feat: mob castle damage
This commit is contained in:
@@ -223,8 +223,9 @@ public:
|
|||||||
// MobListener
|
// MobListener
|
||||||
|
|
||||||
virtual void OnMobDamage(Mob* target, float damage, Tower* source);
|
virtual void OnMobDamage(Mob* target, float damage, Tower* source);
|
||||||
|
|
||||||
virtual void OnMobDie(Mob* mob);
|
virtual void OnMobDie(Mob* mob);
|
||||||
|
virtual void OnMobCastleDamage(Mob* damager, TeamCastle* enemyCastle, float damage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void tickMobs(std::uint64_t delta);
|
void tickMobs(std::uint64_t delta);
|
||||||
void cleanDeadMobs();
|
void cleanDeadMobs();
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ void Mob::addEffect(EffectType effectType, float durationSec, Tower* tower) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mob::attackCastle(std::uint64_t delta, World* world) {
|
void Mob::attackCastle(std::uint64_t delta, World* world) {
|
||||||
|
if(!hasReachedEnemyCastle()) return;
|
||||||
|
|
||||||
if (m_AttackTimer.update(delta)) {
|
if (m_AttackTimer.update(delta)) {
|
||||||
world->getMobNotifier().notifyListeners(&MobListener::OnMobCastleDamage, this, m_CastleTarget, getStats()->getDamage());
|
world->getMobNotifier().notifyListeners(&MobListener::OnMobCastleDamage, this, m_CastleTarget, getStats()->getDamage());
|
||||||
m_AttackTimer.applyCooldown();
|
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) {
|
void World::OnMobDamage(Mob* target, float damage, Tower* source) {
|
||||||
target->damage(damage, source);
|
target->damage(damage, source);
|
||||||
if (target->isDead()) {
|
if (target->isDead()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user