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);
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@ public:
|
||||
void setCenterY(float y) { m_Center.setY(y); }
|
||||
|
||||
void setSize(float width, float height) { setWidth(width); setHeight(height); }
|
||||
void setSize(Point size) { setSize(size.getX(), size.getY()); }
|
||||
Point getSize() { return { m_Width, m_Height }; }
|
||||
|
||||
void setWidth(float width) { m_Width = width; }
|
||||
void setHeight(float height) { m_Height = height; }
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "render/gui/TowerPlacePopup.h"
|
||||
#include "render/gui/MobTooltip.h"
|
||||
#include "render/gui/CastleTooltip.h"
|
||||
|
||||
#include "render/gui/imgui/imgui.h"
|
||||
|
||||
@@ -40,6 +41,7 @@ private:
|
||||
|
||||
std::unique_ptr<gui::TowerPlacePopup> m_TowerPlacePopup;
|
||||
std::unique_ptr<gui::MobTooltip> m_MobTooltip;
|
||||
std::unique_ptr<gui::CastleTooltip> m_CastleTooltip;
|
||||
public:
|
||||
WorldRenderer(game::World* world, client::ClientGame* client);
|
||||
~WorldRenderer();
|
||||
@@ -69,8 +71,11 @@ private:
|
||||
void renderPopups();
|
||||
void renderTowerUpgradePopup();
|
||||
void renderMobTooltip() const;
|
||||
void renderCastleTooltip() const;
|
||||
void detectClick();
|
||||
void detectMobHovering() const;
|
||||
void detectCastleHovering() const;
|
||||
void renderTooltips() const;
|
||||
void removeTower();
|
||||
glm::vec2 getCursorWorldPos() const;
|
||||
glm::vec2 getClickWorldPos() const;
|
||||
|
||||
27
include/render/gui/CastleTooltip.h
Normal file
27
include/render/gui/CastleTooltip.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "GuiWidget.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
namespace game {
|
||||
|
||||
class TeamCastle;
|
||||
|
||||
} // namespace game
|
||||
|
||||
namespace gui {
|
||||
|
||||
class CastleTooltip : public GuiWidget {
|
||||
private:
|
||||
const game::TeamCastle* m_Castle;
|
||||
public:
|
||||
CastleTooltip(client::Client* client);
|
||||
|
||||
virtual void render();
|
||||
|
||||
void setCastle(const game::TeamCastle* castle) { m_Castle = castle; }
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
} // namespace td
|
||||
Reference in New Issue
Block a user