feat: add tower detection
This commit is contained in:
@@ -32,9 +32,9 @@ enum class TowerType : std::uint8_t {
|
|||||||
TowerCount
|
TowerCount
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TowerSize : bool {
|
enum class TowerSize : std::uint8_t {
|
||||||
Little = 0, // 3x3
|
Little = 3, // 3x3
|
||||||
Big, // 5x5
|
Big = 5, // 5x5
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TowerPath : std::uint8_t {
|
enum class TowerPath : std::uint8_t {
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ public:
|
|||||||
bool CanPlaceLittleTower(const glm::vec2& worldPos, PlayerID player) const;
|
bool CanPlaceLittleTower(const glm::vec2& worldPos, PlayerID player) const;
|
||||||
bool CanPlaceBigTower(const glm::vec2& worldPos, PlayerID player) const;
|
bool CanPlaceBigTower(const glm::vec2& worldPos, PlayerID player) const;
|
||||||
|
|
||||||
|
TowerPtr GetTower(const glm::vec2& position); // 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[(std::size_t)color]; }
|
const Color& getSpawnColor(TeamColor color) const { return m_SpawnColorPalette[(std::size_t)color]; }
|
||||||
|
|||||||
@@ -467,6 +467,23 @@ void World::cleanDeadMobs(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TowerPtr World::GetTower(const glm::vec2& position) {
|
||||||
|
for (TowerPtr tower : m_Towers) {
|
||||||
|
if (tower->getSize() == TowerSize::Big) {
|
||||||
|
if (tower->getX() - 2 <= position.x && tower->getX() + 3 >= position.x &&
|
||||||
|
tower->getY() - 2 <= position.y && tower->getY() + 3 >= position.y) {
|
||||||
|
return tower;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tower->getX() - 1 <= position.x && tower->getX() + 2 >= position.x &&
|
||||||
|
tower->getY() - 1 <= position.y && tower->getY() + 2 >= position.y) {
|
||||||
|
return tower;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void World::OnArrowShot(MobPtr target, Tower* shooter) {
|
void World::OnArrowShot(MobPtr target, Tower* shooter) {
|
||||||
bool explosiveArrows = shooter->getLevel().getPath() == TowerPath::Bottom;
|
bool explosiveArrows = shooter->getLevel().getPath() == TowerPath::Bottom;
|
||||||
if (explosiveArrows) {
|
if (explosiveArrows) {
|
||||||
|
|||||||
Reference in New Issue
Block a user