feat: add pseudo end game

This commit is contained in:
2021-12-12 16:59:35 +01:00
parent f09f79198d
commit e7bf22cea6
2 changed files with 11 additions and 1 deletions

View File

@@ -106,6 +106,8 @@ bool World::saveMap(const std::string& fileName) const {
}
void World::tick(std::uint64_t delta) {
if(m_Game->getGameState() != GameState::Game) return;
tickMobs(delta);
for (TowerPtr tower : m_Towers) {
tower->tick(delta, this);
@@ -293,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) {
// TODO: a team has won
getWorldNotifier().notifyListeners(&WorldListener::OnGameEnd);
}
}
@@ -304,6 +306,10 @@ void World::OnMobDamage(Mob* target, float damage, Tower* source) {
}
}
void World::OnGameEnd(){
m_Game->setGameState(GameState::EndGame);
}
Team& World::getRedTeam() {
return m_Game->getRedTeam();
}