feat: add basic tower mecanic

This commit is contained in:
2021-09-28 19:19:54 +02:00
parent 26d1dd9d36
commit 1e35146c4b
8 changed files with 104 additions and 26 deletions

View File

@@ -322,8 +322,9 @@ bool World::saveMap(const std::string& fileName) const {
void World::tick(std::uint64_t delta) {
moveMobs(delta);
for(TowerPtr tower : m_Towers){
tower->tick(delta);
tower->tick(delta, this);
}
cleanDeadMobs();
}
void World::spawnMobAt(MobID id, MobType type, std::uint8_t level, PlayerID sender, float x, float y, Direction dir) {
@@ -447,6 +448,15 @@ bool World::CanPlaceBigTower(const glm::vec2& worldPos, PlayerID playerID) const
return false;
}
void World::cleanDeadMobs(){
for(auto it = m_Mobs.begin(); it != m_Mobs.end(); it++){
MobPtr mob = *it;
if(!mob->isAlive()){
m_Mobs.erase(it);
}
}
}
Team& World::getRedTeam() {
return m_Game->getRedTeam();
}