mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
Additional sounds
This commit is contained in:
parent
c862079727
commit
28a14d379d
BIN
assets/Media/Audio/Sound/GP_Begin_Turn_1.wav
Normal file
BIN
assets/Media/Audio/Sound/GP_Begin_Turn_1.wav
Normal file
Binary file not shown.
14
assets/Media/Audio/Sound/GP_Begin_Turn_1.wav.meta
Normal file
14
assets/Media/Audio/Sound/GP_Begin_Turn_1.wav.meta
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.0",
|
||||||
|
"importer": "audio-clip",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "68ebed5f-544b-4337-a49c-d4ba32e8e6a2",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".wav"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"downloadMode": 0
|
||||||
|
}
|
||||||
|
}
|
@ -348,6 +348,14 @@
|
|||||||
"__uuid__": "efed223f-7b17-47ad-b265-7a951ace6d85",
|
"__uuid__": "efed223f-7b17-47ad-b265-7a951ace6d85",
|
||||||
"__expectedType__": "cc.AudioClip"
|
"__expectedType__": "cc.AudioClip"
|
||||||
},
|
},
|
||||||
|
"playerHit": {
|
||||||
|
"__uuid__": "99fb12ce-b248-4560-85fd-c1a61689adf2",
|
||||||
|
"__expectedType__": "cc.AudioClip"
|
||||||
|
},
|
||||||
|
"playerDeath": {
|
||||||
|
"__uuid__": "68ebed5f-544b-4337-a49c-d4ba32e8e6a2",
|
||||||
|
"__expectedType__": "cc.AudioClip"
|
||||||
|
},
|
||||||
"weaponSwing": {
|
"weaponSwing": {
|
||||||
"__uuid__": "5ad08e27-4461-464a-ad19-8c933abf5a5d",
|
"__uuid__": "5ad08e27-4461-464a-ad19-8c933abf5a5d",
|
||||||
"__expectedType__": "cc.AudioClip"
|
"__expectedType__": "cc.AudioClip"
|
||||||
|
@ -11,6 +11,8 @@ const { ccclass, property } = _decorator;
|
|||||||
export class GameAudioAdapter extends Component {
|
export class GameAudioAdapter extends Component {
|
||||||
@property(AudioClip) private music: AudioClip;
|
@property(AudioClip) private music: AudioClip;
|
||||||
@property(AudioClip) private enemyHit: AudioClip;
|
@property(AudioClip) private enemyHit: AudioClip;
|
||||||
|
@property(AudioClip) private playerHit: AudioClip;
|
||||||
|
@property(AudioClip) private playerDeath: AudioClip;
|
||||||
@property(AudioClip) private weaponSwing: AudioClip;
|
@property(AudioClip) private weaponSwing: AudioClip;
|
||||||
@property(AudioClip) private xpPickup: AudioClip;
|
@property(AudioClip) private xpPickup: AudioClip;
|
||||||
@property(AudioClip) private goldPickup: AudioClip;
|
@property(AudioClip) private goldPickup: AudioClip;
|
||||||
@ -18,14 +20,17 @@ export class GameAudioAdapter extends Component {
|
|||||||
@property(AudioClip) private levelUp: AudioClip;
|
@property(AudioClip) private levelUp: AudioClip;
|
||||||
|
|
||||||
private audioPlayer: AudioPlayer;
|
private audioPlayer: AudioPlayer;
|
||||||
|
private player: Player;
|
||||||
|
|
||||||
public init(player: Player, enemyManager: EnemyManager, itemManager: ItemManager): void {
|
public init(player: Player, enemyManager: EnemyManager, itemManager: ItemManager): void {
|
||||||
AppRoot.Instance.AudioPlayer.playMusic(this.music);
|
AppRoot.Instance.AudioPlayer.playMusic(this.music);
|
||||||
|
|
||||||
this.audioPlayer = AppRoot.Instance.AudioPlayer;
|
this.audioPlayer = AppRoot.Instance.AudioPlayer;
|
||||||
|
this.player = player;
|
||||||
|
|
||||||
player.Weapon.WeaponStrikeEvent.on(() => this.audioPlayer.playSound(this.weaponSwing), this);
|
player.Weapon.WeaponStrikeEvent.on(() => this.audioPlayer.playSound(this.weaponSwing), this);
|
||||||
player.Level.LevelUpEvent.on(() => this.audioPlayer.playSound(this.levelUp), this);
|
player.Level.LevelUpEvent.on(() => this.audioPlayer.playSound(this.levelUp), this);
|
||||||
|
player.Health.HealthPointsChangeEvent.on(this.tryPlayPlayerHitSound, this);
|
||||||
|
|
||||||
itemManager.PickupEvent.on(this.playPickupItemSound, this);
|
itemManager.PickupEvent.on(this.playPickupItemSound, this);
|
||||||
|
|
||||||
@ -41,6 +46,16 @@ export class GameAudioAdapter extends Component {
|
|||||||
enemy.Health.HealthPointsChangeEvent.off(this.playEnemyHitSound);
|
enemy.Health.HealthPointsChangeEvent.off(this.playEnemyHitSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private tryPlayPlayerHitSound(healthChange: number): void {
|
||||||
|
if (healthChange < 0) {
|
||||||
|
this.audioPlayer.playSound(this.playerHit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.player.Health.IsAlive) {
|
||||||
|
this.audioPlayer.playSound(this.playerDeath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private playEnemyHitSound(): void {
|
private playEnemyHitSound(): void {
|
||||||
this.audioPlayer.playSound(this.enemyHit);
|
this.audioPlayer.playSound(this.enemyHit);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user