feat: changed timer mecanic and mage tower

This commit is contained in:
2021-10-11 19:09:56 +02:00
parent a6ccdcc7af
commit a62549e93e
3 changed files with 34 additions and 3 deletions

View File

@@ -168,34 +168,52 @@ TowerPtr createTower(TowerType type, TowerID id, std::int32_t x, std::int32_t y,
void ArcherTower::tick(std::uint64_t delta, World* world) {
if (m_Timer.update(delta)) {
bool wasTowerActive = false;
std::uint8_t arrowsShot = 0;
bool explosiveArrows = getLevel().getPath() == TowerPath::Bottom;
std::uint8_t arrows = explosiveArrows ? 2 : getLevel().getLevel();
for (MobPtr mob : world->getMobList()) {
if (isMobInRange(mob)) {
world->OnArrowShot(mob, this);
wasTowerActive = true;
arrowsShot++;
if (arrowsShot >= arrows)
break;
}
}
if (!wasTowerActive)
m_Timer.wait();
}
}
void IceTower::tick(std::uint64_t delta, World* world) {
if (m_Timer.update(delta)) {
float damage = getStats()->getDamage();
bool wasTowerActive = false;
for (MobPtr mob : world->getMobList()) {
if (isMobInRange(mob)) {
mob->addEffect(EffectType::Slowness, 1); // slowness for 1s every second
mob->damage(damage);
wasTowerActive = true;
}
}
if (!wasTowerActive)
m_Timer.wait();
}
}
void MageTower::tick(std::uint64_t delta, World* world) {
if (m_Timer.update(delta)) {
bool wasTowerActive = false;
for (MobPtr mob : world->getMobList()) {
if (isMobInRange(mob)) {
mob->addEffect(EffectType::Fire, getLevel().getLevel()); // slowness for 1s every second
wasTowerActive = true;
}
}
if (!wasTowerActive)
m_Timer.wait();
}
}
void PoisonTower::tick(std::uint64_t delta, World* world) {