diff --git a/src/game/Towers.cpp b/src/game/Towers.cpp index 0bcd6af..f8bced2 100644 --- a/src/game/Towers.cpp +++ b/src/game/Towers.cpp @@ -201,119 +201,5 @@ std::string GetTowerName(TowerType type) { } } // namespace TowerFactory - - - - - -void ArcherTower::Tick(std::uint64_t delta, World* world) { - if (m_Timer.Update(delta)) { - 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->GetWorldNotifier().NotifyListeners(&WorldListener::OnArcherTowerShot, mob, this); - m_Timer.ApplyCooldown(); - arrowsShot++; - if (arrowsShot >= arrows) - break; - } - } - } -} - -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(); - } - } - } -} - -void MageTower::Tick(std::uint64_t delta, World* world) { - if (m_Timer.Update(delta)) { - for (MobPtr mob : world->GetMobList()) { - if (IsMobInRange(mob)) { - mob->AddEffect(EffectType::Fire, GetLevel().GetLevel() * 3, this); - m_Timer.ApplyCooldown(); - } - } - } -} - -void PoisonTower::Tick(std::uint64_t delta, World* world) { - if (m_Timer.Update(delta)) { - for (MobPtr mob : world->GetMobList()) { - if (IsMobInRange(mob)) { - if (GetLevel().GetPath() == TowerPath::Bottom) { - world->GetMobNotifier().NotifyListeners(&MobListener::OnMobDamage, mob.get(), GetStats()->GetDamage(), this); - } else { - float durationSec; - switch (GetLevel().GetLevel()) { - case 1: - durationSec = 5; - break; - - case 2: - durationSec = 15; - break; - - case 3: - durationSec = 30; - break; - - case 4: - durationSec = 1e10; // about 3 million hours. It should be enough - break; - - default: - durationSec = 0; // how did we get there ? - break; - } - mob->AddEffect(EffectType::Poison, durationSec, this); - } - m_Timer.ApplyCooldown(); - } - } - } -} - -void QuakeTower::Tick(std::uint64_t delta, World* world) { - -} - -void ZeusTower::Tick(std::uint64_t delta, World* world) { - -} - -void ArtilleryTower::Tick(std::uint64_t delta, World* world) { - -} - -void SorcererTower::Tick(std::uint64_t delta, World* world) { - -} - - - -void LeachTower::Tick(std::uint64_t delta, World* world) { - -} - -void TurretTower::Tick(std::uint64_t delta, World* world) { - -} - -void NecromancerTower::Tick(std::uint64_t delta, World* world) { - -} - } // namespace game } // namespace td diff --git a/src/game/towers/ArcherTower.cpp b/src/game/towers/ArcherTower.cpp new file mode 100644 index 0000000..9bad50f --- /dev/null +++ b/src/game/towers/ArcherTower.cpp @@ -0,0 +1,25 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void ArcherTower::Tick(std::uint64_t delta, World* world) { + if (m_Timer.Update(delta)) { + 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->GetWorldNotifier().NotifyListeners(&WorldListener::OnArcherTowerShot, mob, this); + m_Timer.ApplyCooldown(); + arrowsShot++; + if (arrowsShot >= arrows) + break; + } + } + } +} + +} // namespace game +} // namespace td diff --git a/src/game/towers/ArtilleryTower.cpp b/src/game/towers/ArtilleryTower.cpp new file mode 100644 index 0000000..ee0e488 --- /dev/null +++ b/src/game/towers/ArtilleryTower.cpp @@ -0,0 +1,12 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void ArtilleryTower::Tick(std::uint64_t delta, World* world) { + +} + +} // namespace game +} // namespace td \ No newline at end of file diff --git a/src/game/towers/IceTower.cpp b/src/game/towers/IceTower.cpp new file mode 100644 index 0000000..3a79c60 --- /dev/null +++ b/src/game/towers/IceTower.cpp @@ -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 \ No newline at end of file diff --git a/src/game/towers/LeachTower.cpp b/src/game/towers/LeachTower.cpp new file mode 100644 index 0000000..35f07c8 --- /dev/null +++ b/src/game/towers/LeachTower.cpp @@ -0,0 +1,12 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void LeachTower::Tick(std::uint64_t delta, World* world) { + +} + +} // namespace game +} // namespace td \ No newline at end of file diff --git a/src/game/towers/MageTower.cpp b/src/game/towers/MageTower.cpp new file mode 100644 index 0000000..7501eb4 --- /dev/null +++ b/src/game/towers/MageTower.cpp @@ -0,0 +1,19 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void MageTower::Tick(std::uint64_t delta, World* world) { + if (m_Timer.Update(delta)) { + for (MobPtr mob : world->GetMobList()) { + if (IsMobInRange(mob)) { + mob->AddEffect(EffectType::Fire, GetLevel().GetLevel() * 3, this); + m_Timer.ApplyCooldown(); + } + } + } +} + +} // namespace game +} // namespace td \ No newline at end of file diff --git a/src/game/towers/Necromancer.cpp b/src/game/towers/Necromancer.cpp new file mode 100644 index 0000000..1fc1715 --- /dev/null +++ b/src/game/towers/Necromancer.cpp @@ -0,0 +1,12 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void NecromancerTower::Tick(std::uint64_t delta, World* world) { + +} + +} // namespace game +} // namespace td \ No newline at end of file diff --git a/src/game/towers/PoisonTower.cpp b/src/game/towers/PoisonTower.cpp new file mode 100644 index 0000000..515152c --- /dev/null +++ b/src/game/towers/PoisonTower.cpp @@ -0,0 +1,45 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void PoisonTower::Tick(std::uint64_t delta, World* world) { + if (m_Timer.Update(delta)) { + for (MobPtr mob : world->GetMobList()) { + if (IsMobInRange(mob)) { + if (GetLevel().GetPath() == TowerPath::Bottom) { + world->GetMobNotifier().NotifyListeners(&MobListener::OnMobDamage, mob.get(), GetStats()->GetDamage(), this); + } else { + float durationSec; + switch (GetLevel().GetLevel()) { + case 1: + durationSec = 5; + break; + + case 2: + durationSec = 15; + break; + + case 3: + durationSec = 30; + break; + + case 4: + durationSec = 1e10; // about 3 million hours. It should be enough + break; + + default: + durationSec = 0; // how did we get there ? + break; + } + mob->AddEffect(EffectType::Poison, durationSec, this); + } + m_Timer.ApplyCooldown(); + } + } + } +} + +} // namespace game +} // namespace td \ No newline at end of file diff --git a/src/game/towers/QuakeTower.cpp b/src/game/towers/QuakeTower.cpp new file mode 100644 index 0000000..98aea48 --- /dev/null +++ b/src/game/towers/QuakeTower.cpp @@ -0,0 +1,12 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void QuakeTower::Tick(std::uint64_t delta, World* world) { + +} + +} // namespace game +} // namespace td \ No newline at end of file diff --git a/src/game/towers/SorcererTower.cpp b/src/game/towers/SorcererTower.cpp new file mode 100644 index 0000000..ac7cf10 --- /dev/null +++ b/src/game/towers/SorcererTower.cpp @@ -0,0 +1,12 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void SorcererTower::Tick(std::uint64_t delta, World* world) { + +} + +} // namespace game +} // namespace td \ No newline at end of file diff --git a/src/game/towers/TurretTower.cpp b/src/game/towers/TurretTower.cpp new file mode 100644 index 0000000..8cee3c6 --- /dev/null +++ b/src/game/towers/TurretTower.cpp @@ -0,0 +1,12 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void TurretTower::Tick(std::uint64_t delta, World* world) { + +} + +} // namespace game +} // namespace td \ No newline at end of file diff --git a/src/game/towers/ZeusTower.cpp b/src/game/towers/ZeusTower.cpp new file mode 100644 index 0000000..58332a6 --- /dev/null +++ b/src/game/towers/ZeusTower.cpp @@ -0,0 +1,12 @@ +#include "game/Towers.h" +#include "game/World.h" + +namespace td { +namespace game { + +void ZeusTower::Tick(std::uint64_t delta, World* world) { + +} + +} // namespace game +} // namespace td \ No newline at end of file