diff --git a/include/Camera.hpp b/include/Camera.hpp index 181bee61..5f59a0d1 100644 --- a/include/Camera.hpp +++ b/include/Camera.hpp @@ -48,6 +48,8 @@ class CameraClass { void Start(glm::vec2 minPosition, glm::vec2 maxPosition); void Update(); + +protected: void UpdateWhenCursorAtBoarder(); void UpdateWhenCursorScroll(); diff --git a/include/Mechanics/Player.hpp b/include/Mechanics/Player.hpp index 757f7b3b..ef1205ac 100644 --- a/include/Mechanics/Player.hpp +++ b/include/Mechanics/Player.hpp @@ -9,8 +9,7 @@ class Player { public: Player() {} ~Player() {} - - void setTotalCurrency(int value) { m_totalCurrency = value; }; + void setTotalCurrency(int value) { m_totalCurrency = value; } void addCurrency(int value) { m_totalCurrency += value; }; void setTotalPower(int value) { m_totalPower = value; } @@ -32,6 +31,6 @@ class Player { protected: int m_maxTroopSize = 200; int m_totalPower = 0; - int m_totalCurrency = 200; + int m_totalCurrency = 0; }; #endif // PRACTICALTOOLSFORSIMPLEDESIGN_PLAYER_HPP diff --git a/include/UI/UI.hpp b/include/UI/UI.hpp index 0812a8c2..cbdb8f06 100644 --- a/include/UI/UI.hpp +++ b/include/UI/UI.hpp @@ -18,7 +18,7 @@ class UIClass { public: - void Start(std::shared_ptr map, std::shared_ptr player, + void Start(std::shared_ptr map, std::shared_ptr gameobjectmanager); void Update(); @@ -44,10 +44,6 @@ class UIClass { protected: void importMap(std::shared_ptr m_Map) { this->m_Map = m_Map; } - void importPlayer(std::shared_ptr m_Player) { - this->m_Player = m_Player; - ButtonScript.importPlayer(m_Player); - } void importGameObjManager(std::shared_ptr gameObjectManager) { m_gameObjectManager = gameObjectManager; @@ -88,7 +84,7 @@ class UIClass { glm::vec2 m_GridSize = {100, 100}; // 0318 - void setSelectToBuild(unitType type){m_selectedStructureType = type;} + void setSelectToBuild(unitType type) { m_selectedStructureType = type; } ImGuiIO &io = ImGui::GetIO(); @@ -99,7 +95,6 @@ class UIClass { ImFont *sacker_light = io.Fonts->AddFontFromFileTTF( "../assets/fonts/sackersgothicstd-light.otf", 11); - bool b_barackBuilt = false; bool b_warfactoryBuilt = false; bool b_orerefineryBuilt = false; @@ -110,12 +105,10 @@ class UIClass { glm::vec2 m_warfactoryTargetCell; glm::vec2 m_orerefineryCell; glm::vec2 m_orerefineryTargetCell; - unitType m_selectedStructureType=unitType::NONE; - + unitType m_selectedStructureType = unitType::NONE; // ptr import from scene std::shared_ptr m_Map; - std::shared_ptr m_Player; std::shared_ptr m_gameObjectManager; }; diff --git a/include/UI/UIScriptProcess.hpp b/include/UI/UIScriptProcess.hpp index 5bfa913b..1a0a3a78 100644 --- a/include/UI/UIScriptProcess.hpp +++ b/include/UI/UIScriptProcess.hpp @@ -22,7 +22,6 @@ class UIScriptProcess { private: - std::shared_ptr m_player; std::shared_ptr m_gameObjectManager; // building @@ -101,7 +100,6 @@ class UIScriptProcess { void setIfReadytoSpawn(bool b) { b_isReadyToSpawn = b; } // import from scene - void importPlayer(std::shared_ptr player) { m_player = player; } void importGameObjManager(std::shared_ptr gameObjectManager) { m_gameObjectManager = gameObjectManager; diff --git a/src/Scene/DefaultScene.cpp b/src/Scene/DefaultScene.cpp index 94b26fd3..d0286810 100644 --- a/src/Scene/DefaultScene.cpp +++ b/src/Scene/DefaultScene.cpp @@ -23,8 +23,8 @@ void DefaultScene::Start() { // m_dummy.Start({5, 5}, m_Map); m_GameObjectManager->Start(m_Map); // m_Cursor.Start(m_Map); - m_UI.Start(m_Map, m_Player, m_GameObjectManager); - m_Player->setTotalCurrency(5000); + m_UI.Start(m_Map, m_GameObjectManager); + m_GameObjectManager->setTotalCurrency(5000); m_SceneCamera.Start(MapUtil::CellCoordToGlobal(glm::vec2(-10, -10)), MapUtil::CellCoordToGlobal(glm::vec2(100, 100))); diff --git a/src/UI/UI.cpp b/src/UI/UI.cpp index 8b8970a7..bbfbd415 100644 --- a/src/UI/UI.cpp +++ b/src/UI/UI.cpp @@ -8,7 +8,6 @@ std::unordered_map UIClass::s_unitConstructCount; void UIClass::Start(std::shared_ptr map, - std::shared_ptr player, std::shared_ptr gameobjectmanager) { InitUnitQueue(); m_StructureIconSpriteSheet->Start( @@ -18,7 +17,6 @@ void UIClass::Start(std::shared_ptr map, m_VehiclesIconSpriteSheet->Start( "../assets/sprites/ICON_Allied_Vehicles.png", 64, 48, 12, 0); importMap(map); - importPlayer(player); importGameObjManager(gameobjectmanager); } @@ -442,7 +440,6 @@ std::shared_ptr UIClass::getUnitFromUI() { ButtonScript.setIfReadytoSpawn(false); if (std::dynamic_pointer_cast(Avatar)) { - Avatar->Start({m_barrackCell.x + 1, m_barrackCell.y - 1}); Avatar->setNewDestination(m_barrackTargetCell); diff --git a/src/UI/UIScriptProcess.cpp b/src/UI/UIScriptProcess.cpp index 74c64148..b91e1e5f 100644 --- a/src/UI/UIScriptProcess.cpp +++ b/src/UI/UIScriptProcess.cpp @@ -75,7 +75,7 @@ void UIScriptProcess::CountDown() { } if (m_currentBuildRemainingCost > 0) { m_currentBuildRemainingCost -= buildCost; - m_player->addCurrency(-1 * buildCost); + m_gameObjectManager->addCurrency(-1 * buildCost); } } // if finish building @@ -108,7 +108,7 @@ void UIScriptProcess::CountDown() { } if (m_currentSpawnRemainingCost > 0) { m_currentSpawnRemainingCost -= spawnCost; - m_player->addCurrency(-1 * spawnCost); + m_gameObjectManager->addCurrency(-1 * spawnCost); } } // if finish spawning