move towers implementations
This commit is contained in:
@@ -201,119 +201,5 @@ std::string GetTowerName(TowerType type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace TowerFactory
|
} // 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 game
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|||||||
25
src/game/towers/ArcherTower.cpp
Normal file
25
src/game/towers/ArcherTower.cpp
Normal file
@@ -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
|
||||||
12
src/game/towers/ArtilleryTower.cpp
Normal file
12
src/game/towers/ArtilleryTower.cpp
Normal file
@@ -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
|
||||||
22
src/game/towers/IceTower.cpp
Normal file
22
src/game/towers/IceTower.cpp
Normal file
@@ -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
|
||||||
12
src/game/towers/LeachTower.cpp
Normal file
12
src/game/towers/LeachTower.cpp
Normal file
@@ -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
|
||||||
19
src/game/towers/MageTower.cpp
Normal file
19
src/game/towers/MageTower.cpp
Normal file
@@ -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
|
||||||
12
src/game/towers/Necromancer.cpp
Normal file
12
src/game/towers/Necromancer.cpp
Normal file
@@ -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
|
||||||
45
src/game/towers/PoisonTower.cpp
Normal file
45
src/game/towers/PoisonTower.cpp
Normal file
@@ -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
|
||||||
12
src/game/towers/QuakeTower.cpp
Normal file
12
src/game/towers/QuakeTower.cpp
Normal file
@@ -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
|
||||||
12
src/game/towers/SorcererTower.cpp
Normal file
12
src/game/towers/SorcererTower.cpp
Normal file
@@ -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
|
||||||
12
src/game/towers/TurretTower.cpp
Normal file
12
src/game/towers/TurretTower.cpp
Normal file
@@ -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
|
||||||
12
src/game/towers/ZeusTower.cpp
Normal file
12
src/game/towers/ZeusTower.cpp
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user