93 lines
1.7 KiB
C++
93 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "Types.h"
|
|
|
|
#include "td/misc/Shapes.h"
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <cmath>
|
|
|
|
namespace td {
|
|
namespace game {
|
|
|
|
class Player;
|
|
|
|
enum class TeamColor : std::int8_t {
|
|
None = -1,
|
|
Red,
|
|
Blue
|
|
};
|
|
|
|
class Spawn : public utils::shape::Rectangle {
|
|
private:
|
|
Direction m_Direction;
|
|
public:
|
|
Spawn() {
|
|
SetWidth(5);
|
|
SetHeight(5);
|
|
}
|
|
|
|
Direction GetDirection() const { return m_Direction; }
|
|
|
|
void SetDirection(Direction direction) { m_Direction = direction; }
|
|
};
|
|
|
|
class Team;
|
|
|
|
class TeamCastle : public utils::shape::Rectangle {
|
|
private:
|
|
const Team* m_Team;
|
|
float m_Life;
|
|
public:
|
|
static constexpr int CastleMaxLife = 1000;
|
|
|
|
TeamCastle(const Team* team) : m_Team(team), m_Life(CastleMaxLife) {
|
|
SetWidth(5);
|
|
SetHeight(5);
|
|
}
|
|
|
|
TeamCastle() : TeamCastle(nullptr) {}
|
|
|
|
float GetLife() const { return m_Life; }
|
|
|
|
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 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;
|
|
public:
|
|
Team(TeamColor color);
|
|
|
|
void AddPlayer(Player* newPlayer);
|
|
void RemovePlayer(const Player* player);
|
|
|
|
TeamColor GetColor() const;
|
|
|
|
const Spawn& GetSpawn() const { return m_Spawn; }
|
|
Spawn& GetSpawn() { return m_Spawn; }
|
|
|
|
const TeamCastle& GetCastle() const { return m_TeamCastle; }
|
|
TeamCastle& GetCastle() { return m_TeamCastle; }
|
|
|
|
std::uint8_t GetPlayerCount() const;
|
|
};
|
|
|
|
typedef std::array<Team, 2> TeamList;
|
|
|
|
} // namespace game
|
|
} // namespace td
|