indent with tabs
This commit is contained in:
@@ -8,62 +8,62 @@ namespace td {
|
||||
namespace game {
|
||||
|
||||
enum class GameState : std::uint8_t {
|
||||
Lobby,
|
||||
Game,
|
||||
EndGame,
|
||||
Disconnected,
|
||||
Closed
|
||||
Lobby,
|
||||
Game,
|
||||
EndGame,
|
||||
Disconnected,
|
||||
Closed
|
||||
};
|
||||
|
||||
typedef std::map<std::uint8_t, Player> PlayerList;
|
||||
|
||||
class GameListener {
|
||||
public:
|
||||
virtual void OnPlayerJoin(PlayerID player) {}
|
||||
virtual void OnPlayerLeave(PlayerID player) {}
|
||||
virtual void OnPlayerJoin(PlayerID player) {}
|
||||
virtual void OnPlayerLeave(PlayerID player) {}
|
||||
|
||||
virtual void OnGameStateUpdate(GameState newState) {}
|
||||
virtual void OnGameBegin() {}
|
||||
virtual void OnGameEnd() {}
|
||||
virtual void OnGameClose() {}
|
||||
virtual void OnGameStateUpdate(GameState newState) {}
|
||||
virtual void OnGameBegin() {}
|
||||
virtual void OnGameEnd() {}
|
||||
virtual void OnGameClose() {}
|
||||
};
|
||||
|
||||
typedef utils::ObjectNotifier<GameListener> GameNotifier;
|
||||
|
||||
class Game : public GameNotifier {
|
||||
protected:
|
||||
World* m_World;
|
||||
TeamList m_Teams = { Team{TeamColor::Red}, Team{TeamColor::Blue} };
|
||||
GameState m_GameState = GameState::Lobby;
|
||||
PlayerList m_Players;
|
||||
World* m_World;
|
||||
TeamList m_Teams = { Team{TeamColor::Red}, Team{TeamColor::Blue} };
|
||||
GameState m_GameState = GameState::Lobby;
|
||||
PlayerList m_Players;
|
||||
public:
|
||||
Game(World* world);
|
||||
virtual ~Game();
|
||||
Game(World* world);
|
||||
virtual ~Game();
|
||||
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
|
||||
Team& GetRedTeam() { return m_Teams[static_cast<std::uint8_t>(TeamColor::Red)]; }
|
||||
const Team& GetRedTeam() const { return m_Teams[static_cast<std::uint8_t>(TeamColor::Red)]; }
|
||||
Team& GetRedTeam() { return m_Teams[static_cast<std::uint8_t>(TeamColor::Red)]; }
|
||||
const Team& GetRedTeam() const { return m_Teams[static_cast<std::uint8_t>(TeamColor::Red)]; }
|
||||
|
||||
Team& GetBlueTeam() { return m_Teams[static_cast<std::uint8_t>(TeamColor::Blue)]; }
|
||||
const Team& GetBlueTeam() const { return m_Teams[static_cast<std::uint8_t>(TeamColor::Red)]; }
|
||||
Team& GetBlueTeam() { return m_Teams[static_cast<std::uint8_t>(TeamColor::Blue)]; }
|
||||
const Team& GetBlueTeam() const { return m_Teams[static_cast<std::uint8_t>(TeamColor::Red)]; }
|
||||
|
||||
Team& GetTeam(TeamColor team) { return m_Teams[static_cast<std::uint8_t>(team)]; }
|
||||
const Team& GetTeam(TeamColor team) const { return m_Teams[static_cast<std::uint8_t>(team)]; }
|
||||
Team& GetTeam(TeamColor team) { return m_Teams[static_cast<std::uint8_t>(team)]; }
|
||||
const Team& GetTeam(TeamColor team) const { return m_Teams[static_cast<std::uint8_t>(team)]; }
|
||||
|
||||
GameState GetGameState() const { return m_GameState; }
|
||||
void SetGameState(GameState gameState) { m_GameState = gameState; };
|
||||
GameState GetGameState() const { return m_GameState; }
|
||||
void SetGameState(GameState gameState) { m_GameState = gameState; };
|
||||
|
||||
const World* GetWorld() const { return m_World; }
|
||||
World* GetWorld() { return m_World; }
|
||||
const World* GetWorld() const { return m_World; }
|
||||
World* GetWorld() { return m_World; }
|
||||
|
||||
const PlayerList& GetPlayers() const { return m_Players; }
|
||||
PlayerList& GetPlayers() { return m_Players; }
|
||||
const PlayerList& GetPlayers() const { return m_Players; }
|
||||
PlayerList& GetPlayers() { return m_Players; }
|
||||
|
||||
const Player* GetPlayerById(PlayerID id) const;
|
||||
Player* GetPlayerById(PlayerID id);
|
||||
const Player* GetPlayerById(PlayerID id) const;
|
||||
Player* GetPlayerById(PlayerID id);
|
||||
|
||||
const TeamList& GetTeams() const { return m_Teams; }
|
||||
const TeamList& GetTeams() const { return m_Teams; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,26 +10,26 @@ namespace protocol {
|
||||
|
||||
class Connexion : public protocol::PacketHandler {
|
||||
protected:
|
||||
protocol::PacketDispatcher m_Dispatcher;
|
||||
protocol::PacketDispatcher m_Dispatcher;
|
||||
private:
|
||||
network::TCPSocket m_Socket;
|
||||
network::TCPSocket m_Socket;
|
||||
public:
|
||||
Connexion();
|
||||
Connexion(Connexion&& move);
|
||||
Connexion(protocol::PacketDispatcher* dispatcher);
|
||||
Connexion(protocol::PacketDispatcher* dispatcher, network::TCPSocket& socket);
|
||||
virtual ~Connexion();
|
||||
Connexion();
|
||||
Connexion(Connexion&& move);
|
||||
Connexion(protocol::PacketDispatcher* dispatcher);
|
||||
Connexion(protocol::PacketDispatcher* dispatcher, network::TCPSocket& socket);
|
||||
virtual ~Connexion();
|
||||
|
||||
virtual bool UpdateSocket();
|
||||
void CloseConnection();
|
||||
virtual bool UpdateSocket();
|
||||
void CloseConnection();
|
||||
|
||||
bool Connect(const std::string& address, std::uint16_t port);
|
||||
bool Connect(const std::string& address, std::uint16_t port);
|
||||
|
||||
network::Socket::Status GetSocketStatus() const { return m_Socket.GetStatus(); }
|
||||
network::Socket::Status GetSocketStatus() const { return m_Socket.GetStatus(); }
|
||||
|
||||
void SendPacket(const protocol::Packet* packet);
|
||||
void SendPacket(const protocol::Packet* packet);
|
||||
|
||||
REMOVE_COPY(Connexion);
|
||||
REMOVE_COPY(Connexion);
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
@@ -16,26 +16,26 @@ namespace game {
|
||||
struct WalkableTile;
|
||||
|
||||
enum class EffectType : std::uint8_t {
|
||||
Slowness = 0,
|
||||
Stun,
|
||||
Fire,
|
||||
Poison,
|
||||
Heal,
|
||||
Slowness = 0,
|
||||
Stun,
|
||||
Fire,
|
||||
Poison,
|
||||
Heal,
|
||||
};
|
||||
|
||||
enum class MobType : std::uint8_t {
|
||||
Zombie = 0,
|
||||
Spider,
|
||||
Skeleton,
|
||||
Pigman,
|
||||
Creeper,
|
||||
Silverfish,
|
||||
Blaze,
|
||||
Witch,
|
||||
Slime,
|
||||
Giant,
|
||||
Zombie = 0,
|
||||
Spider,
|
||||
Skeleton,
|
||||
Pigman,
|
||||
Creeper,
|
||||
Silverfish,
|
||||
Blaze,
|
||||
Witch,
|
||||
Slime,
|
||||
Giant,
|
||||
|
||||
MOB_COUNT
|
||||
MOB_COUNT
|
||||
};
|
||||
|
||||
typedef std::uint32_t MobID;
|
||||
@@ -45,34 +45,34 @@ typedef std::vector<EffectType> EffectImmunities;
|
||||
|
||||
class MobStats {
|
||||
private:
|
||||
float m_Damage;
|
||||
float m_Speed;
|
||||
Vec2f m_Size;
|
||||
std::uint16_t m_MoneyCost;
|
||||
std::uint16_t m_ExpCost;
|
||||
std::uint16_t m_MaxLife;
|
||||
std::uint16_t m_ExpReward;
|
||||
float m_Damage;
|
||||
float m_Speed;
|
||||
Vec2f m_Size;
|
||||
std::uint16_t m_MoneyCost;
|
||||
std::uint16_t m_ExpCost;
|
||||
std::uint16_t m_MaxLife;
|
||||
std::uint16_t m_ExpReward;
|
||||
public:
|
||||
MobStats(float damage, float speed, Vec2f size, std::uint16_t moneyCost,
|
||||
std::uint16_t expCost, std::uint16_t expReward,
|
||||
std::uint16_t maxLife) : m_Damage(damage), m_Speed(speed),
|
||||
m_Size(size), m_MoneyCost(moneyCost), m_ExpCost(expCost),
|
||||
m_MaxLife(maxLife), m_ExpReward(expReward) {
|
||||
}
|
||||
MobStats(float damage, float speed, Vec2f size, std::uint16_t moneyCost,
|
||||
std::uint16_t expCost, std::uint16_t expReward,
|
||||
std::uint16_t maxLife) : m_Damage(damage), m_Speed(speed),
|
||||
m_Size(size), m_MoneyCost(moneyCost), m_ExpCost(expCost),
|
||||
m_MaxLife(maxLife), m_ExpReward(expReward) {
|
||||
}
|
||||
|
||||
float GetDamage() const { return m_Damage; }
|
||||
float GetMovementSpeed() const { return m_Speed; }
|
||||
const Vec2f& GetSize() const { return m_Size; }
|
||||
std::uint16_t GetMoneyCost() const { return m_MoneyCost; }
|
||||
std::uint16_t GetExpCost() const { return m_ExpCost; }
|
||||
std::uint16_t GetExpReward() const { return m_ExpReward; }
|
||||
std::uint16_t GetMaxLife() const { return m_MaxLife; }
|
||||
float GetDamage() const { return m_Damage; }
|
||||
float GetMovementSpeed() const { return m_Speed; }
|
||||
const Vec2f& GetSize() const { return m_Size; }
|
||||
std::uint16_t GetMoneyCost() const { return m_MoneyCost; }
|
||||
std::uint16_t GetExpCost() const { return m_ExpCost; }
|
||||
std::uint16_t GetExpReward() const { return m_ExpReward; }
|
||||
std::uint16_t GetMaxLife() const { return m_MaxLife; }
|
||||
};
|
||||
|
||||
struct EffectDuration {
|
||||
EffectType type;
|
||||
float duration; // in seconds
|
||||
Tower* tower; // the tower that gived the effect
|
||||
EffectType type;
|
||||
float duration; // in seconds
|
||||
Tower* tower; // the tower that gived the effect
|
||||
};
|
||||
|
||||
const MobStats* GetMobStats(MobType type, std::uint8_t level);
|
||||
@@ -81,149 +81,149 @@ const EffectImmunities& GetMobEffectImmunities(MobType type, std::uint8_t level)
|
||||
|
||||
class Mob : public utils::shape::Rectangle {
|
||||
protected:
|
||||
float m_Health;
|
||||
float m_Health;
|
||||
private:
|
||||
MobID m_ID;
|
||||
PlayerID m_Sender;
|
||||
MobLevel m_Level;
|
||||
Direction m_Direction;
|
||||
std::vector<EffectDuration> m_Effects;
|
||||
const Tower* m_LastDamage; // the last tower that damaged the mob
|
||||
MobID m_ID;
|
||||
PlayerID m_Sender;
|
||||
MobLevel m_Level;
|
||||
Direction m_Direction;
|
||||
std::vector<EffectDuration> m_Effects;
|
||||
const Tower* m_LastDamage; // the last tower that damaged the mob
|
||||
|
||||
utils::Timer m_EffectFireTimer;
|
||||
utils::Timer m_EffectPoisonTimer;
|
||||
utils::Timer m_EffectHealTimer;
|
||||
utils::Timer m_EffectFireTimer;
|
||||
utils::Timer m_EffectPoisonTimer;
|
||||
utils::Timer m_EffectHealTimer;
|
||||
|
||||
TeamCastle* m_CastleTarget;
|
||||
utils::CooldownTimer m_AttackTimer;
|
||||
TeamCastle* m_CastleTarget;
|
||||
utils::CooldownTimer m_AttackTimer;
|
||||
|
||||
public:
|
||||
Mob(MobID id, MobLevel level, PlayerID sender) : m_Sender(sender), m_Level(level),
|
||||
m_EffectFireTimer(1000), m_EffectPoisonTimer(1000),
|
||||
m_EffectHealTimer(1000), m_CastleTarget(nullptr), m_AttackTimer(1000) {
|
||||
Mob(MobID id, MobLevel level, PlayerID sender) : m_Sender(sender), m_Level(level),
|
||||
m_EffectFireTimer(1000), m_EffectPoisonTimer(1000),
|
||||
m_EffectHealTimer(1000), m_CastleTarget(nullptr), m_AttackTimer(1000) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
virtual MobType GetType() const = 0;
|
||||
virtual MobType GetType() const = 0;
|
||||
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
|
||||
virtual bool OnDeath(World* world) { return true; }
|
||||
virtual bool OnDeath(World* world) { return true; }
|
||||
|
||||
MobID GetMobID() const { return m_ID; }
|
||||
const TowerImmunities& GetTowerImmunities() const { return GetMobTowerImmunities(GetType(), m_Level); }
|
||||
const EffectImmunities& GetEffectImmunities() const { return GetMobEffectImmunities(GetType(), m_Level); }
|
||||
PlayerID GetSender() const { return m_Sender; }
|
||||
MobLevel GetLevel() const { return m_Level; }
|
||||
const MobStats* GetStats() const { return GetMobStats(GetType(), m_Level); }
|
||||
void SetHealth(float newHealth) { m_Health = newHealth; }
|
||||
float GetHealth() const { return m_Health; }
|
||||
bool IsDead() const { return m_Health <= 0; }
|
||||
bool IsAlive() const { return m_Health > 0; }
|
||||
const Tower* GetLastDamageTower() { return m_LastDamage; }
|
||||
bool HasReachedEnemyCastle() { return m_CastleTarget != nullptr; }
|
||||
MobID GetMobID() const { return m_ID; }
|
||||
const TowerImmunities& GetTowerImmunities() const { return GetMobTowerImmunities(GetType(), m_Level); }
|
||||
const EffectImmunities& GetEffectImmunities() const { return GetMobEffectImmunities(GetType(), m_Level); }
|
||||
PlayerID GetSender() const { return m_Sender; }
|
||||
MobLevel GetLevel() const { return m_Level; }
|
||||
const MobStats* GetStats() const { return GetMobStats(GetType(), m_Level); }
|
||||
void SetHealth(float newHealth) { m_Health = newHealth; }
|
||||
float GetHealth() const { return m_Health; }
|
||||
bool IsDead() const { return m_Health <= 0; }
|
||||
bool IsAlive() const { return m_Health > 0; }
|
||||
const Tower* GetLastDamageTower() { return m_LastDamage; }
|
||||
bool HasReachedEnemyCastle() { return m_CastleTarget != nullptr; }
|
||||
|
||||
void Damage(float dmg, const Tower* damager) { m_Health = std::max(0.0f, m_Health - dmg); m_LastDamage = damager; }
|
||||
void Heal(float heal) { m_Health = std::min(static_cast<float>(GetStats()->GetMaxLife()), m_Health + heal); }
|
||||
void SetMobReachedCastle(TeamCastle* castle) { m_CastleTarget = castle; } // used when mob is in front of the castle
|
||||
void Damage(float dmg, const Tower* damager) { m_Health = std::max(0.0f, m_Health - dmg); m_LastDamage = damager; }
|
||||
void Heal(float heal) { m_Health = std::min(static_cast<float>(GetStats()->GetMaxLife()), m_Health + heal); }
|
||||
void SetMobReachedCastle(TeamCastle* castle) { m_CastleTarget = castle; } // used when mob is in front of the castle
|
||||
|
||||
bool IsImmuneTo(TowerType type);
|
||||
bool IsImmuneTo(TowerType type);
|
||||
|
||||
bool IsImmuneTo(EffectType type);
|
||||
void AddEffect(EffectType type, float durationSec, Tower* tower);
|
||||
bool HasEffect(EffectType type);
|
||||
bool IsImmuneTo(EffectType type);
|
||||
void AddEffect(EffectType type, float durationSec, Tower* tower);
|
||||
bool HasEffect(EffectType type);
|
||||
|
||||
float GetTileX() { return GetCenterX() - static_cast<float>(static_cast<std::int32_t>(GetCenterX())); } // returns a float between 0 and 1 excluded
|
||||
float GetTileY() { return GetCenterY() - static_cast<float>(static_cast<std::int32_t>(GetCenterY())); } // returns a float between 0 and 1 excluded
|
||||
float GetTileX() { return GetCenterX() - static_cast<float>(static_cast<std::int32_t>(GetCenterX())); } // returns a float between 0 and 1 excluded
|
||||
float GetTileY() { return GetCenterY() - static_cast<float>(static_cast<std::int32_t>(GetCenterY())); } // returns a float between 0 and 1 excluded
|
||||
|
||||
Direction GetDirection() const { return m_Direction; }
|
||||
void SetDirection(Direction dir) { m_Direction = dir; }
|
||||
Direction GetDirection() const { return m_Direction; }
|
||||
void SetDirection(Direction dir) { m_Direction = dir; }
|
||||
protected:
|
||||
void InitMob() {
|
||||
m_Health = static_cast<float>(GetStats()->GetMaxLife());
|
||||
SetSize(GetStats()->GetSize().x, GetStats()->GetSize().y);
|
||||
}
|
||||
void InitMob() {
|
||||
m_Health = static_cast<float>(GetStats()->GetMaxLife());
|
||||
SetSize(GetStats()->GetSize().x, GetStats()->GetSize().y);
|
||||
}
|
||||
private:
|
||||
void UpdateEffects(std::uint64_t delta, World* world);
|
||||
void AttackCastle(std::uint64_t delta, World* world);
|
||||
void Move(std::uint64_t delta, World* world);
|
||||
void Walk(std::uint64_t delta, World* world);
|
||||
void MoveBack(const TeamCastle& castle, World* world);
|
||||
void ChangeDirection(const WalkableTile& tile, World* world);
|
||||
bool IsTouchingCastle(const TeamCastle& castle) const;
|
||||
EffectDuration& GetEffect(EffectType type);
|
||||
void UpdateEffects(std::uint64_t delta, World* world);
|
||||
void AttackCastle(std::uint64_t delta, World* world);
|
||||
void Move(std::uint64_t delta, World* world);
|
||||
void Walk(std::uint64_t delta, World* world);
|
||||
void MoveBack(const TeamCastle& castle, World* world);
|
||||
void ChangeDirection(const WalkableTile& tile, World* world);
|
||||
bool IsTouchingCastle(const TeamCastle& castle) const;
|
||||
EffectDuration& GetEffect(EffectType type);
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Mob> MobPtr;
|
||||
|
||||
class Zombie : public Mob {
|
||||
public:
|
||||
Zombie(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Zombie(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Zombie; }
|
||||
virtual MobType GetType() const { return MobType::Zombie; }
|
||||
};
|
||||
|
||||
class Spider : public Mob {
|
||||
public:
|
||||
Spider(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Spider(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Spider; }
|
||||
virtual MobType GetType() const { return MobType::Spider; }
|
||||
};
|
||||
|
||||
class Skeleton : public Mob {
|
||||
public:
|
||||
Skeleton(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Skeleton(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Skeleton; }
|
||||
virtual MobType GetType() const { return MobType::Skeleton; }
|
||||
};
|
||||
|
||||
class PigMan : public Mob {
|
||||
public:
|
||||
PigMan(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
PigMan(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Pigman; }
|
||||
virtual MobType GetType() const { return MobType::Pigman; }
|
||||
};
|
||||
|
||||
class Creeper : public Mob {
|
||||
public:
|
||||
Creeper(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Creeper(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Creeper; }
|
||||
virtual MobType GetType() const { return MobType::Creeper; }
|
||||
};
|
||||
|
||||
class Silverfish : public Mob {
|
||||
public:
|
||||
Silverfish(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Silverfish(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Silverfish; }
|
||||
virtual MobType GetType() const { return MobType::Silverfish; }
|
||||
};
|
||||
|
||||
class Blaze : public Mob {
|
||||
public:
|
||||
Blaze(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Blaze(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Blaze; }
|
||||
virtual MobType GetType() const { return MobType::Blaze; }
|
||||
};
|
||||
|
||||
class Witch : public Mob {
|
||||
public:
|
||||
Witch(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Witch(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Witch; }
|
||||
virtual MobType GetType() const { return MobType::Witch; }
|
||||
};
|
||||
|
||||
class Slime : public Mob {
|
||||
public:
|
||||
Slime(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Slime(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Slime; }
|
||||
virtual MobType GetType() const { return MobType::Slime; }
|
||||
};
|
||||
|
||||
class Giant : public Mob {
|
||||
public:
|
||||
Giant(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
Giant(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType GetType() const { return MobType::Giant; }
|
||||
virtual MobType GetType() const { return MobType::Giant; }
|
||||
};
|
||||
|
||||
namespace MobFactory {
|
||||
@@ -235,13 +235,13 @@ std::string GetMobName(MobType type);
|
||||
|
||||
class MobListener {
|
||||
public:
|
||||
virtual void OnMobSpawn(Mob* mob) {}
|
||||
virtual void OnMobDie(Mob* mob) {}
|
||||
virtual void OnMobSpawn(Mob* mob) {}
|
||||
virtual void OnMobDie(Mob* mob) {}
|
||||
|
||||
virtual void OnMobDamage(Mob* target, float damage, Tower* damager) {}
|
||||
virtual void OnMobDamage(Mob* target, float damage, Tower* damager) {}
|
||||
|
||||
virtual void OnMobTouchCastle(Mob* damager, TeamCastle* enemyCastle) {}
|
||||
virtual void OnMobCastleDamage(Mob* damager, TeamCastle* enemyCastle, float damage) {}
|
||||
virtual void OnMobTouchCastle(Mob* damager, TeamCastle* enemyCastle) {}
|
||||
virtual void OnMobCastleDamage(Mob* damager, TeamCastle* enemyCastle, float damage) {}
|
||||
};
|
||||
|
||||
typedef utils::ObjectNotifier<MobListener> MobNotifier;
|
||||
|
||||
@@ -10,41 +10,41 @@ namespace game {
|
||||
|
||||
class Player {
|
||||
private:
|
||||
TeamColor m_TeamColor;
|
||||
TeamColor m_TeamColor;
|
||||
PlayerUpgrades m_Upgrades;
|
||||
|
||||
std::uint32_t m_Gold;
|
||||
std::uint32_t m_Exp;
|
||||
std::string m_Name;
|
||||
PlayerID m_ID;
|
||||
std::uint32_t m_Gold;
|
||||
std::uint32_t m_Exp;
|
||||
std::string m_Name;
|
||||
PlayerID m_ID;
|
||||
|
||||
public:
|
||||
|
||||
Player(std::uint8_t id = 0) : m_TeamColor(TeamColor::None), m_Gold(0), m_Exp(0), m_ID(id) {}
|
||||
Player(std::uint8_t id = 0) : m_TeamColor(TeamColor::None), m_Gold(0), m_Exp(0), m_ID(id) {}
|
||||
|
||||
const std::string& GetName() const { return m_Name; }
|
||||
void SetName(const std::string& name) { m_Name = name; }
|
||||
const std::string& GetName() const { return m_Name; }
|
||||
void SetName(const std::string& name) { m_Name = name; }
|
||||
|
||||
TeamColor GetTeamColor() const { return m_TeamColor; }
|
||||
void SetTeamColor(TeamColor teamColor) { m_TeamColor = teamColor; }
|
||||
TeamColor GetTeamColor() const { return m_TeamColor; }
|
||||
void SetTeamColor(TeamColor teamColor) { m_TeamColor = teamColor; }
|
||||
|
||||
std::uint32_t GetGold() const { return m_Gold; }
|
||||
void SetGold(std::uint32_t gold) { m_Gold = gold; }
|
||||
void AddGold(std::uint32_t gold) { m_Gold += gold; }
|
||||
void RemoveGold(std::uint32_t gold) { m_Gold -= gold; }
|
||||
std::uint32_t GetGold() const { return m_Gold; }
|
||||
void SetGold(std::uint32_t gold) { m_Gold = gold; }
|
||||
void AddGold(std::uint32_t gold) { m_Gold += gold; }
|
||||
void RemoveGold(std::uint32_t gold) { m_Gold -= gold; }
|
||||
|
||||
std::uint32_t GetExp() const { return m_Exp; }
|
||||
void SetExp(std::uint32_t exp) { m_Exp = exp; }
|
||||
void AddExp(std::uint32_t exp) { m_Exp += exp; }
|
||||
void RemoveExp(std::uint32_t exp) { m_Exp -= exp; }
|
||||
std::uint32_t GetExp() const { return m_Exp; }
|
||||
void SetExp(std::uint32_t exp) { m_Exp = exp; }
|
||||
void AddExp(std::uint32_t exp) { m_Exp += exp; }
|
||||
void RemoveExp(std::uint32_t exp) { m_Exp -= exp; }
|
||||
|
||||
const PlayerUpgrades& getUpgrades() const { return m_Upgrades; }
|
||||
PlayerUpgrades& getUpgrades() { return m_Upgrades; }
|
||||
|
||||
bool HasEnoughGold(std::uint32_t gold) const { return m_Gold >= gold; }
|
||||
bool HasEnoughExp(std::uint32_t exp) const { return m_Exp >= exp; }
|
||||
bool HasEnoughGold(std::uint32_t gold) const { return m_Gold >= gold; }
|
||||
bool HasEnoughExp(std::uint32_t exp) const { return m_Exp >= exp; }
|
||||
|
||||
PlayerID GetID() const { return m_ID; }
|
||||
PlayerID GetID() const { return m_ID; }
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -7,27 +7,27 @@ namespace game {
|
||||
|
||||
class PlayerUpgrades {
|
||||
private:
|
||||
std::uint8_t m_ClickerLevel;
|
||||
std::uint8_t m_ClickerLevel;
|
||||
std::uint8_t m_GoldPerSecond;
|
||||
std::array<std::uint8_t, static_cast<std::size_t>(MobType::MOB_COUNT)> m_MobsUpgradeLevel;
|
||||
std::array<std::uint8_t, static_cast<std::size_t>(MobType::MOB_COUNT)> m_MobsUpgradeLevel;
|
||||
public:
|
||||
static const int MAX_MOB_LEVEL = 5;
|
||||
static const int MAX_CLICKER_LEVEL = 3;
|
||||
static const int MAX_MOB_LEVEL = 5;
|
||||
static const int MAX_CLICKER_LEVEL = 3;
|
||||
|
||||
PlayerUpgrades() : m_ClickerLevel(1), m_GoldPerSecond(5) {}
|
||||
PlayerUpgrades() : m_ClickerLevel(1), m_GoldPerSecond(5) {}
|
||||
|
||||
std::uint8_t GetClickerLevel() const { return m_ClickerLevel; }
|
||||
std::uint8_t GetMobUpgradeLevel(MobType mob) const { return m_MobsUpgradeLevel.at(static_cast<std::size_t>(mob)); }
|
||||
std::uint8_t GetGoldPerSecond() const { return m_GoldPerSecond; }
|
||||
std::uint8_t GetClickerLevel() const { return m_ClickerLevel; }
|
||||
std::uint8_t GetMobUpgradeLevel(MobType mob) const { return m_MobsUpgradeLevel.at(static_cast<std::size_t>(mob)); }
|
||||
std::uint8_t GetGoldPerSecond() const { return m_GoldPerSecond; }
|
||||
|
||||
|
||||
void UpgradeMob(MobType mob) {
|
||||
void UpgradeMob(MobType mob) {
|
||||
std::uint8_t& mobLevel = m_MobsUpgradeLevel.at(static_cast<std::size_t>(mob));
|
||||
mobLevel = std::min(mobLevel + 1, MAX_MOB_LEVEL);
|
||||
mobLevel = std::min(mobLevel + 1, MAX_MOB_LEVEL);
|
||||
}
|
||||
|
||||
void UpgradeClicker() { m_ClickerLevel = std::min(m_ClickerLevel + 1, MAX_CLICKER_LEVEL); }
|
||||
void SetGoldPerSecond(std::uint8_t goldPerSecond) { m_GoldPerSecond = goldPerSecond; }
|
||||
void SetGoldPerSecond(std::uint8_t goldPerSecond) { m_GoldPerSecond = goldPerSecond; }
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -14,76 +14,76 @@ namespace game {
|
||||
class Player;
|
||||
|
||||
enum class TeamColor : std::int8_t {
|
||||
None = -1,
|
||||
Red,
|
||||
Blue
|
||||
None = -1,
|
||||
Red,
|
||||
Blue
|
||||
};
|
||||
|
||||
class Spawn : public utils::shape::Rectangle {
|
||||
private:
|
||||
Direction m_Direction;
|
||||
Direction m_Direction;
|
||||
public:
|
||||
Spawn() {
|
||||
SetWidth(5);
|
||||
SetHeight(5);
|
||||
}
|
||||
Spawn() {
|
||||
SetWidth(5);
|
||||
SetHeight(5);
|
||||
}
|
||||
|
||||
Direction GetDirection() const { return m_Direction; }
|
||||
Direction GetDirection() const { return m_Direction; }
|
||||
|
||||
void SetDirection(Direction direction) { m_Direction = direction; }
|
||||
void SetDirection(Direction direction) { m_Direction = direction; }
|
||||
};
|
||||
|
||||
class Team;
|
||||
|
||||
class TeamCastle : public utils::shape::Rectangle {
|
||||
private:
|
||||
const Team* m_Team;
|
||||
float m_Life;
|
||||
const Team* m_Team;
|
||||
float m_Life;
|
||||
public:
|
||||
static constexpr int CastleMaxLife = 1000;
|
||||
static constexpr int CastleMaxLife = 1000;
|
||||
|
||||
TeamCastle(const Team* team) : m_Team(team), m_Life(CastleMaxLife) {
|
||||
SetWidth(5);
|
||||
SetHeight(5);
|
||||
}
|
||||
TeamCastle(const Team* team) : m_Team(team), m_Life(CastleMaxLife) {
|
||||
SetWidth(5);
|
||||
SetHeight(5);
|
||||
}
|
||||
|
||||
TeamCastle() : TeamCastle(nullptr) {}
|
||||
TeamCastle() : TeamCastle(nullptr) {}
|
||||
|
||||
float GetLife() const { return m_Life; }
|
||||
float GetLife() const { return m_Life; }
|
||||
|
||||
const Team* GetTeam() const { return m_Team; }
|
||||
void SetTeam(const Team* team) { m_Team = team; }
|
||||
const Team* GetTeam() const { return m_Team; }
|
||||
void SetTeam(const Team* team) { m_Team = team; }
|
||||
|
||||
void SetLife(float life) { m_Life = life; }
|
||||
void Damage(float damage) { m_Life = std::max(0.0f, m_Life - damage); }
|
||||
void SetLife(float life) { m_Life = life; }
|
||||
void Damage(float damage) { m_Life = std::max(0.0f, m_Life - damage); }
|
||||
|
||||
void SetShape(utils::shape::Rectangle rect) {
|
||||
SetCenter(rect.GetCenter());
|
||||
SetSize(rect.GetSize());
|
||||
}
|
||||
void SetShape(utils::shape::Rectangle rect) {
|
||||
SetCenter(rect.GetCenter());
|
||||
SetSize(rect.GetSize());
|
||||
}
|
||||
};
|
||||
|
||||
class Team {
|
||||
private:
|
||||
std::vector<Player*> m_Players;
|
||||
TeamColor m_Color;
|
||||
Spawn m_Spawn;
|
||||
TeamCastle m_TeamCastle;
|
||||
std::vector<Player*> m_Players;
|
||||
TeamColor m_Color;
|
||||
Spawn m_Spawn;
|
||||
TeamCastle m_TeamCastle;
|
||||
public:
|
||||
Team(TeamColor color);
|
||||
Team(TeamColor color);
|
||||
|
||||
void AddPlayer(Player* newPlayer);
|
||||
void RemovePlayer(const Player* player);
|
||||
void AddPlayer(Player* newPlayer);
|
||||
void RemovePlayer(const Player* player);
|
||||
|
||||
TeamColor GetColor() const;
|
||||
TeamColor GetColor() const;
|
||||
|
||||
const Spawn& GetSpawn() const { return m_Spawn; }
|
||||
Spawn& GetSpawn() { return m_Spawn; }
|
||||
const Spawn& GetSpawn() const { return m_Spawn; }
|
||||
Spawn& GetSpawn() { return m_Spawn; }
|
||||
|
||||
const TeamCastle& GetCastle() const { return m_TeamCastle; }
|
||||
TeamCastle& GetCastle() { return m_TeamCastle; }
|
||||
const TeamCastle& GetCastle() const { return m_TeamCastle; }
|
||||
TeamCastle& GetCastle() { return m_TeamCastle; }
|
||||
|
||||
std::uint8_t GetPlayerCount() const;
|
||||
std::uint8_t GetPlayerCount() const;
|
||||
};
|
||||
|
||||
typedef std::array<Team, 2> TeamList;
|
||||
|
||||
@@ -17,69 +17,69 @@ class Mob;
|
||||
typedef std::shared_ptr<Mob> MobPtr;
|
||||
|
||||
enum class TowerType : std::uint8_t {
|
||||
Archer = 0,
|
||||
Ice,
|
||||
Sorcerer,
|
||||
Zeus,
|
||||
Mage,
|
||||
Artillery,
|
||||
Quake,
|
||||
Poison,
|
||||
Archer = 0,
|
||||
Ice,
|
||||
Sorcerer,
|
||||
Zeus,
|
||||
Mage,
|
||||
Artillery,
|
||||
Quake,
|
||||
Poison,
|
||||
|
||||
Leach,
|
||||
Turret,
|
||||
Necromancer,
|
||||
Leach,
|
||||
Turret,
|
||||
Necromancer,
|
||||
|
||||
TowerCount
|
||||
TowerCount
|
||||
};
|
||||
|
||||
enum class TowerSize : std::uint8_t {
|
||||
Little = 3, // 3x3
|
||||
Big = 5, // 5x5
|
||||
Little = 3, // 3x3
|
||||
Big = 5, // 5x5
|
||||
};
|
||||
|
||||
enum class TowerPath : std::uint8_t {
|
||||
Top = 0,
|
||||
Base, // Base Path
|
||||
Bottom
|
||||
Top = 0,
|
||||
Base, // Base Path
|
||||
Bottom
|
||||
};
|
||||
|
||||
class TowerStats {
|
||||
private:
|
||||
float m_Rate;
|
||||
float m_Damage;
|
||||
std::uint8_t m_Range;
|
||||
float m_Rate;
|
||||
float m_Damage;
|
||||
std::uint8_t m_Range;
|
||||
public:
|
||||
TowerStats(float rate, float damage, std::uint8_t range) : m_Rate(rate), m_Damage(damage),
|
||||
m_Range(range) {
|
||||
}
|
||||
TowerStats(float rate, float damage, std::uint8_t range) : m_Rate(rate), m_Damage(damage),
|
||||
m_Range(range) {
|
||||
}
|
||||
|
||||
float GetDamageRate() const { return m_Rate; }
|
||||
float GetDamage() const { return m_Damage; }
|
||||
std::uint8_t GetRange() const { return m_Range; }
|
||||
float GetDamageRate() const { return m_Rate; }
|
||||
float GetDamage() const { return m_Damage; }
|
||||
std::uint8_t GetRange() const { return m_Range; }
|
||||
};
|
||||
|
||||
class TowerLevel {
|
||||
private:
|
||||
// 1, 2, 3, 4
|
||||
std::uint8_t m_Level : 3;
|
||||
// 0 : base path 1 : top path (if there is bottom path) 2 : bottom path (if there is top path)
|
||||
TowerPath m_Path : 2;
|
||||
// 1, 2, 3, 4
|
||||
std::uint8_t m_Level : 3;
|
||||
// 0 : base path 1 : top path (if there is bottom path) 2 : bottom path (if there is top path)
|
||||
TowerPath m_Path : 2;
|
||||
public:
|
||||
TowerLevel() : m_Level(1), m_Path(TowerPath::Base) {}
|
||||
TowerLevel(std::uint8_t level, TowerPath path) : m_Level(level), m_Path(path) {}
|
||||
TowerLevel() : m_Level(1), m_Path(TowerPath::Base) {}
|
||||
TowerLevel(std::uint8_t level, TowerPath path) : m_Level(level), m_Path(path) {}
|
||||
|
||||
std::uint8_t GetLevel() const { return m_Level; }
|
||||
TowerPath GetPath() const { return m_Path; }
|
||||
std::uint8_t GetLevel() const { return m_Level; }
|
||||
TowerPath GetPath() const { return m_Path; }
|
||||
|
||||
void SetLevel(std::uint8_t level) { m_Level = level; }
|
||||
void SetPath(TowerPath path) { m_Path = path; }
|
||||
void SetLevel(std::uint8_t level) { m_Level = level; }
|
||||
void SetPath(TowerPath path) { m_Path = path; }
|
||||
|
||||
// operator to sort maps
|
||||
friend bool operator<(const TowerLevel& level, const TowerLevel& other) {
|
||||
return level.GetLevel() + static_cast<std::uint8_t>(level.GetPath()) * 4 <
|
||||
other.GetLevel() + static_cast<std::uint8_t>(other.GetPath()) * 4;
|
||||
}
|
||||
// operator to sort maps
|
||||
friend bool operator<(const TowerLevel& level, const TowerLevel& other) {
|
||||
return level.GetLevel() + static_cast<std::uint8_t>(level.GetPath()) * 4 <
|
||||
other.GetLevel() + static_cast<std::uint8_t>(other.GetPath()) * 4;
|
||||
}
|
||||
};
|
||||
|
||||
const TowerStats* GetTowerStats(TowerType type, TowerLevel level);
|
||||
@@ -88,36 +88,36 @@ typedef std::uint16_t TowerID;
|
||||
|
||||
class Tower : public utils::shape::Circle {
|
||||
private:
|
||||
TowerID m_ID;
|
||||
TowerType m_Type;
|
||||
TowerLevel m_Level{};
|
||||
PlayerID m_Builder;
|
||||
TowerID m_ID;
|
||||
TowerType m_Type;
|
||||
TowerLevel m_Level{};
|
||||
PlayerID m_Builder;
|
||||
protected:
|
||||
utils::CooldownTimer m_Timer;
|
||||
utils::CooldownTimer m_Timer;
|
||||
public:
|
||||
Tower(TowerID id, TowerType type, std::int32_t x, std::int32_t y, PlayerID builder) : utils::shape::Circle(x + 0.5f, y + 0.5f, 0), m_ID(id), m_Type(type), m_Builder(builder),
|
||||
m_Timer(GetStats()->GetDamageRate() * 1000) { // converting seconds to millis
|
||||
SetRadius(GetStats()->GetRange());
|
||||
}
|
||||
Tower(TowerID id, TowerType type, std::int32_t x, std::int32_t y, PlayerID builder) : utils::shape::Circle(x + 0.5f, y + 0.5f, 0), m_ID(id), m_Type(type), m_Builder(builder),
|
||||
m_Timer(GetStats()->GetDamageRate() * 1000) { // converting seconds to millis
|
||||
SetRadius(GetStats()->GetRange());
|
||||
}
|
||||
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual TowerSize GetSize() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual TowerSize GetSize() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
|
||||
void Upgrade(std::uint8_t level, TowerPath path) {
|
||||
m_Level.SetLevel(level);
|
||||
m_Level.SetPath(path);
|
||||
m_Timer.SetCooldown(GetStats()->GetDamageRate() * 1000); // converting seconds to millis
|
||||
m_Timer.Reset();
|
||||
SetRadius(GetStats()->GetRange());
|
||||
}
|
||||
void Upgrade(std::uint8_t level, TowerPath path) {
|
||||
m_Level.SetLevel(level);
|
||||
m_Level.SetPath(path);
|
||||
m_Timer.SetCooldown(GetStats()->GetDamageRate() * 1000); // converting seconds to millis
|
||||
m_Timer.Reset();
|
||||
SetRadius(GetStats()->GetRange());
|
||||
}
|
||||
|
||||
std::uint16_t GetID() const { return m_ID; }
|
||||
const TowerLevel& GetLevel() const { return m_Level; }
|
||||
const TowerStats* GetStats() const { return GetTowerStats(m_Type, m_Level); }
|
||||
PlayerID GetBuilder() const { return m_Builder; }
|
||||
std::uint16_t GetID() const { return m_ID; }
|
||||
const TowerLevel& GetLevel() const { return m_Level; }
|
||||
const TowerStats* GetStats() const { return GetTowerStats(m_Type, m_Level); }
|
||||
PlayerID GetBuilder() const { return m_Builder; }
|
||||
|
||||
bool IsMobInRange(MobPtr mob);
|
||||
bool IsMobInRange(MobPtr mob);
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Tower> TowerPtr;
|
||||
@@ -132,16 +132,17 @@ std::string GetTowerName(TowerType type);
|
||||
|
||||
class TowerInfo {
|
||||
private:
|
||||
std::string m_Name, m_Description;
|
||||
bool m_IsBigTower;
|
||||
std::string m_Name, m_Description;
|
||||
bool m_IsBigTower;
|
||||
public:
|
||||
TowerInfo(std::string&& name, std::string&& description, bool big) : m_Name(std::move(name)),
|
||||
m_Description(std::move(description)), m_IsBigTower(big) {}
|
||||
TowerInfo(std::string&& name, std::string&& description, bool big) : m_Name(std::move(name)),
|
||||
m_Description(std::move(description)), m_IsBigTower(big) {
|
||||
}
|
||||
|
||||
const std::string& GetName() const { return m_Name; }
|
||||
const std::string& GetDescription() const { return m_Description; }
|
||||
const std::string& GetName() const { return m_Name; }
|
||||
const std::string& GetDescription() const { return m_Description; }
|
||||
|
||||
bool IsBigTower() const { return m_IsBigTower; }
|
||||
bool IsBigTower() const { return m_IsBigTower; }
|
||||
};
|
||||
|
||||
const TowerInfo& GetTowerInfo(TowerType type);
|
||||
@@ -150,115 +151,115 @@ const TowerInfo& GetTowerInfo(TowerType type);
|
||||
|
||||
class LittleTower : public Tower {
|
||||
public:
|
||||
LittleTower(TowerID id, TowerType type, std::uint16_t x, std::uint16_t y, PlayerID builder) : Tower(id, type, x, y, builder) {}
|
||||
LittleTower(TowerID id, TowerType type, std::uint16_t x, std::uint16_t y, PlayerID builder) : Tower(id, type, x, y, builder) {}
|
||||
|
||||
virtual TowerSize GetSize() const { return TowerSize::Little; }
|
||||
virtual TowerSize GetSize() const { return TowerSize::Little; }
|
||||
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
};
|
||||
|
||||
class ArcherTower : public LittleTower {
|
||||
public:
|
||||
ArcherTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
ArcherTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
constexpr static float ExplosionRadius = 1.5f;
|
||||
constexpr static float FireDurationSec = 10.0f;
|
||||
constexpr static float ExplosionRadius = 1.5f;
|
||||
constexpr static float FireDurationSec = 10.0f;
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Archer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Archer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class IceTower : public LittleTower {
|
||||
public:
|
||||
IceTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
IceTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Ice; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Ice; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class MageTower : public LittleTower {
|
||||
public:
|
||||
MageTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
MageTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Mage; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Mage; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class PoisonTower : public LittleTower {
|
||||
public:
|
||||
PoisonTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
PoisonTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Poison; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Poison; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class QuakeTower : public LittleTower {
|
||||
public:
|
||||
QuakeTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
QuakeTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Quake; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Quake; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class ArtilleryTower : public LittleTower {
|
||||
public:
|
||||
ArtilleryTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
ArtilleryTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Artillery; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Artillery; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class SorcererTower : public LittleTower {
|
||||
public:
|
||||
SorcererTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
SorcererTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Sorcerer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Sorcerer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class ZeusTower : public LittleTower {
|
||||
public:
|
||||
ZeusTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
ZeusTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Zeus; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Zeus; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
// ---------- Big Towers ----------
|
||||
|
||||
class BigTower : public Tower {
|
||||
public:
|
||||
BigTower(TowerID id, TowerType type, std::uint16_t x, std::uint16_t y, PlayerID builder) : Tower(id, type, x, y, builder) {}
|
||||
BigTower(TowerID id, TowerType type, std::uint16_t x, std::uint16_t y, PlayerID builder) : Tower(id, type, x, y, builder) {}
|
||||
|
||||
virtual TowerSize GetSize() const { return TowerSize::Big; }
|
||||
virtual TowerSize GetSize() const { return TowerSize::Big; }
|
||||
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
};
|
||||
|
||||
class TurretTower : public BigTower {
|
||||
public:
|
||||
TurretTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
TurretTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Turret; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Turret; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class NecromancerTower : public BigTower {
|
||||
public:
|
||||
NecromancerTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
NecromancerTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Necromancer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Necromancer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class LeachTower : public BigTower {
|
||||
public:
|
||||
LeachTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
LeachTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType GetType() const { return TowerType::Leach; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Leach; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace td {
|
||||
namespace game {
|
||||
|
||||
enum class Direction : std::uint8_t {
|
||||
PositiveX = 1 << 0,
|
||||
NegativeX = 1 << 1,
|
||||
PositiveY = 1 << 2,
|
||||
NegativeY = 1 << 3,
|
||||
PositiveX = 1 << 0,
|
||||
NegativeX = 1 << 1,
|
||||
PositiveY = 1 << 2,
|
||||
NegativeY = 1 << 3,
|
||||
};
|
||||
|
||||
typedef std::uint8_t PlayerID;
|
||||
|
||||
@@ -13,11 +13,11 @@ namespace td {
|
||||
namespace game {
|
||||
|
||||
struct ChunkCoord {
|
||||
std::int16_t x, y;
|
||||
std::int16_t x, y;
|
||||
|
||||
friend bool operator==(const td::game::ChunkCoord& first, const td::game::ChunkCoord& other) {
|
||||
return first.x == other.x && first.y == other.y;
|
||||
}
|
||||
friend bool operator==(const td::game::ChunkCoord& first, const td::game::ChunkCoord& other) {
|
||||
return first.x == other.x && first.y == other.y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ struct ChunkCoord {
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<td::game::ChunkCoord> {
|
||||
std::size_t operator()(const td::game::ChunkCoord& key) const noexcept{
|
||||
return std::hash<std::int16_t>()(key.x << 16 | key.y);
|
||||
}
|
||||
std::size_t operator()(const td::game::ChunkCoord& key) const noexcept {
|
||||
return std::hash<std::int16_t>()(key.x << 16 | key.y);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -47,15 +47,15 @@ namespace game {
|
||||
class Game;
|
||||
|
||||
enum class TileType : std::uint8_t {
|
||||
None = 0,
|
||||
Tower,
|
||||
Walk,
|
||||
Decoration,
|
||||
/*Heal,
|
||||
Lava,
|
||||
Bedrock,
|
||||
Freeze,
|
||||
Ice,*/
|
||||
None = 0,
|
||||
Tower,
|
||||
Walk,
|
||||
Decoration,
|
||||
/*Heal,
|
||||
Lava,
|
||||
Bedrock,
|
||||
Freeze,
|
||||
Ice,*/
|
||||
};
|
||||
|
||||
static constexpr Color BLACK{ 0, 0, 0 };
|
||||
@@ -66,26 +66,26 @@ static constexpr Color GREEN{ 0, 255, 0 };
|
||||
static constexpr Color BLUE{ 0, 0, 255 };
|
||||
|
||||
struct Tile {
|
||||
virtual TileType GetType() const = 0;
|
||||
virtual TileType GetType() const = 0;
|
||||
};
|
||||
|
||||
struct TowerTile : Tile {
|
||||
std::uint8_t color_palette_ref;
|
||||
TeamColor team_owner;
|
||||
std::uint8_t color_palette_ref;
|
||||
TeamColor team_owner;
|
||||
|
||||
virtual TileType GetType() const { return TileType::Tower; }
|
||||
virtual TileType GetType() const { return TileType::Tower; }
|
||||
};
|
||||
|
||||
struct WalkableTile : Tile {
|
||||
Direction direction;
|
||||
Direction direction;
|
||||
|
||||
virtual TileType GetType() const { return TileType::Walk; }
|
||||
virtual TileType GetType() const { return TileType::Walk; }
|
||||
};
|
||||
|
||||
struct DecorationTile : Tile {
|
||||
std::uint16_t color_palette_ref;
|
||||
std::uint16_t color_palette_ref;
|
||||
|
||||
virtual TileType GetType() const { return TileType::Decoration; }
|
||||
virtual TileType GetType() const { return TileType::Decoration; }
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Tile> TilePtr;
|
||||
@@ -97,19 +97,19 @@ typedef std::uint32_t TileIndex;
|
||||
|
||||
//32 x 32 area
|
||||
struct Chunk {
|
||||
enum { ChunkWidth = 32, ChunkHeight = 32, ChunkSize = ChunkWidth * ChunkHeight };
|
||||
typedef std::array<std::uint16_t, ChunkSize> ChunkData;
|
||||
enum { ChunkWidth = 32, ChunkHeight = 32, ChunkSize = ChunkWidth * ChunkHeight };
|
||||
typedef std::array<std::uint16_t, ChunkSize> ChunkData;
|
||||
|
||||
// stores index of tile palette
|
||||
ChunkData tiles{ 0 };
|
||||
ChunkPalette palette;
|
||||
// stores index of tile palette
|
||||
ChunkData tiles{ 0 };
|
||||
ChunkPalette palette;
|
||||
|
||||
TileIndex GetTileIndex(std::uint16_t tileNumber) const {
|
||||
TileIndex chunkPaletteIndex = tiles.at(tileNumber);
|
||||
if (chunkPaletteIndex == 0) // index 0 means empty tile index 1 = first tile
|
||||
return 0;
|
||||
return palette.at(chunkPaletteIndex);
|
||||
}
|
||||
TileIndex GetTileIndex(std::uint16_t tileNumber) const {
|
||||
TileIndex chunkPaletteIndex = tiles.at(tileNumber);
|
||||
if (chunkPaletteIndex == 0) // index 0 means empty tile index 1 = first tile
|
||||
return 0;
|
||||
return palette.at(chunkPaletteIndex);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Chunk> ChunkPtr;
|
||||
@@ -126,119 +126,119 @@ typedef std::vector<TowerPtr> TowerList;
|
||||
|
||||
class WorldListener {
|
||||
public:
|
||||
WorldListener() {}
|
||||
WorldListener() {}
|
||||
|
||||
virtual void OnTowerAdd(TowerPtr tower) {}
|
||||
virtual void OnTowerRemove(TowerPtr tower) {}
|
||||
virtual void OnTowerAdd(TowerPtr tower) {}
|
||||
virtual void OnTowerRemove(TowerPtr tower) {}
|
||||
|
||||
virtual void OnArcherTowerShot(MobPtr target, ArcherTower* shooter) {}
|
||||
virtual void OnArcherTowerShot(MobPtr target, ArcherTower* shooter) {}
|
||||
|
||||
virtual void OnArrowShot(MobPtr target, bool fire, Tower* shooter) {}
|
||||
virtual void OnExplosion(utils::shape::Circle explosion, float centerDamage, Tower* shooter) {}
|
||||
virtual void OnArrowShot(MobPtr target, bool fire, Tower* shooter) {}
|
||||
virtual void OnExplosion(utils::shape::Circle explosion, float centerDamage, Tower* shooter) {}
|
||||
};
|
||||
|
||||
typedef utils::ObjectNotifier<WorldListener> WorldNotifier;
|
||||
|
||||
class World : public WorldListener, public MobListener {
|
||||
protected:
|
||||
TowerTileColorPalette m_TowerPlacePalette;
|
||||
Color m_WalkablePalette;
|
||||
std::vector<Color> m_DecorationPalette;
|
||||
Color m_Background;
|
||||
TowerTileColorPalette m_TowerPlacePalette;
|
||||
Color m_WalkablePalette;
|
||||
std::vector<Color> m_DecorationPalette;
|
||||
Color m_Background;
|
||||
|
||||
std::unordered_map<ChunkCoord, ChunkPtr> m_Chunks;
|
||||
std::unordered_map<ChunkCoord, ChunkPtr> m_Chunks;
|
||||
|
||||
SpawnColorPalette m_SpawnColorPalette;
|
||||
SpawnColorPalette m_SpawnColorPalette;
|
||||
|
||||
TilePalette m_TilePalette;
|
||||
TilePalette m_TilePalette;
|
||||
|
||||
MobList m_Mobs;
|
||||
MobList m_Mobs;
|
||||
|
||||
TowerList m_Towers;
|
||||
TowerList m_Towers;
|
||||
|
||||
Game* m_Game;
|
||||
Game* m_Game;
|
||||
|
||||
WorldNotifier m_WorldNotifier;
|
||||
MobNotifier m_MobNotifier;
|
||||
WorldNotifier m_WorldNotifier;
|
||||
MobNotifier m_MobNotifier;
|
||||
public:
|
||||
World(Game* game);
|
||||
World(Game* game);
|
||||
|
||||
bool LoadMap(const protocol::WorldBeginDataPacket* worldHeader);
|
||||
bool LoadMap(const protocol::WorldDataPacket* worldData);
|
||||
bool LoadMap(const protocol::WorldBeginDataPacket* worldHeader);
|
||||
bool LoadMap(const protocol::WorldDataPacket* worldData);
|
||||
|
||||
bool LoadMapFromFile(const std::string& fileName);
|
||||
bool SaveMap(const std::string& fileName) const;
|
||||
bool LoadMapFromFile(const std::string& fileName);
|
||||
bool SaveMap(const std::string& fileName) const;
|
||||
|
||||
void Tick(std::uint64_t delta);
|
||||
void Tick(std::uint64_t delta);
|
||||
|
||||
void SpawnMobAt(MobID id, MobType type, std::uint8_t level, PlayerID sender, float x, float y, Direction dir);
|
||||
void SpawnMobAt(MobID id, MobType type, std::uint8_t level, PlayerID sender, float x, float y, Direction dir);
|
||||
|
||||
TowerPtr PlaceTowerAt(TowerID id, TowerType type, std::int32_t x, std::int32_t y, PlayerID builder);
|
||||
TowerPtr RemoveTower(TowerID id);
|
||||
TowerPtr PlaceTowerAt(TowerID id, TowerType type, std::int32_t x, std::int32_t y, PlayerID builder);
|
||||
TowerPtr RemoveTower(TowerID id);
|
||||
|
||||
TilePtr GetTile(std::int32_t x, std::int32_t y) const;
|
||||
TilePtr GetTile(std::int32_t x, std::int32_t y) const;
|
||||
|
||||
const TowerTileColorPalette& GetTowerTileColorPalette() const { return m_TowerPlacePalette; }
|
||||
const Color& GetWalkableTileColor() const { return m_WalkablePalette; }
|
||||
const std::vector<Color>& GetDecorationPalette() const { return m_DecorationPalette; }
|
||||
const Color& GetBackgroundColor() const { return m_Background; }
|
||||
const TowerTileColorPalette& GetTowerTileColorPalette() const { return m_TowerPlacePalette; }
|
||||
const Color& GetWalkableTileColor() const { return m_WalkablePalette; }
|
||||
const std::vector<Color>& GetDecorationPalette() const { return m_DecorationPalette; }
|
||||
const Color& GetBackgroundColor() const { return m_Background; }
|
||||
|
||||
const TilePalette& GetTilePalette() const { return m_TilePalette; }
|
||||
const TilePalette& GetTilePalette() const { return m_TilePalette; }
|
||||
|
||||
TilePtr GetTilePtr(TileIndex index) const {
|
||||
if (index == 0)
|
||||
return nullptr;
|
||||
return m_TilePalette.at(index - 1);
|
||||
}
|
||||
TilePtr GetTilePtr(TileIndex index) const {
|
||||
if (index == 0)
|
||||
return nullptr;
|
||||
return m_TilePalette.at(index - 1);
|
||||
}
|
||||
|
||||
bool CanPlaceLittleTower(const Vec2f& worldPos, PlayerID player) const;
|
||||
bool CanPlaceBigTower(const Vec2f& worldPos, PlayerID player) const;
|
||||
bool CanPlaceLittleTower(const Vec2f& worldPos, PlayerID player) const;
|
||||
bool CanPlaceBigTower(const Vec2f& worldPos, PlayerID player) const;
|
||||
|
||||
TowerPtr GetTower(const Vec2f& position) const; // returns null if no tower is here
|
||||
TowerPtr GetTower(const Vec2f& position) const; // returns null if no tower is here
|
||||
|
||||
const std::unordered_map<ChunkCoord, ChunkPtr>& GetChunks() const { return m_Chunks; }
|
||||
const std::unordered_map<ChunkCoord, ChunkPtr>& GetChunks() const { return m_Chunks; }
|
||||
|
||||
const Color& GetSpawnColor(TeamColor color) const { return m_SpawnColorPalette[static_cast<std::size_t>(color)]; }
|
||||
const SpawnColorPalette& GetSpawnColors() const { return m_SpawnColorPalette; }
|
||||
const Color& GetSpawnColor(TeamColor color) const { return m_SpawnColorPalette[static_cast<std::size_t>(color)]; }
|
||||
const SpawnColorPalette& GetSpawnColors() const { return m_SpawnColorPalette; }
|
||||
|
||||
const MobList& GetMobList() const { return m_Mobs; }
|
||||
MobList& GetMobList() { return m_Mobs; }
|
||||
const MobList& GetMobList() const { return m_Mobs; }
|
||||
MobList& GetMobList() { return m_Mobs; }
|
||||
|
||||
const Color* GetTileColor(TilePtr tile) const;
|
||||
const Color* GetTileColor(TilePtr tile) const;
|
||||
|
||||
Team& GetRedTeam();
|
||||
const Team& GetRedTeam() const;
|
||||
Team& GetRedTeam();
|
||||
const Team& GetRedTeam() const;
|
||||
|
||||
Team& GetBlueTeam();
|
||||
const Team& GetBlueTeam() const;
|
||||
Team& GetBlueTeam();
|
||||
const Team& GetBlueTeam() const;
|
||||
|
||||
Team& GetTeam(TeamColor team);
|
||||
const Team& GetTeam(TeamColor team) const;
|
||||
Team& GetTeam(TeamColor team);
|
||||
const Team& GetTeam(TeamColor team) const;
|
||||
|
||||
const TeamList& GetTeams() const;
|
||||
const TeamList& GetTeams() const;
|
||||
|
||||
const TowerList& GetTowers() const { return m_Towers; }
|
||||
TowerPtr GetTowerById(TowerID tower);
|
||||
const TowerList& GetTowers() const { return m_Towers; }
|
||||
TowerPtr GetTowerById(TowerID tower);
|
||||
|
||||
const Player* GetPlayerById(PlayerID id) const;
|
||||
const Player* GetPlayerById(PlayerID id) const;
|
||||
|
||||
WorldNotifier& GetWorldNotifier() { return m_WorldNotifier; }
|
||||
MobNotifier& GetMobNotifier() { return m_MobNotifier; }
|
||||
WorldNotifier& GetWorldNotifier() { return m_WorldNotifier; }
|
||||
MobNotifier& GetMobNotifier() { return m_MobNotifier; }
|
||||
|
||||
// WorldListener
|
||||
// WorldListener
|
||||
|
||||
virtual void OnArcherTowerShot(MobPtr target, ArcherTower* shooter) override;
|
||||
virtual void OnArrowShot(MobPtr target, bool fire, Tower* shooter) override;
|
||||
virtual void OnExplosion(utils::shape::Circle explosion, float centerDamage, Tower* shooter) override;
|
||||
virtual void OnArcherTowerShot(MobPtr target, ArcherTower* shooter) override;
|
||||
virtual void OnArrowShot(MobPtr target, bool fire, Tower* shooter) override;
|
||||
virtual void OnExplosion(utils::shape::Circle explosion, float centerDamage, Tower* shooter) override;
|
||||
|
||||
// MobListener
|
||||
// MobListener
|
||||
|
||||
virtual void OnMobDamage(Mob* target, float damage, Tower* source) override;
|
||||
virtual void OnMobCastleDamage(Mob* damager, TeamCastle* enemyCastle, float damage) override;
|
||||
virtual void OnMobDamage(Mob* target, float damage, Tower* source) override;
|
||||
virtual void OnMobCastleDamage(Mob* damager, TeamCastle* enemyCastle, float damage) override;
|
||||
|
||||
private:
|
||||
void TickMobs(std::uint64_t delta);
|
||||
void CleanDeadMobs();
|
||||
void TickMobs(std::uint64_t delta);
|
||||
void CleanDeadMobs();
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -17,38 +17,38 @@ namespace client {
|
||||
|
||||
class Client {
|
||||
private:
|
||||
render::Renderer* m_Renderer;
|
||||
ClientConnexion m_Connexion;
|
||||
std::unique_ptr<ClientGame> m_Game;
|
||||
bool m_Connected;
|
||||
render::Renderer* m_Renderer;
|
||||
ClientConnexion m_Connexion;
|
||||
std::unique_ptr<ClientGame> m_Game;
|
||||
bool m_Connected;
|
||||
public:
|
||||
Client(render::Renderer* renderer) : m_Renderer(renderer), m_Game(std::make_unique<ClientGame>(this)), m_Connected(false) {}
|
||||
Client(render::Renderer* renderer) : m_Renderer(renderer), m_Game(std::make_unique<ClientGame>(this)), m_Connected(false) {}
|
||||
|
||||
const ClientGame& GetGame() const { return *m_Game; }
|
||||
const ClientConnexion& GetConnexion() const { return m_Connexion; }
|
||||
render::Renderer* GetRenderer() const { return m_Renderer; }
|
||||
const ClientGame& GetGame() const { return *m_Game; }
|
||||
const ClientConnexion& GetConnexion() const { return m_Connexion; }
|
||||
render::Renderer* GetRenderer() const { return m_Renderer; }
|
||||
|
||||
ClientGame& GetGame() { return *m_Game; }
|
||||
ClientConnexion& GetConnexion() { return m_Connexion; }
|
||||
ClientGame& GetGame() { return *m_Game; }
|
||||
ClientConnexion& GetConnexion() { return m_Connexion; }
|
||||
|
||||
const game::Player* GetPlayer() { return m_Game->GetPlayer(); }
|
||||
const game::Player* GetPlayer() { return m_Game->GetPlayer(); }
|
||||
|
||||
void Tick(std::uint64_t delta);
|
||||
void Tick(std::uint64_t delta);
|
||||
|
||||
void Render();
|
||||
void Render();
|
||||
|
||||
bool Connect(const network::IPAddresses& addresses, std::uint16_t port);
|
||||
void CloseConnection();
|
||||
bool Connect(const network::IPAddresses& addresses, std::uint16_t port);
|
||||
void CloseConnection();
|
||||
|
||||
bool IsConnected() const { return m_Connexion.GetSocketStatus() == network::Socket::Connected; }
|
||||
bool IsConnected() const { return m_Connexion.GetSocketStatus() == network::Socket::Connected; }
|
||||
|
||||
void SelectTeam(game::TeamColor team);
|
||||
void SendMobs(const std::vector<protocol::MobSend>& mobSends);
|
||||
void PlaceTower(game::TowerType type, const Vec2f& position);
|
||||
void UpgradeTower(game::TowerID tower, game::TowerLevel level);
|
||||
void RemoveTower(game::TowerID tower);
|
||||
void SelectTeam(game::TeamColor team);
|
||||
void SendMobs(const std::vector<protocol::MobSend>& mobSends);
|
||||
void PlaceTower(game::TowerType type, const Vec2f& position);
|
||||
void UpgradeTower(game::TowerID tower, game::TowerLevel level);
|
||||
void RemoveTower(game::TowerID tower);
|
||||
private:
|
||||
void Reset();
|
||||
void Reset();
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
@@ -9,28 +9,28 @@ namespace client {
|
||||
|
||||
class ClientConnexion : public protocol::Connexion {
|
||||
private:
|
||||
std::uint8_t m_ConnectionID;
|
||||
std::string m_DisconnectReason;
|
||||
float m_ServerTPS;
|
||||
int m_Ping = 0;
|
||||
std::uint8_t m_ConnectionID;
|
||||
std::string m_DisconnectReason;
|
||||
float m_ServerTPS;
|
||||
int m_Ping = 0;
|
||||
public:
|
||||
ClientConnexion();
|
||||
ClientConnexion();
|
||||
|
||||
virtual bool UpdateSocket();
|
||||
virtual bool UpdateSocket();
|
||||
|
||||
virtual void HandlePacket(const protocol::KeepAlivePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::ConnexionInfoPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::DisconnectPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::ServerTpsPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::KeepAlivePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::ConnexionInfoPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::DisconnectPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::ServerTpsPacket* packet) override;
|
||||
|
||||
const std::string& GetDisconnectReason() const { return m_DisconnectReason; }
|
||||
float GetServerTPS() const { return m_ServerTPS; }
|
||||
int GetServerPing() const { return m_Ping; }
|
||||
const std::string& GetDisconnectReason() const { return m_DisconnectReason; }
|
||||
float GetServerTPS() const { return m_ServerTPS; }
|
||||
int GetServerPing() const { return m_Ping; }
|
||||
|
||||
REMOVE_COPY(ClientConnexion);
|
||||
REMOVE_COPY(ClientConnexion);
|
||||
private:
|
||||
void RegisterHandlers();
|
||||
void Login();
|
||||
void RegisterHandlers();
|
||||
void Login();
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
@@ -16,40 +16,40 @@ class Client;
|
||||
|
||||
class ClientGame : public protocol::PacketHandler, public game::Game {
|
||||
private:
|
||||
Client* m_Client;
|
||||
std::uint8_t m_ConnexionID;
|
||||
std::uint32_t m_LobbyTime = 0;
|
||||
game::Player* m_Player = nullptr;
|
||||
render::Renderer* m_Renderer;
|
||||
client::WorldClient m_WorldClient;
|
||||
render::WorldRenderer m_WorldRenderer;
|
||||
Client* m_Client;
|
||||
std::uint8_t m_ConnexionID;
|
||||
std::uint32_t m_LobbyTime = 0;
|
||||
game::Player* m_Player = nullptr;
|
||||
render::Renderer* m_Renderer;
|
||||
client::WorldClient m_WorldClient;
|
||||
render::WorldRenderer m_WorldRenderer;
|
||||
public:
|
||||
ClientGame(Client* client);
|
||||
virtual ~ClientGame();
|
||||
ClientGame(Client* client);
|
||||
virtual ~ClientGame();
|
||||
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
|
||||
void RenderWorld();
|
||||
void RenderWorld();
|
||||
|
||||
std::uint32_t GetLobbyTime() const { return m_LobbyTime; }
|
||||
const game::Player* GetPlayer() const { return m_Player; }
|
||||
const WorldClient& GetWorld() const { return m_WorldClient; }
|
||||
Client* GetClient() const { return m_Client; }
|
||||
std::uint32_t GetLobbyTime() const { return m_LobbyTime; }
|
||||
const game::Player* GetPlayer() const { return m_Player; }
|
||||
const WorldClient& GetWorld() const { return m_WorldClient; }
|
||||
Client* GetClient() const { return m_Client; }
|
||||
|
||||
render::Renderer* GetRenderer() const { return m_Renderer; }
|
||||
WorldClient& GetWorldClient() { return m_WorldClient; }
|
||||
render::Renderer* GetRenderer() const { return m_Renderer; }
|
||||
WorldClient& GetWorldClient() { return m_WorldClient; }
|
||||
|
||||
virtual void HandlePacket(const protocol::ConnexionInfoPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlayerJoinPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlayerLeavePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlayerListPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdatePlayerTeamPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateGameStatePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateLobbyTimePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateMoneyPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateExpPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::DisconnectPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::WorldDataPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::ConnexionInfoPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlayerJoinPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlayerLeavePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlayerListPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdatePlayerTeamPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateGameStatePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateLobbyTimePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateMoneyPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateExpPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::DisconnectPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::WorldDataPacket* packet) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,18 +10,18 @@ class ClientGame;
|
||||
|
||||
class WorldClient : public game::World, public protocol::PacketHandler {
|
||||
private:
|
||||
ClientGame* m_Game;
|
||||
ClientGame* m_Game;
|
||||
public:
|
||||
WorldClient(ClientGame* game);
|
||||
WorldClient(ClientGame* game);
|
||||
|
||||
virtual void HandlePacket(const protocol::WorldBeginDataPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::WorldDataPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::SpawnMobPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpgradeTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::WorldAddTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::RemoveTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateMobStatesPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateCastleLifePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::WorldBeginDataPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::WorldDataPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::SpawnMobPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpgradeTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::WorldAddTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::RemoveTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateMobStatesPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpdateCastleLifePacket* packet) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -11,23 +11,23 @@ class Server;
|
||||
|
||||
class Lobby {
|
||||
private:
|
||||
Server* m_Server;
|
||||
bool m_GameStarted = false;
|
||||
std::uint64_t m_StartTimerTime = 0;
|
||||
std::vector<std::uint8_t> m_Players;
|
||||
utils::AutoTimer m_Timer;
|
||||
Server* m_Server;
|
||||
bool m_GameStarted = false;
|
||||
std::uint64_t m_StartTimerTime = 0;
|
||||
std::vector<std::uint8_t> m_Players;
|
||||
utils::AutoTimer m_Timer;
|
||||
public:
|
||||
Lobby(Server* server);
|
||||
Lobby(Server* server);
|
||||
|
||||
void OnPlayerJoin(std::uint8_t playerID);
|
||||
void OnPlayerLeave(std::uint8_t playerID);
|
||||
void OnPlayerJoin(std::uint8_t playerID);
|
||||
void OnPlayerLeave(std::uint8_t playerID);
|
||||
|
||||
void SendTimeRemaining();
|
||||
void SendTimeRemaining();
|
||||
|
||||
void Tick();
|
||||
void Tick();
|
||||
|
||||
//static constexpr int LobbyWaitingTime = 2 * 60 * 1000; // in millis
|
||||
static constexpr int LobbyWaitingTime = 5 * 1000; // in millis
|
||||
//static constexpr int LobbyWaitingTime = 2 * 60 * 1000; // in millis
|
||||
static constexpr int LobbyWaitingTime = 5 * 1000; // in millis
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
@@ -21,80 +21,80 @@ typedef std::map<std::uint8_t, ServerConnexion> ConnexionMap;
|
||||
|
||||
class TickCounter {
|
||||
private:
|
||||
float m_TPS;
|
||||
std::uint64_t m_LastTPSTime;
|
||||
std::uint8_t m_TickCount;
|
||||
float m_TPS;
|
||||
std::uint64_t m_LastTPSTime;
|
||||
std::uint8_t m_TickCount;
|
||||
public:
|
||||
TickCounter() {}
|
||||
TickCounter() {}
|
||||
|
||||
void Reset() {
|
||||
m_TPS = SERVER_TPS;
|
||||
m_LastTPSTime = utils::GetTime();
|
||||
m_TickCount = 0;
|
||||
}
|
||||
void Reset() {
|
||||
m_TPS = SERVER_TPS;
|
||||
m_LastTPSTime = utils::GetTime();
|
||||
m_TickCount = 0;
|
||||
}
|
||||
|
||||
bool Update() { // return true when tps is updated
|
||||
m_TickCount++;
|
||||
if (m_TickCount >= SERVER_TPS) {
|
||||
std::uint64_t timeElapsedSinceLast20Ticks = td::utils::GetTime() - m_LastTPSTime;
|
||||
m_TPS = static_cast<float>(SERVER_TPS) / static_cast<float>(timeElapsedSinceLast20Ticks / 1000.0f);
|
||||
m_TickCount = 0;
|
||||
m_LastTPSTime = td::utils::GetTime();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool Update() { // return true when tps is updated
|
||||
m_TickCount++;
|
||||
if (m_TickCount >= SERVER_TPS) {
|
||||
std::uint64_t timeElapsedSinceLast20Ticks = td::utils::GetTime() - m_LastTPSTime;
|
||||
m_TPS = static_cast<float>(SERVER_TPS) / static_cast<float>(timeElapsedSinceLast20Ticks / 1000.0f);
|
||||
m_TickCount = 0;
|
||||
m_LastTPSTime = td::utils::GetTime();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float GetTPS() const { return m_TPS; }
|
||||
float GetTPS() const { return m_TPS; }
|
||||
};
|
||||
|
||||
class Server {
|
||||
private:
|
||||
network::TCPListener m_Listener;
|
||||
ConnexionMap m_Connections;
|
||||
ServerGame m_Game{ this };
|
||||
Lobby m_Lobby{ this };
|
||||
TickCounter m_TickCounter;
|
||||
network::TCPListener m_Listener;
|
||||
ConnexionMap m_Connections;
|
||||
ServerGame m_Game{ this };
|
||||
Lobby m_Lobby{ this };
|
||||
TickCounter m_TickCounter;
|
||||
|
||||
std::thread m_Thread;
|
||||
bool m_ServerRunning;
|
||||
std::thread m_Thread;
|
||||
bool m_ServerRunning;
|
||||
public:
|
||||
Server(const std::string& worldFilePath);
|
||||
virtual ~Server();
|
||||
Server(const std::string& worldFilePath);
|
||||
virtual ~Server();
|
||||
|
||||
bool Start(std::uint16_t port);
|
||||
void Stop(); // force the server to stop
|
||||
void Close(); // at the end of a game
|
||||
bool Start(std::uint16_t port);
|
||||
void Stop(); // force the server to stop
|
||||
void Close(); // at the end of a game
|
||||
|
||||
void RemoveConnexion(std::uint8_t connexionID);
|
||||
void RemoveConnexion(std::uint8_t connexionID);
|
||||
|
||||
void BroadcastPacket(const protocol::Packet* packet);
|
||||
void BroadcastPacket(const protocol::Packet* packet);
|
||||
|
||||
float GetTPS() const { return m_TickCounter.GetTPS(); }
|
||||
float GetTPS() const { return m_TickCounter.GetTPS(); }
|
||||
|
||||
bool IsRunning() { return m_ServerRunning; }
|
||||
bool IsRunning() { return m_ServerRunning; }
|
||||
|
||||
const ServerGame& GetGame() const { return m_Game; }
|
||||
ServerGame& GetGame() { return m_Game; }
|
||||
const ServerGame& GetGame() const { return m_Game; }
|
||||
ServerGame& GetGame() { return m_Game; }
|
||||
|
||||
const Lobby& GetLobby() const { return m_Lobby; }
|
||||
const ConnexionMap& GetConnexions() const { return m_Connections; }
|
||||
ConnexionMap& GetConnexions() { return m_Connections; }
|
||||
const Lobby& GetLobby() const { return m_Lobby; }
|
||||
const ConnexionMap& GetConnexions() const { return m_Connections; }
|
||||
ConnexionMap& GetConnexions() { return m_Connections; }
|
||||
|
||||
const game::PlayerList& GetPlayers() const { return m_Game.GetPlayers(); }
|
||||
game::PlayerList& GetPlayers() { return m_Game.GetPlayers(); }
|
||||
const game::PlayerList& GetPlayers() const { return m_Game.GetPlayers(); }
|
||||
game::PlayerList& GetPlayers() { return m_Game.GetPlayers(); }
|
||||
|
||||
private:
|
||||
void Accept();
|
||||
void UpdateSockets();
|
||||
void Accept();
|
||||
void UpdateSockets();
|
||||
|
||||
void Clean();
|
||||
void StartThread();
|
||||
void StopThread();
|
||||
void Tick(std::uint64_t delta);
|
||||
void Clean();
|
||||
void StartThread();
|
||||
void StopThread();
|
||||
void Tick(std::uint64_t delta);
|
||||
|
||||
void OnPlayerJoin(std::uint8_t id);
|
||||
void OnPlayerLeave(std::uint8_t id);
|
||||
void OnPlayerJoin(std::uint8_t id);
|
||||
void OnPlayerLeave(std::uint8_t id);
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
@@ -11,49 +11,48 @@ namespace server {
|
||||
|
||||
class Server;
|
||||
|
||||
struct KeepAlive
|
||||
{
|
||||
std::uint64_t keepAliveID = 0;
|
||||
std::uint64_t sendTime;
|
||||
bool recievedResponse = false;
|
||||
struct KeepAlive {
|
||||
std::uint64_t keepAliveID = 0;
|
||||
std::uint64_t sendTime;
|
||||
bool recievedResponse = false;
|
||||
};
|
||||
|
||||
|
||||
class ServerConnexion : public protocol::Connexion {
|
||||
private:
|
||||
Server* m_Server = nullptr;
|
||||
std::uint8_t m_ID;
|
||||
KeepAlive m_KeepAlive;
|
||||
game::Player* m_Player;
|
||||
Server* m_Server = nullptr;
|
||||
std::uint8_t m_ID;
|
||||
KeepAlive m_KeepAlive;
|
||||
game::Player* m_Player;
|
||||
public:
|
||||
ServerConnexion();
|
||||
ServerConnexion(network::TCPSocket& socket, std::uint8_t id);
|
||||
ServerConnexion(ServerConnexion&& move);
|
||||
virtual ~ServerConnexion();
|
||||
ServerConnexion();
|
||||
ServerConnexion(network::TCPSocket& socket, std::uint8_t id);
|
||||
ServerConnexion(ServerConnexion&& move);
|
||||
virtual ~ServerConnexion();
|
||||
|
||||
void SetServer(Server* server);
|
||||
void SetServer(Server* server);
|
||||
|
||||
virtual void HandlePacket(const protocol::PlayerLoginPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::KeepAlivePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::SelectTeamPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::DisconnectPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlaceTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::SendMobsPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpgradeTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::RemoveTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlayerLoginPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::KeepAlivePacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::SelectTeamPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::DisconnectPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::PlaceTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::SendMobsPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::UpgradeTowerPacket* packet) override;
|
||||
virtual void HandlePacket(const protocol::RemoveTowerPacket* packet) override;
|
||||
|
||||
std::uint8_t GetID() const { return m_ID; }
|
||||
const game::Player* GetPlayer() const { return m_Player; }
|
||||
game::Player* GetPlayer() { return m_Player; }
|
||||
std::uint8_t GetID() const { return m_ID; }
|
||||
const game::Player* GetPlayer() const { return m_Player; }
|
||||
game::Player* GetPlayer() { return m_Player; }
|
||||
|
||||
virtual bool UpdateSocket();
|
||||
virtual bool UpdateSocket();
|
||||
|
||||
REMOVE_COPY(ServerConnexion);
|
||||
REMOVE_COPY(ServerConnexion);
|
||||
private:
|
||||
void RegisterHandlers();
|
||||
void CheckKeepAlive();
|
||||
void SendKeepAlive();
|
||||
void InitConnection();
|
||||
void RegisterHandlers();
|
||||
void CheckKeepAlive();
|
||||
void SendKeepAlive();
|
||||
void InitConnection();
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
@@ -11,32 +11,32 @@ class Server;
|
||||
|
||||
class ServerGame : public game::Game, public game::GameListener {
|
||||
private:
|
||||
Server* m_Server;
|
||||
ServerWorld m_ServerWorld;
|
||||
utils::AutoTimer m_GoldMineTimer;
|
||||
utils::AutoTimer m_MobStatesTimer;
|
||||
utils::CooldownTimer m_EndGameCooldown;
|
||||
Server* m_Server;
|
||||
ServerWorld m_ServerWorld;
|
||||
utils::AutoTimer m_GoldMineTimer;
|
||||
utils::AutoTimer m_MobStatesTimer;
|
||||
utils::CooldownTimer m_EndGameCooldown;
|
||||
public:
|
||||
ServerGame(Server* server);
|
||||
~ServerGame() {}
|
||||
ServerGame(Server* server);
|
||||
~ServerGame() {}
|
||||
|
||||
ServerWorld* GetServerWorld() { return &m_ServerWorld; }
|
||||
ServerWorld* GetServerWorld() { return &m_ServerWorld; }
|
||||
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
void StartGame();
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
void StartGame();
|
||||
|
||||
// GameListener
|
||||
// GameListener
|
||||
|
||||
virtual void OnGameStateUpdate(game::GameState newState) override;
|
||||
virtual void OnGameBegin() override;
|
||||
virtual void OnGameEnd() override;
|
||||
virtual void OnGameClose() override;
|
||||
virtual void OnGameStateUpdate(game::GameState newState) override;
|
||||
virtual void OnGameBegin() override;
|
||||
virtual void OnGameEnd() override;
|
||||
virtual void OnGameClose() override;
|
||||
private:
|
||||
void BalanceTeams();
|
||||
void InitPlayerStats();
|
||||
void UpdateMobStates();
|
||||
void UpdateGoldMines();
|
||||
void UpdatePlayerStats();
|
||||
void BalanceTeams();
|
||||
void InitPlayerStats();
|
||||
void UpdateMobStates();
|
||||
void UpdateGoldMines();
|
||||
void UpdatePlayerStats();
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -10,19 +10,19 @@ class ServerGame;
|
||||
|
||||
class ServerWorld : public game::World {
|
||||
private:
|
||||
game::MobID m_CurrentMobID;
|
||||
game::TowerID m_CurrentTowerID;
|
||||
Server* m_Server;
|
||||
game::MobID m_CurrentMobID;
|
||||
game::TowerID m_CurrentTowerID;
|
||||
Server* m_Server;
|
||||
public:
|
||||
static constexpr float MobSpawnBorder = 0.01f;
|
||||
static constexpr float MobSpawnBorder = 0.01f;
|
||||
|
||||
ServerWorld(Server* server, ServerGame* game);
|
||||
ServerWorld(Server* server, ServerGame* game);
|
||||
|
||||
void SpawnMobs(game::MobType type, std::uint8_t level, game::PlayerID sender, std::uint8_t count);
|
||||
game::TowerPtr PlaceTowerAt(game::TowerType type, std::int32_t x, std::int32_t y, game::PlayerID builder);
|
||||
void SpawnMobs(game::MobType type, std::uint8_t level, game::PlayerID sender, std::uint8_t count);
|
||||
game::TowerPtr PlaceTowerAt(game::TowerType type, std::int32_t x, std::int32_t y, game::PlayerID builder);
|
||||
|
||||
virtual void OnMobDie(game::Mob* mob) override;
|
||||
virtual void OnMobCastleDamage(game::Mob* damager, game::TeamCastle* enemyCastle, float damage) override;
|
||||
virtual void OnMobDie(game::Mob* mob) override;
|
||||
virtual void OnMobCastleDamage(game::Mob* damager, game::TeamCastle* enemyCastle, float damage) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user