feat: mob castle damage

This commit is contained in:
2021-12-11 20:06:52 +01:00
parent c4a2b08416
commit fd9b448fa4
3 changed files with 11 additions and 1 deletions

View File

@@ -33,6 +33,8 @@ void Mob::addEffect(EffectType effectType, float durationSec, Tower* tower) {
}
void Mob::attackCastle(std::uint64_t delta, World* world) {
if(!hasReachedEnemyCastle()) return;
if (m_AttackTimer.update(delta)) {
world->getMobNotifier().notifyListeners(&MobListener::OnMobCastleDamage, this, m_CastleTarget, getStats()->getDamage());
m_AttackTimer.applyCooldown();

View File

@@ -286,6 +286,13 @@ 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
}
}
void World::OnMobDamage(Mob* target, float damage, Tower* source) {
target->damage(damage, source);
if (target->isDead()) {