move towers implementations

This commit is contained in:
2023-01-02 14:47:02 +01:00
parent ed45995645
commit 5a547b6514
12 changed files with 195 additions and 114 deletions

View File

@@ -0,0 +1,22 @@
#include "game/Towers.h"
#include "game/World.h"
namespace td {
namespace game {
void IceTower::Tick(std::uint64_t delta, World* world) {
if (m_Timer.Update(delta)) {
float damage = GetStats()->GetDamage();
for (MobPtr mob : world->GetMobList()) {
if (IsMobInRange(mob)) {
mob->AddEffect(EffectType::Slowness, 1, this); // slowness for 1s every second
if (damage > 0)
world->GetMobNotifier().NotifyListeners(&MobListener::OnMobDamage, mob.get(), damage, this);
m_Timer.ApplyCooldown();
}
}
}
}
} // namespace game
} // namespace td