diff --git a/CMakeLists.txt b/CMakeLists.txt index 53c64c8d..8b14312c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,13 +70,14 @@ set(SRC_FILES ${SRC_DIR}/Util/GameObject.cpp ${SRC_DIR}/Util/Renderer.cpp ${SRC_DIR}/Util/Color.cpp + ${SRC_DIR}/Util/Animation.cpp + ${SRC_DIR}/Util/MissingTexture.cpp ${SRC_DIR}/Display/ImageArray.cpp ${SRC_DIR}/Display/CustomizableImage.cpp ${SRC_DIR}/Display/SpriteSheetAnimation.cpp - ${SRC_DIR}/Display/Animation.cpp - ${SRC_DIR}/Display/MissingTexture.cpp + ${SRC_DIR}/Display/Grid.cpp ${SRC_DIR}/Display/SpriteSheet.cpp @@ -152,7 +153,6 @@ set(INCLUDE_FILES ${INCLUDE_DIR}/Util/Keycode.hpp ${INCLUDE_DIR}/Util/SFX.hpp ${INCLUDE_DIR}/Util/BGM.hpp - ${INCLUDE_DIR}/Util/Text.hpp ${INCLUDE_DIR}/Util/Transform.hpp ${INCLUDE_DIR}/Util/TransformUtils.hpp @@ -160,9 +160,10 @@ set(INCLUDE_FILES ${INCLUDE_DIR}/Util/Renderer.hpp ${INCLUDE_DIR}/Util/Color.hpp ${INCLUDE_DIR}/Util/Image.hpp + ${INCLUDE_DIR}/Util/Animation.hpp + ${INCLUDE_DIR}/Util/MissingTexture.hpp + - ${INCLUDE_DIR}/Display/Animation.hpp - ${INCLUDE_DIR}/Display/MissingTexture.hpp ${INCLUDE_DIR}/Display/SpriteSheetAnimation.hpp ${INCLUDE_DIR}/Display/ImageArray.hpp ${INCLUDE_DIR}/Display/CustomizableImage.hpp diff --git a/include/Avatar/Avatar.hpp b/include/Avatar/Avatar.hpp index 1979b2f5..366a573e 100644 --- a/include/Avatar/Avatar.hpp +++ b/include/Avatar/Avatar.hpp @@ -8,12 +8,12 @@ #include "Avatar/AvatarOrder.hpp" #include "Avatar/Moving.hpp" #include "Avatar/PathUtility.hpp" -#include "Display/Image.hpp" #include "Display/SpriteSheet.hpp" #include "Display/SpriteSheetAnimation.hpp" #include "Map/MapUtility.hpp" #include "Mechanics/GameObjectID.hpp" #include "Selectable.hpp" +#include "Util/Image.hpp" class Avatar : public Moving, public AttackAndDamage, diff --git a/include/Display/DrawOverlays.hpp b/include/Display/DrawOverlays.hpp index d567e74c..2eabe80b 100644 --- a/include/Display/DrawOverlays.hpp +++ b/include/Display/DrawOverlays.hpp @@ -5,7 +5,7 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_DRAWOVERLAYS_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_DRAWOVERLAYS_HPP #include "Core/Drawable.hpp" -#include "Display/Image.hpp" +#include "Util/Image.hpp" #include "Util/TransformUtils.hpp" #include "pch.hpp" class DrawOverlays : public Core::Drawable { diff --git a/include/Display/Sprite.hpp b/include/Display/Sprite.hpp index c42be73c..fb412dc7 100644 --- a/include/Display/Sprite.hpp +++ b/include/Display/Sprite.hpp @@ -5,8 +5,8 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_SPRITE_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_SPRITE_HPP #include "Core/Drawable.hpp" -#include "Display/Image.hpp" #include "Util/CustomizableImage.hpp" +#include "Util/Image.hpp" #include "pch.hpp" // IWYU pragma: export class Sprite : public Core::Drawable { diff --git a/include/Display/SpriteSheetAnimation.hpp b/include/Display/SpriteSheetAnimation.hpp index ced1ed91..a1d8c2a9 100644 --- a/include/Display/SpriteSheetAnimation.hpp +++ b/include/Display/SpriteSheetAnimation.hpp @@ -12,7 +12,7 @@ #include "Core/Drawable.hpp" -#include "Image.hpp" +#include "Util/Image.hpp" namespace Util { /** diff --git a/include/Map/YAMLReader.hpp b/include/Map/YAMLReader.hpp index 30f0eeae..d681ec9d 100644 --- a/include/Map/YAMLReader.hpp +++ b/include/Map/YAMLReader.hpp @@ -4,9 +4,9 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_YAMLREADER_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_YAMLREADER_HPP -#include "Display/Image.hpp" #include "TerrainConfig.hpp" #include "Tile.hpp" +#include "Util/Image.hpp" #include #include #include diff --git a/include/Mechanics/NemesisManager.hpp b/include/Mechanics/NemesisManager.hpp index f2c4464f..1e0e7c7b 100644 --- a/include/Mechanics/NemesisManager.hpp +++ b/include/Mechanics/NemesisManager.hpp @@ -5,7 +5,7 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_NEMESISMANAGER_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_NEMESISMANAGER_HPP #include "Map/MapUtility.hpp" -#define ATTACK_RANGE 5 + class NemesisManager { public: NemesisManager() {} @@ -32,11 +32,13 @@ class NemesisManager { if (ifAvatarHasNemesis(hunter) == false) { return false; } - if (hunter.getDistance(m_Nemesis[hunter].getCurrentCell()) <= ATTACK_RANGE) // check with in range + if (hunter->getDistance(m_Nemesis[hunter]->getCurrentCell()) <= + hunter->getWeapon()->getFireRange()) // check with in range { return true; } else { - forceMove(hunter,m_Nemesis[hunter].getCurrentCell());//向目標移動 + // forceMove(hunter, + // m_Nemesis[hunter]->getCurrentCell()); // 向目標移動 return false; } } @@ -49,7 +51,7 @@ class NemesisManager { hunter->setAvatarOrder(AvatarOrderType::OPEN_FIRE); prey->setAvatarOrder(AvatarOrderType::TAKEN_DAMAGE); hunter->getAttackAndDamager()->openFireToTarget(prey); - //反擊 + // 反擊 prey->setAvatarOrder(AvatarOrderType::OPEN_FIRE); hunter->setAvatarOrder(AvatarOrderType::TAKEN_DAMAGE); prey->getAttackAndDamager()->openFireToTarget(prey); diff --git a/include/Mechanics/UnitManager.hpp b/include/Mechanics/UnitManager.hpp index 7232ab42..2007280a 100644 --- a/include/Mechanics/UnitManager.hpp +++ b/include/Mechanics/UnitManager.hpp @@ -74,11 +74,13 @@ class UnitManager : public Player { void spawn(std::shared_ptr m_Map, UnitType unit, HouseType house) { + if (house == HouseType::ENEMY) { // m_Enemy->addUnitConstructCount(unit, 1); } else { // m_Player->setUnitConstructCount(unit, 1); } + switch (unit) { case UnitType::INFANTRY: { auto avatar = std::make_shared(house); @@ -89,12 +91,13 @@ class UnitManager : public Player { return; } + + avatar->Start(m_StructureManager->getStructureArray() ->getPlayerBarrackCell()); // avatar // ->setNewDestination(m_StructureManager.getStructureArray().getPlayerWayPointCell()); m_AvatarManager->AppendAvatar(avatar); - break; } default: { @@ -216,4 +219,5 @@ class UnitManager : public Player { std::chrono::high_resolution_clock::time_point m_StartTime; double m_lastElapsed = 0.F; }; + #endif // PRACTICALTOOLSFORSIMPLEDESIGN_UNITMANAGER_HPP diff --git a/include/Scene/Scene.hpp b/include/Scene/Scene.hpp index 47057991..ea611c67 100644 --- a/include/Scene/Scene.hpp +++ b/include/Scene/Scene.hpp @@ -13,7 +13,6 @@ #include "Camera.hpp" #include "Display/DrawOverlays.hpp" #include "Display/Grid.hpp" -#include "Display/Image.hpp" #include "Display/SpriteSheet.hpp" #include "Map/Map.hpp" #include "Structure/AdvencePowerPlants.hpp" @@ -24,6 +23,7 @@ #include "Structure/WarFactory.hpp" #include "Structure/WayPoint.hpp" #include "UI/UI.hpp" +#include "Util/Image.hpp" #include "Util/Input.hpp" #include "Util/Keycode.hpp" #include "Util/Logger.hpp" @@ -47,7 +47,8 @@ class Scene { protected: std::shared_ptr m_Map = std::make_shared(); - std::shared_ptr m_SceneCamera = std::make_shared(); + std::shared_ptr m_SceneCamera = + std::make_shared(); std::shared_ptr m_GameObjectManager = std::make_shared(); std::shared_ptr m_EnemyObjectManager = diff --git a/include/Structure/Structure.hpp b/include/Structure/Structure.hpp index ad8cfdd3..004e1d62 100644 --- a/include/Structure/Structure.hpp +++ b/include/Structure/Structure.hpp @@ -5,13 +5,13 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_HPP #include "Avatar/AttackAndDamage.hpp" -#include "Display/Image.hpp" #include "Display/SpriteSheet.hpp" #include "Display/SpriteSheetAnimation.hpp" #include "HighLight.h" #include "Mechanics/GameObjectID.hpp" #include "Selectable.hpp" #include "Structure/StructureOrder.hpp" +#include "Util/Image.hpp" #include "Unit/Health.hpp" #include "Unit/IHealthable.hpp" @@ -70,8 +70,8 @@ class Structure : public Util::GameObject, virtual void SetSpriteSheet() { m_StructureSpriteSheet->Start( "../assets/sprites/Barracks_SpriteSheet.png", 48, 48, 13, 0); - m_SpriteSheetAnimation->initSpriteSheetAnimation(m_StructureSpriteSheet, - false, INTERVAL, false); + m_SpriteSheetAnimation->initSpriteSheetAnimation( + m_StructureSpriteSheet, false, INTERVAL, false); } virtual void SetObjectLocation(glm::vec2 location); @@ -86,7 +86,7 @@ class Structure : public Util::GameObject, float getElectricPower() { return this->m_ElectricPower; } float getBuildingTime() { return this->m_BuildingTime; } float getBuildingCost() { return this->m_BuildingCost; } - HouseType getHouseType(){return this->m_ID.getHouseType();} + HouseType getHouseType() { return this->m_ID.getHouseType(); } glm::vec2 GlobalCoordToCellCoord(glm::vec2 globalCoord) { return glm::vec2(int(globalCoord[0] / CELL_SIZE.x), @@ -126,7 +126,7 @@ class Structure : public Util::GameObject, m_ObjectLocation.y + CELL_SIZE.y}; glm::vec2 m_ObjectLocation = {100, 100}; std::vector m_RelativeOccupiedArea = {{0, 0}}; - + // health std::shared_ptr m_Health = std::make_shared(); // attack and damage diff --git a/include/Structure/WayPoint.hpp b/include/Structure/WayPoint.hpp index 454d337b..7c082e7d 100644 --- a/include/Structure/WayPoint.hpp +++ b/include/Structure/WayPoint.hpp @@ -4,8 +4,8 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINT_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINT_HPP -#include "Display/Image.hpp" #include "Util/GameObject.hpp" +#include "Util/Image.hpp" #include "Util/TransformUtils.hpp" class WayPoint : public Util::GameObject { private: diff --git a/include/Structure/WayPointStructure.hpp b/include/Structure/WayPointStructure.hpp index e5f6798b..aa02b718 100644 --- a/include/Structure/WayPointStructure.hpp +++ b/include/Structure/WayPointStructure.hpp @@ -5,12 +5,12 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_MOVEABLESTRUCTURE_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_MOVEABLESTRUCTURE_HPP #include "Display/Grid.hpp" -#include "Display/Image.hpp" #include "Display/Line.hpp" #include "HighLight.h" #include "Map/MapUtility.hpp" #include "Structure/IWayPoint.hpp" #include "Structure/Structure.hpp" +#include "Util/Image.hpp" #include "Util/Input.hpp" #include "Util/Keycode.hpp" #include "WayPoint.hpp" diff --git a/include/Unit/IOrderable.hpp b/include/Unit/IOrderable.hpp deleted file mode 100644 index 6200eddd..00000000 --- a/include/Unit/IOrderable.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// -// Created by 盧威任 on 5/6/24. -// - -#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_IORDERABLE_HPP -#define PRACTICALTOOLSFORSIMPLEDESIGN_IORDERABLE_HPP -class IOrderable {}; -#endif // PRACTICALTOOLSFORSIMPLEDESIGN_IORDERABLE_HPP diff --git a/include/Display/Animation.hpp b/include/Util/Animation.hpp similarity index 100% rename from include/Display/Animation.hpp rename to include/Util/Animation.hpp diff --git a/include/Display/Image.hpp b/include/Util/Image.hpp similarity index 100% rename from include/Display/Image.hpp rename to include/Util/Image.hpp diff --git a/include/Display/MissingTexture.hpp b/include/Util/MissingTexture.hpp similarity index 100% rename from include/Display/MissingTexture.hpp rename to include/Util/MissingTexture.hpp diff --git a/include/Display/Text.hpp b/include/Util/Text.hpp similarity index 100% rename from include/Display/Text.hpp rename to include/Util/Text.hpp diff --git a/src/Display/Animation.cpp b/src/Util/Animation.cpp similarity index 98% rename from src/Display/Animation.cpp rename to src/Util/Animation.cpp index 8b696394..ee681c01 100644 --- a/src/Display/Animation.cpp +++ b/src/Util/Animation.cpp @@ -1,4 +1,4 @@ -#include "Display/Animation.hpp" +#include "Util/Animation.hpp" #include "Util/Logger.hpp" #include "Util/Time.hpp" diff --git a/src/Util/Image.cpp b/src/Util/Image.cpp index 79a9ba53..627f8e52 100644 --- a/src/Util/Image.cpp +++ b/src/Util/Image.cpp @@ -1,11 +1,11 @@ -#include "Display/Image.hpp" +#include "Util/Image.hpp" #include "pch.hpp" #include "Core/Texture.hpp" #include "Core/TextureUtils.hpp" -#include "Display/MissingTexture.hpp" +#include "Util/MissingTexture.hpp" #include "Util/TransformUtils.hpp" #include "config.hpp" diff --git a/src/Display/MissingTexture.cpp b/src/Util/MissingTexture.cpp similarity index 91% rename from src/Display/MissingTexture.cpp rename to src/Util/MissingTexture.cpp index c64ad421..ce56dd65 100644 --- a/src/Display/MissingTexture.cpp +++ b/src/Util/MissingTexture.cpp @@ -2,7 +2,7 @@ #include "SDL_image.h" #include "Util/Logger.hpp" -#include "Display/MissingTexture.hpp" +#include "Util/MissingTexture.hpp" SDL_Surface *GetMissingTextureSDLSurface() { SDL_RWops *rwop = SDL_RWFromConstMem(MISSING_TEXTURE_BASE64_DECODE.data(), diff --git a/src/Util/Text.cpp b/src/Util/Text.cpp index c906ceb4..28e61b49 100644 --- a/src/Util/Text.cpp +++ b/src/Util/Text.cpp @@ -3,8 +3,8 @@ #include "Core/Texture.hpp" #include "Core/TextureUtils.hpp" -#include "Display/Text.hpp" #include "Util/Logger.hpp" +#include "Util/Text.hpp" #include "Util/TransformUtils.hpp" #include "config.hpp"