diff --git a/assets/Media/Audio/Music.meta b/assets/Media/Audio/Music.meta new file mode 100644 index 0000000..98e165d --- /dev/null +++ b/assets/Media/Audio/Music.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "beb2e2db-0402-4a36-957d-2f5333ed6557", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/assets/Media/Audio/Music/Goblins_Dance_(Battle).wav b/assets/Media/Audio/Music/Goblins_Dance_(Battle).wav new file mode 100644 index 0000000..f2a1bb1 Binary files /dev/null and b/assets/Media/Audio/Music/Goblins_Dance_(Battle).wav differ diff --git a/assets/Media/Audio/Music/Goblins_Dance_(Battle).wav.meta b/assets/Media/Audio/Music/Goblins_Dance_(Battle).wav.meta new file mode 100644 index 0000000..c856c2c --- /dev/null +++ b/assets/Media/Audio/Music/Goblins_Dance_(Battle).wav.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "0faecdcf-e5d6-4cc1-b3cf-3b2873f8ee62", + "files": [ + ".json", + ".wav" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Audio/Sound/07_human_atk_sword_1.wav b/assets/Media/Audio/Sound/07_human_atk_sword_1.wav new file mode 100644 index 0000000..f6626f5 Binary files /dev/null and b/assets/Media/Audio/Sound/07_human_atk_sword_1.wav differ diff --git a/assets/Media/Audio/Sound/07_human_atk_sword_1.wav.meta b/assets/Media/Audio/Sound/07_human_atk_sword_1.wav.meta new file mode 100644 index 0000000..bd171a6 --- /dev/null +++ b/assets/Media/Audio/Sound/07_human_atk_sword_1.wav.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "5ad08e27-4461-464a-ad19-8c933abf5a5d", + "files": [ + ".json", + ".wav" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Audio/Sound/GP_Damage_8.wav b/assets/Media/Audio/Sound/GP_Damage_8.wav new file mode 100644 index 0000000..d12e9cc Binary files /dev/null and b/assets/Media/Audio/Sound/GP_Damage_8.wav differ diff --git a/assets/Media/Audio/Sound/GP_Damage_8.wav.meta b/assets/Media/Audio/Sound/GP_Damage_8.wav.meta new file mode 100644 index 0000000..7cb1744 --- /dev/null +++ b/assets/Media/Audio/Sound/GP_Damage_8.wav.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "efed223f-7b17-47ad-b265-7a951ace6d85", + "files": [ + ".json", + ".wav" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Audio/Sound/GP_Damage_9.wav b/assets/Media/Audio/Sound/GP_Damage_9.wav new file mode 100644 index 0000000..a1b0e09 Binary files /dev/null and b/assets/Media/Audio/Sound/GP_Damage_9.wav differ diff --git a/assets/Media/Audio/Sound/GP_Damage_9.wav.meta b/assets/Media/Audio/Sound/GP_Damage_9.wav.meta new file mode 100644 index 0000000..f7979ee --- /dev/null +++ b/assets/Media/Audio/Sound/GP_Damage_9.wav.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "99fb12ce-b248-4560-85fd-c1a61689adf2", + "files": [ + ".json", + ".wav" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Audio/Sound/GP_Heal_1.wav b/assets/Media/Audio/Sound/GP_Heal_1.wav new file mode 100644 index 0000000..d63c07a Binary files /dev/null and b/assets/Media/Audio/Sound/GP_Heal_1.wav differ diff --git a/assets/Media/Audio/Sound/GP_Heal_1.wav.meta b/assets/Media/Audio/Sound/GP_Heal_1.wav.meta new file mode 100644 index 0000000..247f092 --- /dev/null +++ b/assets/Media/Audio/Sound/GP_Heal_1.wav.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "4bf29238-2767-4178-a74a-3c2857685265", + "files": [ + ".json", + ".wav" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Audio/Sound/GP_Turbo_Discard_2.wav b/assets/Media/Audio/Sound/GP_Turbo_Discard_2.wav new file mode 100644 index 0000000..dda983b Binary files /dev/null and b/assets/Media/Audio/Sound/GP_Turbo_Discard_2.wav differ diff --git a/assets/Media/Audio/Sound/GP_Turbo_Discard_2.wav.meta b/assets/Media/Audio/Sound/GP_Turbo_Discard_2.wav.meta new file mode 100644 index 0000000..10c823d --- /dev/null +++ b/assets/Media/Audio/Sound/GP_Turbo_Discard_2.wav.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "6af287fc-820f-4e12-8b8f-858a5dd41d2c", + "files": [ + ".json", + ".wav" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Audio/Sound/Special_Powerup_10.WAV b/assets/Media/Audio/Sound/Special_Powerup_10.WAV new file mode 100644 index 0000000..7e5941e Binary files /dev/null and b/assets/Media/Audio/Sound/Special_Powerup_10.WAV differ diff --git a/assets/Media/Audio/Sound/Special_Powerup_10.WAV.meta b/assets/Media/Audio/Sound/Special_Powerup_10.WAV.meta new file mode 100644 index 0000000..724ef98 --- /dev/null +++ b/assets/Media/Audio/Sound/Special_Powerup_10.WAV.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "b1564752-035d-4989-aed0-2c0684d8a0e9", + "files": [ + ".json", + ".wav" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Audio/Sound/UI_Select_2.wav b/assets/Media/Audio/Sound/UI_Select_2.wav new file mode 100644 index 0000000..c870f6a Binary files /dev/null and b/assets/Media/Audio/Sound/UI_Select_2.wav differ diff --git a/assets/Media/Audio/Sound/UI_Select_2.wav.meta b/assets/Media/Audio/Sound/UI_Select_2.wav.meta new file mode 100644 index 0000000..6adde8b --- /dev/null +++ b/assets/Media/Audio/Sound/UI_Select_2.wav.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "c36e792e-caa2-42f7-b314-eb3f8ad3b280", + "files": [ + ".json", + ".wav" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Audio/Sound/coin.1.ogg b/assets/Media/Audio/Sound/coin.1.ogg new file mode 100644 index 0000000..e1cd573 Binary files /dev/null and b/assets/Media/Audio/Sound/coin.1.ogg differ diff --git a/assets/Media/Audio/Sound/coin.1.ogg.meta b/assets/Media/Audio/Sound/coin.1.ogg.meta new file mode 100644 index 0000000..2b3e34d --- /dev/null +++ b/assets/Media/Audio/Sound/coin.1.ogg.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "audio-clip", + "imported": true, + "uuid": "580b2ceb-3daa-409b-b6c4-7d81c7182650", + "files": [ + ".json", + ".ogg" + ], + "subMetas": {}, + "userData": { + "downloadMode": 0 + } +} diff --git a/assets/Media/Prefabs/AppRoot.prefab b/assets/Media/Prefabs/AppRoot.prefab index 543fa97..7fc5ad3 100644 --- a/assets/Media/Prefabs/AppRoot.prefab +++ b/assets/Media/Prefabs/AppRoot.prefab @@ -243,9 +243,12 @@ "__prefab": { "__id__": 9 }, - "_clip": null, + "_clip": { + "__uuid__": "0faecdcf-e5d6-4cc1-b3cf-3b2873f8ee62", + "__expectedType__": "cc.AudioClip" + }, "_loop": true, - "_playOnAwake": false, + "_playOnAwake": true, "_volume": 1, "_id": "" }, diff --git a/assets/Scenes/Game.scene b/assets/Scenes/Game.scene index 85ae692..6ab1190 100644 --- a/assets/Scenes/Game.scene +++ b/assets/Scenes/Game.scene @@ -340,8 +340,32 @@ }, "_enabled": true, "__prefab": null, + "music": { + "__uuid__": "0faecdcf-e5d6-4cc1-b3cf-3b2873f8ee62", + "__expectedType__": "cc.AudioClip" + }, "enemyHit": { - "__uuid__": "c2afb64d-ffcf-4ad4-95b7-1ce1035a2166", + "__uuid__": "efed223f-7b17-47ad-b265-7a951ace6d85", + "__expectedType__": "cc.AudioClip" + }, + "weaponSwing": { + "__uuid__": "5ad08e27-4461-464a-ad19-8c933abf5a5d", + "__expectedType__": "cc.AudioClip" + }, + "xpPickup": { + "__uuid__": "6af287fc-820f-4e12-8b8f-858a5dd41d2c", + "__expectedType__": "cc.AudioClip" + }, + "goldPickup": { + "__uuid__": "580b2ceb-3daa-409b-b6c4-7d81c7182650", + "__expectedType__": "cc.AudioClip" + }, + "healthPotionPickup": { + "__uuid__": "b1564752-035d-4989-aed0-2c0684d8a0e9", + "__expectedType__": "cc.AudioClip" + }, + "levelUp": { + "__uuid__": "4bf29238-2767-4178-a74a-3c2857685265", "__expectedType__": "cc.AudioClip" }, "_id": "8fIp3RG7RDK6FMarL5A96h" @@ -1373,7 +1397,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": -320, - "y": 479.9999999999999, + "y": 480, "z": -1000 }, "_lrot": { @@ -3000,7 +3024,7 @@ "_priority": 1073741824, "_fov": 45, "_fovAxis": 0, - "_orthoHeight": 479.99999999999994, + "_orthoHeight": 480, "_near": 0, "_far": 2000, "_color": { diff --git a/assets/Scripts/Game/Audio/GameAudioAdapter.ts b/assets/Scripts/Game/Audio/GameAudioAdapter.ts index ad4874c..4c7700f 100644 --- a/assets/Scripts/Game/Audio/GameAudioAdapter.ts +++ b/assets/Scripts/Game/Audio/GameAudioAdapter.ts @@ -1,19 +1,34 @@ import { _decorator, Component, Node, AudioClip } from "cc"; import { AppRoot } from "../../AppRoot/AppRoot"; import { AudioPlayer } from "../../Services/AudioPlayer/AudioPlayer"; +import { ItemManager, ItemType } from "../Items/ItemManager"; import { Enemy } from "../Unit/Enemy/Enemy"; import { EnemyManager } from "../Unit/Enemy/EnemyManager"; +import { Player } from "../Unit/Player/Player"; const { ccclass, property } = _decorator; @ccclass("GameAudioAdapter") export class GameAudioAdapter extends Component { + @property(AudioClip) private music: AudioClip; @property(AudioClip) private enemyHit: AudioClip; + @property(AudioClip) private weaponSwing: AudioClip; + @property(AudioClip) private xpPickup: AudioClip; + @property(AudioClip) private goldPickup: AudioClip; + @property(AudioClip) private healthPotionPickup: AudioClip; + @property(AudioClip) private levelUp: AudioClip; private audioPlayer: AudioPlayer; - public init(enemyManager: EnemyManager): void { + public init(player: Player, enemyManager: EnemyManager, itemManager: ItemManager): void { + AppRoot.Instance.AudioPlayer.playMusic(this.music); + this.audioPlayer = AppRoot.Instance.AudioPlayer; + player.Weapon.WeaponStrikeEvent.on(() => this.audioPlayer.playSound(this.weaponSwing), this); + player.Level.LevelUpEvent.on(() => this.audioPlayer.playSound(this.levelUp), this); + + itemManager.PickupEvent.on(this.playPickupItemSound, this); + enemyManager.EnemyAddedEvent.on(this.addEnemyListeners, this); enemyManager.EnemyRemovedEvent.on(this.removeEnemyListeners, this); } @@ -29,4 +44,23 @@ export class GameAudioAdapter extends Component { private playEnemyHitSound(): void { this.audioPlayer.playSound(this.enemyHit); } + + private playPickupItemSound(itemType: ItemType): void { + let clipToPlay: AudioClip; + switch (itemType) { + case ItemType.XP: + clipToPlay = this.xpPickup; + break; + case ItemType.Gold: + clipToPlay = this.goldPickup; + break; + case ItemType.HealthPotion: + clipToPlay = this.healthPotionPickup; + break; + default: + break; + } + + this.audioPlayer.playSound(clipToPlay); + } } diff --git a/assets/Scripts/Game/Game.ts b/assets/Scripts/Game/Game.ts index a5cd65d..2e1fc41 100644 --- a/assets/Scripts/Game/Game.ts +++ b/assets/Scripts/Game/Game.ts @@ -18,15 +18,15 @@ import { Pauser } from "./Pauser"; import { TestValues } from "./TestGameRunner"; import { GameUI } from "./UI/GameUI"; import { EnemyManager } from "./Unit/Enemy/EnemyManager"; +import { EnemyProjectileLauncher } from "./Unit/Enemy/ProjectileLauncher.cs/EnemyProjectileLauncher"; import { MetaUpgrades } from "./Unit/MetaUpgrades/MetaUpgrades"; import { Player, PlayerData } from "./Unit/Player/Player"; import { HaloProjectileLauncher } from "./Unit/Player/ProjectileLauncher/HaloProjectileLauncher"; -import { ProjectileLauncher } from "./Unit/Player/ProjectileLauncher/ProjectileLauncher"; import { ProjectileData } from "./Unit/Player/ProjectileLauncher/ProjectileData"; +import { ProjectileLauncher } from "./Unit/Player/ProjectileLauncher/ProjectileLauncher"; import { WaveProjectileLauncher } from "./Unit/Player/ProjectileLauncher/WaveProjectileLauncher"; import { Upgrader } from "./Upgrades/Upgrader"; import { MetaUpgradeType } from "./Upgrades/UpgradeType"; -import { EnemyProjectileLauncher } from "./Unit/Enemy/ProjectileLauncher.cs/EnemyProjectileLauncher"; const { ccclass, property } = _decorator; @@ -144,7 +144,7 @@ export class Game extends Component { this.player.Level.addXp(testValues.startXP); } - this.gameAudioAdapter.init(this.enemyManager); + this.gameAudioAdapter.init(this.player, this.enemyManager, this.itemManager); this.gamePauser.resume(); while (!this.gameResult.hasExitManually && this.player.Health.IsAlive) await delay(100); diff --git a/assets/Scripts/Game/Items/ItemManager.ts b/assets/Scripts/Game/Items/ItemManager.ts index 8a47f27..525bc83 100644 --- a/assets/Scripts/Game/Items/ItemManager.ts +++ b/assets/Scripts/Game/Items/ItemManager.ts @@ -1,4 +1,6 @@ import { Component, random, randomRange, Vec3, _decorator } from "cc"; +import { ISignal } from "../../Services/EventSystem/ISignal"; +import { Signal } from "../../Services/EventSystem/Signal"; import { ItemSettings } from "../Data/GameSettings"; import { GameResult } from "../Game"; import { Enemy } from "../Unit/Enemy/Enemy"; @@ -24,6 +26,8 @@ export class ItemManager extends Component { private gameResult: GameResult; private healthPerPotion: number; + private pickupEvent = new Signal(); + public init(enemyManager: EnemyManager, player: Player, gameResult: GameResult, settings: ItemSettings): void { this.player = player; this.gameResult = gameResult; @@ -38,8 +42,13 @@ export class ItemManager extends Component { this.pickupEffectManager.init(); } + public get PickupEvent(): ISignal { + return this.pickupEvent; + } + public pickupXP(xp: XP): void { this.pickupEffectManager.showEffect(xp.node.worldPosition); + this.pickupEvent.trigger(ItemType.XP); this.player.Level.addXp(xp.Value); xp.pickup(); @@ -47,6 +56,7 @@ export class ItemManager extends Component { public pickupGold(gold: Gold): void { this.pickupEffectManager.showEffect(gold.node.worldPosition); + this.pickupEvent.trigger(ItemType.Gold); gold.pickup(); this.gameResult.goldCoins++; @@ -54,6 +64,7 @@ export class ItemManager extends Component { public pickupHealthPotion(healthPotion: HealthPotion): void { this.pickupEffectManager.showEffect(healthPotion.node.worldPosition); + this.pickupEvent.trigger(ItemType.HealthPotion); healthPotion.pickup(); this.player.Health.heal(this.healthPerPotion); @@ -110,3 +121,9 @@ export class ItemManager extends Component { return position; } } + +export enum ItemType { + XP, + Gold, + HealthPotion +} diff --git a/assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts b/assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts index 5dd1f99..d27ac30 100644 --- a/assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts +++ b/assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts @@ -1,6 +1,7 @@ import { Animation, AnimationState, Component, _decorator } from "cc"; +import { ISignal } from "../../../../Services/EventSystem/ISignal"; +import { Signal } from "../../../../Services/EventSystem/Signal"; import { GameTimer } from "../../../../Services/GameTimer"; -import { WeaponSettings } from "../../../Data/GameSettings"; import { UpgradableCollider } from "./UpgradableCollider"; const { ccclass, property } = _decorator; @@ -10,6 +11,8 @@ export class Weapon extends Component { @property(Animation) private weaponAnimation: Animation; @property(UpgradableCollider) private upgradableCollider: UpgradableCollider; + private weaponStrikeEvent = new Signal(); + private strikeTimer: GameTimer; private strikeState: AnimationState; private damage: number; @@ -33,6 +36,10 @@ export class Weapon extends Component { } } + public get WeaponStrikeEvent(): ISignal { + return this.weaponStrikeEvent; + } + public get Collider(): UpgradableCollider { return this.upgradableCollider; } @@ -51,6 +58,7 @@ export class Weapon extends Component { private strike(): void { this.node.active = true; this.weaponAnimation.play(this.strikeState.name); + this.weaponStrikeEvent.trigger(this); } private endStrike(): void {