Add in death sounds.
This commit is contained in:
parent
90a2b5c562
commit
1801f82248
@ -22,5 +22,8 @@ namespace Sound{
|
|||||||
TURRET,
|
TURRET,
|
||||||
MEMORY_GUARD,
|
MEMORY_GUARD,
|
||||||
SPAWN,
|
SPAWN,
|
||||||
|
DEAD1,
|
||||||
|
DEAD2,
|
||||||
|
DEAD3,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -655,6 +655,20 @@ int Unit::GetBits(Marker&m){
|
|||||||
return activeBits;
|
return activeBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Unit::_OnDeath(std::vector<std::unique_ptr<Audio>>&SOUNDS){
|
||||||
|
switch(rand()%3){
|
||||||
|
case 0:{
|
||||||
|
SOUNDS[Sound::DEAD1]->Play(GetPos());
|
||||||
|
}break;
|
||||||
|
case 1:{
|
||||||
|
SOUNDS[Sound::DEAD2]->Play(GetPos());
|
||||||
|
}break;
|
||||||
|
case 2:{
|
||||||
|
SOUNDS[Sound::DEAD3]->Play(GetPos());
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
OnDeath(SOUNDS);
|
||||||
|
}
|
||||||
void Unit::OnDeath(std::vector<std::unique_ptr<Audio>>&SOUNDS){}
|
void Unit::OnDeath(std::vector<std::unique_ptr<Audio>>&SOUNDS){}
|
||||||
|
|
||||||
int Unit::GetHealth(){
|
int Unit::GetHealth(){
|
||||||
|
|||||||
@ -50,6 +50,7 @@ public:
|
|||||||
virtual void Draw(TileTransformedView&game,std::vector<std::unique_ptr<Renderable>>&IMAGES);
|
virtual void Draw(TileTransformedView&game,std::vector<std::unique_ptr<Renderable>>&IMAGES);
|
||||||
virtual void DrawHud(TileTransformedView&game,std::vector<std::unique_ptr<Renderable>>&IMAGES);
|
virtual void DrawHud(TileTransformedView&game,std::vector<std::unique_ptr<Renderable>>&IMAGES);
|
||||||
void _DrawHud(TileTransformedView&game,std::vector<std::unique_ptr<Renderable>>&IMAGES,bool unitMetersGreyedOut);
|
void _DrawHud(TileTransformedView&game,std::vector<std::unique_ptr<Renderable>>&IMAGES,bool unitMetersGreyedOut);
|
||||||
|
void _OnDeath(std::vector<std::unique_ptr<Audio>>&SOUNDS);
|
||||||
virtual void OnDeath(std::vector<std::unique_ptr<Audio>>&SOUNDS);
|
virtual void OnDeath(std::vector<std::unique_ptr<Audio>>&SOUNDS);
|
||||||
bool IsFriendly();
|
bool IsFriendly();
|
||||||
bool IsSelected();
|
bool IsSelected();
|
||||||
|
|||||||
@ -350,6 +350,9 @@ void VirusAttack::InitializeSounds(){
|
|||||||
LoadSound(Sound::TURRET,"turret.mp3");
|
LoadSound(Sound::TURRET,"turret.mp3");
|
||||||
LoadSound(Sound::MEMORY_GUARD,"memoryguard.mp3");
|
LoadSound(Sound::MEMORY_GUARD,"memoryguard.mp3");
|
||||||
LoadSound(Sound::SPAWN,"spawn.mp3");
|
LoadSound(Sound::SPAWN,"spawn.mp3");
|
||||||
|
LoadSound(Sound::DEAD1,"dead1.mp3");
|
||||||
|
LoadSound(Sound::DEAD2,"dead2.mp3");
|
||||||
|
LoadSound(Sound::DEAD3,"dead3.mp3");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VirusAttack::UnitCreationClickHandled(){
|
bool VirusAttack::UnitCreationClickHandled(){
|
||||||
@ -899,7 +902,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
|
|||||||
|
|
||||||
std::erase_if(units,[&](std::shared_ptr<Unit>u){
|
std::erase_if(units,[&](std::shared_ptr<Unit>u){
|
||||||
if(u->GetHealth()==0){
|
if(u->GetHealth()==0){
|
||||||
u->OnDeath(SOUNDS);
|
u->_OnDeath(SOUNDS);
|
||||||
deathAnimations.emplace_back(std::make_unique<DeathAnimation>(this,u->GetPos(),u->GetImage(),*IMAGES[MATRIX],u->IsFriendly()));
|
deathAnimations.emplace_back(std::make_unique<DeathAnimation>(this,u->GetPos(),u->GetImage(),*IMAGES[MATRIX],u->IsFriendly()));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user