feat: add castle tooltip
This commit is contained in:
@@ -19,7 +19,7 @@ typedef std::map<std::uint8_t, Player> PlayerList;
|
||||
class Game {
|
||||
protected:
|
||||
World* m_World;
|
||||
std::array<Team, 2> m_Teams = { Team{TeamColor::Red}, Team{TeamColor::Blue} };
|
||||
TeamList m_Teams = { Team{TeamColor::Red}, Team{TeamColor::Blue} };
|
||||
GameState m_GameState = GameState::Lobby;
|
||||
PlayerList m_Players;
|
||||
public:
|
||||
@@ -49,6 +49,8 @@ public:
|
||||
const Player* getPlayerById(PlayerID id) const;
|
||||
Player* getPlayerById(PlayerID id);
|
||||
|
||||
const TeamList& getTeams() const { return m_Teams; }
|
||||
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -23,7 +23,7 @@ class Spawn : public utils::shape::Rectangle {
|
||||
private:
|
||||
Direction m_Direction;
|
||||
public:
|
||||
Spawn(){
|
||||
Spawn() {
|
||||
setWidth(5);
|
||||
setHeight(5);
|
||||
}
|
||||
@@ -33,19 +33,34 @@ public:
|
||||
void setDirection(Direction direction) { m_Direction = direction; }
|
||||
};
|
||||
|
||||
struct TeamCastle : public utils::shape::Rectangle{
|
||||
class Team;
|
||||
|
||||
class TeamCastle : public utils::shape::Rectangle {
|
||||
private:
|
||||
const Team* m_Team;
|
||||
float m_Life;
|
||||
public:
|
||||
TeamCastle() : m_Life(1000) {
|
||||
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 {
|
||||
@@ -71,5 +86,7 @@ public:
|
||||
std::uint8_t getPlayerCount() const;
|
||||
};
|
||||
|
||||
typedef std::array<Team, 2> TeamList;
|
||||
|
||||
} // namespace game
|
||||
} // namespace td
|
||||
|
||||
@@ -205,6 +205,8 @@ public:
|
||||
Team& getTeam(TeamColor team);
|
||||
const Team& getTeam(TeamColor team) const;
|
||||
|
||||
const TeamList& getTeams() const;
|
||||
|
||||
const TowerList& getTowers() const { return m_Towers; };
|
||||
TowerPtr getTowerById(TowerID tower);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user