diff --git a/include/Mechanics/UnitManager.hpp b/include/Mechanics/UnitManager.hpp index f55187a3..701d88d3 100644 --- a/include/Mechanics/UnitManager.hpp +++ b/include/Mechanics/UnitManager.hpp @@ -22,6 +22,7 @@ #include + class UnitManager : public Player { public: UnitManager() {} @@ -65,8 +66,13 @@ class UnitManager : public Player { return m_AvatarManager->getAvatarSize();; } + void setCheatMode(bool cheat){ + m_cheat=cheat; + } - + bool getCheatMode(){ + return m_cheat; + } private: @@ -80,6 +86,7 @@ class UnitManager : public Player { std::shared_ptr m_Map = std::make_shared(); float m_mainDeltaTime = 0; Util::Time m_Time; + bool m_cheat=false; }; #endif // PRACTICALTOOLSFORSIMPLEDESIGN_UNITMANAGER_HPP diff --git a/src/UI/IngameUI.cpp b/src/UI/IngameUI.cpp index de45751f..d6ae650b 100644 --- a/src/UI/IngameUI.cpp +++ b/src/UI/IngameUI.cpp @@ -59,9 +59,11 @@ void IngamUI::ShowHeaderSection() { if (ImGui::Button("Cheat Mode On")) { // TODO inf money, speed build time and cant player unit health cant be // damaged + m_gameObjectManager->setCheatMode(true); } if (ImGui::Button("Cheat Mode off")) { // TODO + m_gameObjectManager->setCheatMode(false); } ImGui::PopFont(); diff --git a/src/UI/UIScriptProcess.cpp b/src/UI/UIScriptProcess.cpp index a932620b..b232485c 100644 --- a/src/UI/UIScriptProcess.cpp +++ b/src/UI/UIScriptProcess.cpp @@ -171,21 +171,26 @@ void UIScriptProcess::Update(bool queueContinue) { } float UIScriptProcess::GetStructureTime(UnitType type) { + float returnValue = 0.f; if (type == UnitType::POWER_PLANT) { - return std::make_shared()->getBuildingTime(); + returnValue = std::make_shared()->getBuildingTime(); } if (type == UnitType::BARRACKS) { - return std::make_shared()->getBuildingTime(); + returnValue = std::make_shared()->getBuildingTime(); } if (type == UnitType::ORE_REF) { - return std::make_shared()->getBuildingTime(); + returnValue = std::make_shared()->getBuildingTime(); } if (type == UnitType::WAR_FACT) { - return std::make_shared()->getBuildingTime(); + returnValue = std::make_shared()->getBuildingTime(); } if (type == UnitType::ADV_POWER_PLANT) { - return std::make_shared()->getBuildingTime(); + returnValue = std::make_shared()->getBuildingTime(); } + if(m_gameObjectManager->getCheatMode()){ + returnValue *=0.01; + } + return returnValue; } void UIScriptProcess::SetIfFinished(UnitType type, bool value) { @@ -218,6 +223,9 @@ void UIScriptProcess::AddToSpawnQueue(UnitType type) { float UIScriptProcess::GetSpawnTime(UnitType type) { switch (type) { case UnitType::INFANTRY: { + if(m_gameObjectManager->getCheatMode()){ + return 0.1F; + } return 5.F; } } @@ -247,22 +255,33 @@ float UIScriptProcess::GetSpawnCountDownTime() { } } int UIScriptProcess::GetObjCost(UnitType type) { + int returnValue = 0; switch (type) { case UnitType::BARRACKS: - return std::make_shared()->getBuildingCost(); + returnValue = std::make_shared()->getBuildingCost(); + break; case UnitType::ORE_REF: - return std::make_shared()->getBuildingCost(); + returnValue = std::make_shared()->getBuildingCost(); + break; case UnitType::POWER_PLANT: - return std::make_shared()->getBuildingCost(); + returnValue = std::make_shared()->getBuildingCost(); + break; case UnitType::WAR_FACT: - return std::make_shared()->getBuildingCost(); + returnValue = std::make_shared()->getBuildingCost(); + break; case UnitType::ADV_POWER_PLANT: - return std::make_shared()->getBuildingCost(); + returnValue = std::make_shared()->getBuildingCost(); + break; case UnitType::INFANTRY: - return 100; + returnValue = 100; + break; default: // Handle the case when type doesn't match any of the options // For example, you might throw an exception or set a default value break; } + if(m_gameObjectManager->getCheatMode()){ + return 1; + } + return returnValue; }