feat: mob castle damage
This commit is contained in:
@@ -223,8 +223,9 @@ public:
|
||||
// MobListener
|
||||
|
||||
virtual void OnMobDamage(Mob* target, float damage, Tower* source);
|
||||
|
||||
virtual void OnMobDie(Mob* mob);
|
||||
virtual void OnMobCastleDamage(Mob* damager, TeamCastle* enemyCastle, float damage);
|
||||
|
||||
private:
|
||||
void tickMobs(std::uint64_t delta);
|
||||
void cleanDeadMobs();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user