From 354be800ecdf34accc470ff65ea35548f144a655 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 30 Dec 2022 15:19:32 +0100 Subject: [PATCH] Enemy projectiles --- .../Game/Projectiles/AxeProjectile.prefab | 53 ++++++++----------- .../Projectiles/MagicOrbProjectile.prefab | 53 ++++++++----------- assets/Scenes/Game.scene | 2 +- assets/Scripts/Game/Projectile/Projectile.ts | 2 +- .../ProjectileLauncher/ProjectileLauncher.ts | 8 +-- 5 files changed, 48 insertions(+), 70 deletions(-) diff --git a/assets/Media/Prefabs/Game/Projectiles/AxeProjectile.prefab b/assets/Media/Prefabs/Game/Projectiles/AxeProjectile.prefab index c04f0df..d9177f5 100644 --- a/assets/Media/Prefabs/Game/Projectiles/AxeProjectile.prefab +++ b/assets/Media/Prefabs/Game/Projectiles/AxeProjectile.prefab @@ -257,37 +257,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "5dR8969SVAfLXx5AY1X9B5" }, - { - "__type__": "7f8b6NKHsNNW5nLY3fwejhw", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 13 - }, - "collider": { - "__id__": 10 - }, - "sprite": { - "__id__": 5 - }, - "defaultMaterial": { - "__uuid__": "fda095cb-831d-4601-ad94-846013963de8", - "__expectedType__": "cc.Material" - }, - "whiteMaterial": { - "__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44", - "__expectedType__": "cc.Material" - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "b5ONKVkchBpaoqReE981lo" - }, { "__type__": "cc.Animation", "_name": "", @@ -297,7 +266,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 15 + "__id__": 13 }, "playOnLoad": true, "_clips": [ @@ -316,6 +285,26 @@ "__type__": "cc.CompPrefabInfo", "fileId": "74x/uTmM5C8J/ZyOW71lz5" }, + { + "__type__": "6a24eYAhmtMDZo5Wb8iLC5Q", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 15 + }, + "collider": { + "__id__": 10 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "1dAsEzyaRFLKP5Bpu453Ag" + }, { "__type__": "cc.PrefabInfo", "root": { diff --git a/assets/Media/Prefabs/Game/Projectiles/MagicOrbProjectile.prefab b/assets/Media/Prefabs/Game/Projectiles/MagicOrbProjectile.prefab index 7d67263..8d5604e 100644 --- a/assets/Media/Prefabs/Game/Projectiles/MagicOrbProjectile.prefab +++ b/assets/Media/Prefabs/Game/Projectiles/MagicOrbProjectile.prefab @@ -257,37 +257,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "5dR8969SVAfLXx5AY1X9B5" }, - { - "__type__": "7f8b6NKHsNNW5nLY3fwejhw", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 13 - }, - "collider": { - "__id__": 10 - }, - "sprite": { - "__id__": 5 - }, - "defaultMaterial": { - "__uuid__": "fda095cb-831d-4601-ad94-846013963de8", - "__expectedType__": "cc.Material" - }, - "whiteMaterial": { - "__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44", - "__expectedType__": "cc.Material" - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "b5ONKVkchBpaoqReE981lo" - }, { "__type__": "cc.Animation", "_name": "", @@ -297,7 +266,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 15 + "__id__": 13 }, "playOnLoad": true, "_clips": [ @@ -316,6 +285,26 @@ "__type__": "cc.CompPrefabInfo", "fileId": "74x/uTmM5C8J/ZyOW71lz5" }, + { + "__type__": "6a24eYAhmtMDZo5Wb8iLC5Q", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 15 + }, + "collider": { + "__id__": 10 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "d5iBqvxQdEL7D53HbXiPXQ" + }, { "__type__": "cc.PrefabInfo", "root": { diff --git a/assets/Scenes/Game.scene b/assets/Scenes/Game.scene index a7f87b1..7c0ab9d 100644 --- a/assets/Scenes/Game.scene +++ b/assets/Scenes/Game.scene @@ -784,7 +784,7 @@ "_enabled": true, "__prefab": null, "projectilePrefab": { - "__uuid__": "d20eb25c-f8b8-436e-b59c-2c3dbd87b25a", + "__uuid__": "70a69a09-9531-49c5-8671-1732767f94dd", "__expectedType__": "cc.Prefab" }, "_id": "85yfYEMEFN8YoT2mjsrgxI" diff --git a/assets/Scripts/Game/Projectile/Projectile.ts b/assets/Scripts/Game/Projectile/Projectile.ts index 47b67a1..0551b66 100644 --- a/assets/Scripts/Game/Projectile/Projectile.ts +++ b/assets/Scripts/Game/Projectile/Projectile.ts @@ -15,7 +15,7 @@ export class Projectile extends Component { private piercesLeft = 0; private damage = 0; - public init(damage: number, pierces: number, angle: number): void { + public setup(damage: number, pierces: number, angle: number): void { this.piercesLeft = pierces; this.damage = damage; diff --git a/assets/Scripts/Game/Unit/Player/ProjectileLauncher/ProjectileLauncher.ts b/assets/Scripts/Game/Unit/Player/ProjectileLauncher/ProjectileLauncher.ts index 78319b0..33b73c9 100644 --- a/assets/Scripts/Game/Unit/Player/ProjectileLauncher/ProjectileLauncher.ts +++ b/assets/Scripts/Game/Unit/Player/ProjectileLauncher/ProjectileLauncher.ts @@ -13,7 +13,7 @@ const { ccclass, property } = _decorator; export class ProjectileLauncher extends Component implements IProjectileLauncherSignaler { @property(Prefab) private projectilePrefab: Prefab; private projectileCollisionEvent = new Signal(); - private projectileLauncehdEvent = new Signal(); + private projectileLaunchedEvent = new Signal(); private projectileDamage: number; private projectilePierces: number; @@ -32,7 +32,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher } public get ProjectileLaunchedEvent(): ISignal { - return this.projectileLauncehdEvent; + return this.projectileLaunchedEvent; } public init(projectileLifetime: number, projectileSpeed: number, projectileDamage: number, projectilePierces: number): void { @@ -61,7 +61,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher private fireProjectile(startPosition: Vec3, direction: Vec2): void { direction = direction.normalize(); const projectile: Projectile = this.projectilePool.borrow(); - projectile.init(this.projectileDamage, this.projectilePierces, getDegreeAngleFromDirection(direction.x, direction.y)); + projectile.setup(this.projectileDamage, this.projectilePierces, getDegreeAngleFromDirection(direction.x, direction.y)); projectile.node.setWorldPosition(startPosition); projectile.node.active = true; projectile.ContactBeginEvent.on(this.onProjectileCollision, this); @@ -71,7 +71,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher this.directions.push(direction); this.expireTimes.push(this.currentTime + this.projectileLifetime); - this.projectileLauncehdEvent.trigger({}); + this.projectileLaunchedEvent.trigger(); } private tryRemoveExpiredProjectiles(): void {