refactor: add game listener
This commit is contained in:
@@ -106,7 +106,7 @@ bool World::saveMap(const std::string& fileName) const {
|
||||
}
|
||||
|
||||
void World::tick(std::uint64_t delta) {
|
||||
if(m_Game->getGameState() != GameState::Game) return;
|
||||
if (m_Game->getGameState() != GameState::Game) return;
|
||||
|
||||
tickMobs(delta);
|
||||
for (TowerPtr tower : m_Towers) {
|
||||
@@ -295,7 +295,7 @@ void World::OnExplosion(utils::shape::Circle explosion, float centerDamage, Towe
|
||||
void World::OnMobCastleDamage(Mob* damager, TeamCastle* enemyCastle, float damage) {
|
||||
enemyCastle->damage(damage);
|
||||
if (enemyCastle->getLife() <= 0) {
|
||||
getWorldNotifier().notifyListeners(&WorldListener::OnGameEnd);
|
||||
m_Game->notifyListeners(&GameListener::OnGameEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,10 +306,6 @@ void World::OnMobDamage(Mob* target, float damage, Tower* source) {
|
||||
}
|
||||
}
|
||||
|
||||
void World::OnGameEnd(){
|
||||
m_Game->setGameState(GameState::EndGame);
|
||||
}
|
||||
|
||||
Team& World::getRedTeam() {
|
||||
return m_Game->getRedTeam();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user