diff --git a/assets/sprites/Task/AIWon.png b/assets/images/AIWon.png similarity index 100% rename from assets/sprites/Task/AIWon.png rename to assets/images/AIWon.png diff --git a/assets/sprites/Task/PlayerWon.png b/assets/images/PlayerWon.png similarity index 100% rename from assets/sprites/Task/PlayerWon.png rename to assets/images/PlayerWon.png diff --git a/include/Scene/MenuScene.hpp b/include/Scene/MenuScene.hpp index 2657ee9f..8d3f1901 100644 --- a/include/Scene/MenuScene.hpp +++ b/include/Scene/MenuScene.hpp @@ -33,8 +33,6 @@ class MenuScene : public Scene { m_BGM.Play(); } if (Util::Input::IsKeyPressed(Util::Keycode::K)) { - m_BGM.LoadMedia("../assets/BGM/Jimmy_Scott-Sycamore_Trees.mp3"); - m_BGM.Play(); } if (Util::Input::IsKeyPressed(Util::Keycode::M)) { m_CurrentMode = SceneMode::MAP; @@ -47,22 +45,26 @@ class MenuScene : public Scene { UIStatusType::UI_START) { m_MenuUI.getUIStatus()->setUIStatusType( UIStatusType::UI_DEFAULT); + m_BGM.Play(); m_CurrentMode = SceneMode::TUTORIAL; } if (Util::Input::IsKeyPressed(Util::Keycode::S)) { m_CurrentMode = SceneMode::SANDBOX; } - if (m_TutorialScene->getMissionAccomplishedUI() + } + if (m_CurrentMode == SceneMode::TUTORIAL && + m_TutorialScene->getMissionAccomplishedUI() ->getUIStatus() ->getUIStatusType() == UIStatusType::UI_CONTINUE) { - m_CurrentMode = SceneMode::SKIRMISH; - } + m_MenuUI.getUIStatus()->setUIStatusType(UIStatusType::UI_DEFAULT); + m_SandBoxScene->setStage(true); + m_CurrentMode = SceneMode::SANDBOX; } - if (m_CurrentMode==SceneMode::TUTORIAL&&m_TutorialScene->getMissionAccomplishedUI() - ->getUIStatus() - ->getUIStatusType() == UIStatusType::UI_CONTINUE) { - m_MenuUI.getUIStatus()->setUIStatusType( - UIStatusType::UI_DEFAULT); + + if (m_CurrentMode == SceneMode::SANDBOX && + m_SandBoxScene->getWonUI()->getUIStatus()->getUIStatusType() == + UIStatusType::UI_RESTART) { + m_SandBoxScene->Start(); m_SandBoxScene->setStage(true); m_CurrentMode = SceneMode::SANDBOX; } @@ -97,7 +99,9 @@ class MenuScene : public Scene { UIStatusType::UI_EXIT || m_TutorialScene->getMissionAccomplishedUI() ->getUIStatus() - ->getUIStatusType() == UIStatusType::UI_EXIT) { + ->getUIStatusType() == UIStatusType::UI_EXIT || + m_SandBoxScene->getWonUI()->getUIStatus()->getUIStatusType() == + UIStatusType::UI_EXIT) { return true; } return false; diff --git a/include/Scene/SandBoxScene.hpp b/include/Scene/SandBoxScene.hpp index 54bca284..57a2116d 100644 --- a/include/Scene/SandBoxScene.hpp +++ b/include/Scene/SandBoxScene.hpp @@ -7,13 +7,25 @@ #include "AI/AIScripts.hpp" #include "Cursor.hpp" #include "Scene.hpp" +#include "UI/WonUI.hpp" #include "Util/Prop.hpp" #include #define DEBUG_KEY P class SandBoxScene : public Scene { - enum class Stages { STAGE1, STAGE2, STAGE3, STAGE4, START, END ,FORMAL_START ,FORMAL_UPDATE ,PLAYER_WON ,AI_WON}; + enum class Stages { + STAGE1, + STAGE2, + STAGE3, + STAGE4, + START, + END, + FORMAL_START, + FORMAL_UPDATE, + PLAYER_WON, + AI_WON + }; public: SandBoxScene(){}; @@ -22,12 +34,18 @@ class SandBoxScene : public Scene { void Update() override; void stageStart(); void stageUpdate(); - void setStage(bool stage){ - if(stage){ + void setStage(bool stage) { + if (stage) { m_stage = Stages::FORMAL_START; } } + + Stages getStage() { return m_stage; } + + std::shared_ptr getWonUI() { return m_WUI; } + private: + std::shared_ptr m_WUI = std::make_shared(); SpriteSheet m_SpriteSheet; std::shared_ptr m_Cursor = std::make_shared(); Grid testGrid; diff --git a/include/UI/MissionFailedUI.hpp b/include/UI/WonUI.hpp similarity index 62% rename from include/UI/MissionFailedUI.hpp rename to include/UI/WonUI.hpp index 49adf84d..6d14c01f 100644 --- a/include/UI/MissionFailedUI.hpp +++ b/include/UI/WonUI.hpp @@ -2,16 +2,17 @@ // Created by 盧威任 on 5/25/24. // -#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_MISSIONACCOMPLISHED_HPP -#define PRACTICALTOOLSFORSIMPLEDESIGN_MISSIONACCOMPLISHED_HPP +#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_WUI_HPP +#define PRACTICALTOOLSFORSIMPLEDESIGN_WUI_HPP +#include "Button.hpp" #include "UI/UI.hpp" -class MissionFailedUI : public UI { +class WonUI : public UI { public: - MissionFailedUI() {} - ~MissionFailedUI() {} + WonUI() {} + ~WonUI() {} void Update() override { if (m_ContinueButton->ifClicked()) { - m_UIStatus->setUIStatusType(UIStatusType::UI_CONTINUE); + m_UIStatus->setUIStatusType(UIStatusType::UI_RESTART); } else if (m_ExitButton->ifClicked()) { m_UIStatus->setUIStatusType(UIStatusType::UI_EXIT); } @@ -20,16 +21,22 @@ class MissionFailedUI : public UI { void Draw() override { m_PausedImage->Draw( - Util::Transform({glm::vec2(0, 70), float(0), glm::vec2(1, 1)}), 1); + Util::Transform({glm::vec2(0, 70), float(0), glm::vec2(0.8, 0.8)}), + 1); m_ContinueButton->Draw(); m_ExitButton->Draw(); } + void setPausedImage(std::shared_ptr image) { + m_PausedImage = image; + } + private: std::shared_ptr m_PausedImage = - std::make_shared("../assets/images/paused.png"); + std::make_shared("../assets/images/PlayerWon.png"); + std::shared_ptr