diff --git a/CMakeLists.txt b/CMakeLists.txt index 992da51c..907ae6e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,16 @@ set(SRC_FILES ${SRC_DIR}/Infantry.cpp ${SRC_DIR}/Grid.cpp + ${SRC_DIR}/WayPoint.cpp + ${SRC_DIR}/WayPointTool.cpp + ${SRC_DIR}/Structure/IWayPointStructure.cpp + + # ${SRC_DIR}/Structure/Buildings.cpp + ${SRC_DIR}/Structure/Barracks.cpp + ${SRC_DIR}/Structure/OreRefinery.cpp + ${SRC_DIR}/Structure/PowerPlants.cpp + ${SRC_DIR}/Structure/WarFactory.cpp + ${SRC_DIR}/Scene/DefaultScene.cpp ${SRC_DIR}/Camera.cpp ${SRC_DIR}/SpriteSheet.cpp @@ -129,6 +139,16 @@ set(INCLUDE_FILES ${INCLUDE_DIR}/Settings.hpp ${INCLUDE_DIR}/Camera.hpp + ${INCLUDE_DIR}/WayPoint.hpp + ${INCLUDE_DIR}/WayPointTool.h + ${INCLUDE_DIR}/Structure/IWayPointStructure.hpp + + #${INCLUDE_DIR}/Structure/Buildings.hpp + ${INCLUDE_DIR}/Structure/Barracks.hpp + ${INCLUDE_DIR}/Structure/OreRefinery.hpp + ${INCLUDE_DIR}/Structure/PowerPlants.hpp + ${INCLUDE_DIR}/Structure/WarFactory.hpp + ${INCLUDE_DIR}/imgui/imconfig.h ${INCLUDE_DIR}/imgui/imgui.h ${INCLUDE_DIR}/imgui/imgui_impl_sdl2.h diff --git a/assets/sprites/OreRefinery.png b/assets/sprites/OreRefinery.png new file mode 100644 index 00000000..ed4bfe78 Binary files /dev/null and b/assets/sprites/OreRefinery.png differ diff --git a/assets/sprites/PowerPlants.png b/assets/sprites/PowerPlants.png new file mode 100644 index 00000000..293f87d4 Binary files /dev/null and b/assets/sprites/PowerPlants.png differ diff --git a/assets/sprites/WarFactory.png b/assets/sprites/WarFactory.png new file mode 100644 index 00000000..9e0098c0 Binary files /dev/null and b/assets/sprites/WarFactory.png differ diff --git a/assets/sprites/flagB.png b/assets/sprites/flagB.png new file mode 100644 index 00000000..8f74f589 Binary files /dev/null and b/assets/sprites/flagB.png differ diff --git a/assets/sprites/flagO.png b/assets/sprites/flagO.png new file mode 100644 index 00000000..e91485b3 Binary files /dev/null and b/assets/sprites/flagO.png differ diff --git a/assets/sprites/flagW.png b/assets/sprites/flagW.png new file mode 100644 index 00000000..7b970567 Binary files /dev/null and b/assets/sprites/flagW.png differ diff --git a/include/Barracks.hpp b/include/Barracks.hpp index d8d7f297..d4ecec7c 100644 --- a/include/Barracks.hpp +++ b/include/Barracks.hpp @@ -1,7 +1,7 @@ // // Created by 盧威任 on 1/28/24. // - +/* #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_BARRACKS_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_BARRACKS_HPP @@ -15,3 +15,4 @@ class Barracks : public Util::GameObject { }; #endif // PRACTICALTOOLSFORSIMPLEDESIGN_CAPYBARA_HPP +*/ \ No newline at end of file diff --git a/include/Core/Drawable.hpp b/include/Core/Drawable.hpp index a74622e0..13657521 100644 --- a/include/Core/Drawable.hpp +++ b/include/Core/Drawable.hpp @@ -24,7 +24,7 @@ class Drawable { virtual ~Drawable() = default; virtual void Draw(const Util::Transform &transform, const float zIndex) = 0; - virtual glm::vec2 GetSize() const{}; + virtual glm::vec2 GetSize() const { return {0, 0}; }; virtual void DrawUsingCamera(const Util::Transform &transform, const float zIndex){}; }; diff --git a/include/Line.hpp b/include/Line.hpp index e9d1fba8..104bb59c 100644 --- a/include/Line.hpp +++ b/include/Line.hpp @@ -25,6 +25,9 @@ class Line { glm::vec2 getlineTo() { return lineTo; }; glm::vec3 getColor() { return color; }; + void setlineTo(glm::vec2 to){this->lineTo=to;}; + void setlineFrom(glm::vec2 from){this->lineFrom=from;}; + private: glm::vec2 lineFrom; glm::vec2 lineTo; diff --git a/include/Scene/DefaultScene.hpp b/include/Scene/DefaultScene.hpp index beadcd3b..a5afb459 100644 --- a/include/Scene/DefaultScene.hpp +++ b/include/Scene/DefaultScene.hpp @@ -23,6 +23,14 @@ #include "Util/Logger.hpp" #include "Util/Root.hpp" +#include "Structure/Barracks.hpp" +#include "Structure/IWayPointStructure.hpp" +#include "Structure/OreRefinery.hpp" +#include "Structure/PowerPlants.hpp" +#include "Structure/WarFactory.hpp" +#include "WayPoint.hpp" +#include "WayPointTool.h" + class DefaultScene { public: DefaultScene(){}; @@ -33,14 +41,16 @@ class DefaultScene { void End(){}; private: + /* std::vector> m_GameObjectList = { std::make_shared(), std::make_shared(), std::make_shared()}; - + */ Rectangle rect; + /* std::shared_ptr m_Structure = std::make_shared(); std::shared_ptr m_Inf = std::make_shared(); - + */ SpriteSheet m_SpriteSheet; CameraClass m_SceneCamera; @@ -53,6 +63,22 @@ class DefaultScene { std::vector m_OgMap; std::shared_ptr m_TileSetSpriteSheet = std::make_shared(); + + //Way Point Test Start--------------- + WayPointTool m_waypointTool; + Line m_Line; + bool clickCheck= false; + std::shared_ptr m_Barracks = std::make_shared(); + std::shared_ptr m_OreRefinery = std::make_shared(); + std::shared_ptr m_PowerPlants = std::make_shared(); + std::shared_ptr m_WarFactory = std::make_shared(); + + std::vector> m_IWayPointStructureList = { + m_Barracks,m_OreRefinery,m_WarFactory + }; + + std::shared_ptr m_WayPoint = std::make_shared(); + //Way Point Test End--------------- }; #endif // PRACTICALTOOLSFORSIMPLEDESIGN_DEFAULTSCENE_HPP diff --git a/include/Structure.hpp b/include/Structure.hpp index 6240f042..2b098e31 100644 --- a/include/Structure.hpp +++ b/include/Structure.hpp @@ -9,11 +9,18 @@ #include "Util/TransformUtils.hpp" #include "glm/glm.hpp" + class Structure : public Util::GameObject { public: enum class updateMode { Invisidable, Moveable, Fixed }; - Structure(){}; + Structure(): + electricPower(100.F),buildingTime(100.F), + buildingCost(100.F),buildingHp(100.F){}; + Structure(float electricPower,float buildingTime, + float buildingCost,float buildingHp): + electricPower(electricPower),buildingTime(buildingTime), + buildingCost(buildingCost),buildingHp(buildingHp){m_Transform.scale={0.2,0.2};}; ~Structure(){}; void Update(const Util::Transform &transform = Util::Transform()) override; @@ -21,11 +28,34 @@ class Structure : public Util::GameObject { void Start() override{}; updateMode GetCurrentUpdateMode() const { return m_CurrentState; }; void SetCurrentUpdateMode(updateMode mode) { m_CurrentState = mode; }; - void SetObjectLocation(glm::vec2 location) { ObjectLocation = location; } + void SetObjectLocation(glm::vec2 location); + glm::vec2 GetObjectLocation(){return this->ObjectLocation; } + //virtual glm::vec2 GetWayPointLocation(){return {0,0};}; + //void SetTransformation(glm::vec2 newTrans); + /* + void SetElectricPower(float electricPower); + void SetBuildingTime(float buildingTime); + void SetBuildingCost(float buildingCost); + void SetBuildingHp(float buildingHp); + void DecreaseElectricPower(float Power); + void IncreaseBuildingTime(float Time); + void DecreaseBuildingCost(float Cost); + */ + + void DecreaseHp(float Hp); + + float GetElectricPower(); + float GetBuildingTime(); + float GetBuildingCost(); + float GetBuildingHp(); private: updateMode m_CurrentState = updateMode::Invisidable; - glm::vec2 ObjectLocation; + glm::vec2 ObjectLocation={0,0}; + float electricPower; + float buildingTime; + float buildingCost; + float buildingHp; }; #endif // PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_HPP diff --git a/include/Structure/Barracks.hpp b/include/Structure/Barracks.hpp new file mode 100644 index 00000000..26dc03b3 --- /dev/null +++ b/include/Structure/Barracks.hpp @@ -0,0 +1,19 @@ +#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_BARRACKS_HPP +#define PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_BARRACKS_HPP + +#include "Structure\IWayPointStructure.hpp" +#include "Structure.hpp" +#define DEFAULT_POWER -20.F +#define DEFAULT_TIME 15.F +#define DEFAULT_COST 300.F +#define DEFAULT_HP 800.F + +class Barracks : public Structure,public IWayPointStructure{ +public: + Barracks(float electricPower=DEFAULT_POWER,float buildingTime=DEFAULT_POWER, + float buildingCost=DEFAULT_POWER,float buildingHp=DEFAULT_POWER): Structure(electricPower, buildingTime, buildingCost, buildingHp){}; + virtual glm::vec2 GetStructureLocation()override{return this->GetObjectLocation();}; + void Start() override{this->SetWayPointLocation({this->GetObjectLocation().x+20,this->GetObjectLocation().y+20});}; +}; + +#endif // PRACTICALTOOLSFORSIMPLEDESIGN_CAPYBARA_HPP diff --git a/include/Structure/Buildings.hpp b/include/Structure/Buildings.hpp new file mode 100644 index 00000000..fcf23639 --- /dev/null +++ b/include/Structure/Buildings.hpp @@ -0,0 +1,12 @@ +#include "Structure.hpp" + +#define DEFAULT_POWER 100.F +#define DEFAULT_TIME 100.F +#define DEFAULT_COST 100.F +#define DEFAULT_HP 1000.F + +class Building:public Structure{ +public: + Building(float electricPower=DEFAULT_POWER,float buildingTime=DEFAULT_TIME, + float buildingCost=DEFAULT_COST,float buildingHp=DEFAULT_HP): Structure(electricPower, buildingTime, buildingCost, buildingHp){}; +}; \ No newline at end of file diff --git a/include/Structure/IWayPointStructure.hpp b/include/Structure/IWayPointStructure.hpp new file mode 100644 index 00000000..cb179bfe --- /dev/null +++ b/include/Structure/IWayPointStructure.hpp @@ -0,0 +1,22 @@ +// +// Created by nudle on 2024/3/3. +// + +#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_IWAYPOINTSTRUCTURE_HPP +#define PRACTICALTOOLSFORSIMPLEDESIGN_IWAYPOINTSTRUCTURE_HPP +#include "Structure.hpp" +#include "Line.hpp" + +class IWayPointStructure{ +private: + glm::vec2 waypointLocation; +public: + virtual glm::vec2 GetWayPointLocation(){return this->waypointLocation;}; + void SetWayPointLocation(glm::vec2 newLocation){ + this->waypointLocation=newLocation; + }; + virtual glm::vec2 GetStructureLocation()=0; +}; + + +#endif // PRACTICALTOOLSFORSIMPLEDESIGN_IWAYPOINTSTRUCTURE_HPP diff --git a/include/Structure/OreRefinery.hpp b/include/Structure/OreRefinery.hpp new file mode 100644 index 00000000..c5bdbd2b --- /dev/null +++ b/include/Structure/OreRefinery.hpp @@ -0,0 +1,18 @@ +#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_OreRefinery_HPP +#define PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_OreRefinery_HPP + +#include "IWayPointStructure.hpp" +#include "Structure.hpp" +#define DEFAULT_POWER -30.F +#define DEFAULT_TIME 100.F +#define DEFAULT_COST 2000.F +#define DEFAULT_HP 900.F + +class OreRefinery:public Structure,public IWayPointStructure{ +public: + OreRefinery(float electricPower=DEFAULT_POWER,float buildingTime=DEFAULT_TIME, + float buildingCost=DEFAULT_COST,float buildingHp=DEFAULT_HP): Structure(electricPower, buildingTime, buildingCost, buildingHp){}; + virtual glm::vec2 GetStructureLocation()override{return this->GetObjectLocation();}; + void Start() override{this->SetWayPointLocation({this->GetObjectLocation().x+20,this->GetObjectLocation().y+20});}; +}; +#endif diff --git a/include/Structure/PowerPlants.hpp b/include/Structure/PowerPlants.hpp new file mode 100644 index 00000000..3294ceea --- /dev/null +++ b/include/Structure/PowerPlants.hpp @@ -0,0 +1,17 @@ +#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_PowerPlants_HPP +#define PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_PowerPlants_HPP + + +#include "Structure.hpp" +#define DEFAULT_POWER 100.F +#define DEFAULT_TIME 15.F +#define DEFAULT_COST 300.F +#define DEFAULT_HP 400.F + +class PowerPlants:public Structure{ +public: + PowerPlants(float electricPower=DEFAULT_POWER,float buildingTime=DEFAULT_TIME, + float buildingCost=DEFAULT_COST,float buildingHp=DEFAULT_HP): Structure(electricPower, buildingTime, buildingCost, buildingHp){}; +}; + +#endif diff --git a/include/Structure/WarFactory.hpp b/include/Structure/WarFactory.hpp new file mode 100644 index 00000000..c1c63e74 --- /dev/null +++ b/include/Structure/WarFactory.hpp @@ -0,0 +1,19 @@ +#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_WarFactory_HPP +#define PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_WarFactory_HPP + +#include "IWayPointStructure.hpp" +#include "Structure.hpp" +#define DEFAULT_POWER -30.F +#define DEFAULT_TIME 100.F +#define DEFAULT_COST 2000.F +#define DEFAULT_HP 1000.F + +class WarFactory : public Structure,public IWayPointStructure{ +public: + WarFactory(float electricPower=DEFAULT_POWER,float buildingTime=DEFAULT_POWER, + float buildingCost=DEFAULT_POWER,float buildingHp=DEFAULT_POWER): Structure(electricPower, buildingTime, buildingCost, buildingHp){}; + virtual glm::vec2 GetStructureLocation()override{return this->GetObjectLocation();}; + void Start() override{this->SetWayPointLocation({this->GetObjectLocation().x+20,this->GetObjectLocation().y+20});}; +}; + +#endif // PRACTICALTOOLSFORSIMPLEDESIGN_CAPYBARA_HPP diff --git a/include/WayPoint.hpp b/include/WayPoint.hpp new file mode 100644 index 00000000..9d290e2d --- /dev/null +++ b/include/WayPoint.hpp @@ -0,0 +1,22 @@ +// +// Created by nudle on 2024/3/3. +// + +#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINT_HPP +#define PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINT_HPP +#include "Util/GameObject.hpp" +#include "Util/TransformUtils.hpp" +#include "Util/Image.hpp" + +class WayPoint : public Util::GameObject{ +private: + glm::vec2 ObjectLocation; +public: + WayPoint():Util::GameObject(){m_Transform.scale={0.2,0.2};}; + void Update(const Util::Transform &transform = Util::Transform()) override; + + void Start() override{/*SetDrawable(std::make_unique("../assets/sprites/flag.png"));*/}; + void SetObjectLocation(glm::vec2 location) ; + glm::vec2 GetObjectLocation(){return this->ObjectLocation; } +}; +#endif // PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINT_HPP diff --git a/include/WayPointTool.h b/include/WayPointTool.h new file mode 100644 index 00000000..6220e4d5 --- /dev/null +++ b/include/WayPointTool.h @@ -0,0 +1,21 @@ +// +// Created by nudle on 2024/3/5. +// + +#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINTTOOL_H +#define PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINTTOOL_H + +#include +#include "glm/glm.hpp" +#include "Util/Input.hpp" +#include "Structure/IWayPointStructure.hpp" +class WayPointTool{ +private: +public: + WayPointTool(){}; + ~WayPointTool(){}; + + bool checkMous(glm::vec2 objPos,glm::vec2 mousPos); +}; + +#endif // PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINTTOOL_H diff --git a/include/pch.hpp b/include/pch.hpp index ef826975..d8dc7dd7 100644 --- a/include/pch.hpp +++ b/include/pch.hpp @@ -21,7 +21,7 @@ #include //suppose to be "GL/glut", yet GLUT/glut on mac -#include +//#include #include #include diff --git a/src/Barracks.cpp b/src/Barracks.cpp index b9670aa4..f7a85710 100644 --- a/src/Barracks.cpp +++ b/src/Barracks.cpp @@ -1,6 +1,7 @@ // // Created by 盧威任 on 1/28/24. // +/* #include "Barracks.hpp" #include "Util/GameObject.hpp" #include "Util/Image.hpp" @@ -36,4 +37,4 @@ void Barracks::Update([[maybe_unused]] const Util::Transform &transform) { m_Drawable->Draw(m_Transform, m_ZIndex); // LOG_DEBUG("GIRA: x: {}, y: {}", pos.x, pos.y); -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/src/Scene/DefaultScene.cpp b/src/Scene/DefaultScene.cpp index fa7967c4..3e3a5a5f 100644 --- a/src/Scene/DefaultScene.cpp +++ b/src/Scene/DefaultScene.cpp @@ -5,6 +5,7 @@ void DefaultScene::Start() { LOG_TRACE("Start"); + /* m_GameObjectList[0]->SetDrawable( std::make_unique("../assets/sprites/Raccoon3.jpg")); m_GameObjectList[0]->SetZIndex(10); @@ -27,7 +28,7 @@ void DefaultScene::Start() { } m_Renderer.AddChild(m_Structure); - + */ // init map m_TileSetSpriteSheet->Start("../assets/sprites/TILESET_Field.png", 64, 64, 20, 0); @@ -46,34 +47,111 @@ void DefaultScene::Start() { m_Map.Init(maps, m_TileSetSpriteSheet, 5, 2); m_UI.Start(); + + //Way Point Test Start--------------- + m_Barracks->SetDrawable(std::make_unique("../assets/sprites/barracks.png")); + m_Barracks->SetObjectLocation({-80,-60}); + m_Barracks->Start(); + m_Barracks->SetVisible(true); + m_Renderer.AddChild(m_Barracks); + + + m_OreRefinery->SetDrawable(std::make_unique("../assets/sprites/OreRefinery.png")); + m_OreRefinery->SetObjectLocation({-60,-60}); + m_OreRefinery->Start(); + m_OreRefinery->SetVisible(true); + m_Renderer.AddChild(m_OreRefinery); + + + m_PowerPlants->SetDrawable(std::make_unique("../assets/sprites/PowerPlants.png")); + m_PowerPlants->SetObjectLocation({-80,-80}); + m_PowerPlants->Start(); + m_PowerPlants->SetVisible(true); + m_Renderer.AddChild(m_PowerPlants); + + m_WarFactory->SetDrawable(std::make_unique("../assets/sprites/WarFactory.png")); + m_WarFactory->SetObjectLocation({-60,-80}); + m_WarFactory->Start(); + m_WarFactory->SetVisible(true); + m_Renderer.AddChild(m_WarFactory); + + + m_WayPoint->SetDrawable(std::make_unique("../assets/sprites/flagB.png")); + m_WayPoint->SetObjectLocation({-70,-70}); + m_WayPoint->SetVisible(false); + m_Renderer.AddChild(m_WayPoint); + //Way Point Test End--------------- } void DefaultScene::Update() { m_Map.Draw(); - + /* m_Structure->SetCurrentUpdateMode(Structure::updateMode::Fixed); m_Structure->Update(); - + */ if (Util::Input::IsKeyPressed(Util::Keycode::END)) { glm::vec2 ogLBlocation = Util::Input::GetCursorPosition(); - + /* if (m_Structure->GetCurrentUpdateMode() == Structure::updateMode::Moveable) { m_Structure->SetObjectLocation(ogLBlocation); m_Structure->SetCurrentUpdateMode(Structure::updateMode::Fixed); LOG_DEBUG("Fixed"); - } + }*/ } m_SceneCamera.Update(); - m_Inf->Update(); + //m_Inf->Update(); rect.Update(); m_Renderer.Update(); - + /* for (auto i : m_GameObjectList) { i->Update(); - } + }*/ m_UI.Update(); + + //Way Point Test Start----------------------------------------------------- + /* + if (Util::Input::IsKeyDown(Util::Keycode::MOUSE_LB)) { + for(auto i :m_IWayPointStructureList){ + if(m_waypointTool.checkMous(i->GetStructureLocation(),Util::Input::GetCursorPosition())){ + m_WayPoint->SetObjectLocation(i->GetWayPointLocation()); + m_WayPoint->SetVisible(true); + clickCheck= false; + break; + } + } + }*/ + if (Util::Input::IsKeyDown(Util::Keycode::P)) { + clickCheck=!clickCheck; + } + + if(clickCheck){ + if (Util::Input::IsKeyDown(Util::Keycode::NUM_1)) { + m_WayPoint->SetObjectLocation(m_IWayPointStructureList[0]->GetWayPointLocation()); + m_Line.setlineFrom(m_IWayPointStructureList[0]->GetStructureLocation()); + m_Line.setlineTo(m_IWayPointStructureList[0]->GetWayPointLocation()); + m_WayPoint->SetDrawable(std::make_unique("../assets/sprites/flagB.png")); + m_WayPoint->SetVisible(true); + }else + if (Util::Input::IsKeyDown(Util::Keycode::NUM_2)) { + m_WayPoint->SetObjectLocation(m_IWayPointStructureList[1]->GetWayPointLocation()); + m_Line.setlineFrom(m_IWayPointStructureList[1]->GetStructureLocation()); + m_Line.setlineTo(m_IWayPointStructureList[1]->GetWayPointLocation()); + m_WayPoint->SetDrawable(std::make_unique("../assets/sprites/flagO.png")); + m_WayPoint->SetVisible(true); + }else + if (Util::Input::IsKeyDown(Util::Keycode::NUM_3)) { + m_WayPoint->SetObjectLocation(m_IWayPointStructureList[2]->GetWayPointLocation()); + m_Line.setlineFrom(m_IWayPointStructureList[2]->GetStructureLocation()); + m_Line.setlineTo(m_IWayPointStructureList[2]->GetWayPointLocation()); + m_WayPoint->SetDrawable(std::make_unique("../assets/sprites/flagW.png")); + m_WayPoint->SetVisible(true); + } + }else{ + m_WayPoint->SetVisible(false); + } + //Way Point Test End------------------------------------------------------- } diff --git a/src/Structure.cpp b/src/Structure.cpp index e65d1217..b08f2d0e 100644 --- a/src/Structure.cpp +++ b/src/Structure.cpp @@ -33,3 +33,26 @@ void Structure::Update([[maybe_unused]] const Util::Transform &transsform) { // LOG_DEBUG("GIRA: x: {}, y: {}", pos.x, pos.y); } +/*void Structure::SetTransformation(glm::vec2 newTrans) { + this->m_Transform=newTrans; +}*/ +void Structure::DecreaseHp(float Hp){ + this->buildingHp-=Hp; +} +float Structure::GetElectricPower(){ + return this->electricPower; +} +float Structure::GetBuildingTime(){ + return this->buildingTime; +} +float Structure::GetBuildingCost(){ + return this->buildingCost; +} +float Structure::GetBuildingHp(){ + return this->buildingHp; +} +void Structure::SetObjectLocation(glm::vec2 location) { + ObjectLocation = location; + m_Transform.translation=ObjectLocation; +} + diff --git a/src/Structure/Barracks.cpp b/src/Structure/Barracks.cpp new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/Structure/Barracks.cpp @@ -0,0 +1 @@ + diff --git a/src/Structure/Buildings.cpp b/src/Structure/Buildings.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/Structure/IWayPointStructure.cpp b/src/Structure/IWayPointStructure.cpp new file mode 100644 index 00000000..b8ab01e3 --- /dev/null +++ b/src/Structure/IWayPointStructure.cpp @@ -0,0 +1,6 @@ +// +// Created by nudle on 2024/3/3. +// +#include "Structure/IWayPointStructure.hpp" + + diff --git a/src/Structure/OreRefinery.cpp b/src/Structure/OreRefinery.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/Structure/PowerPlants.cpp b/src/Structure/PowerPlants.cpp new file mode 100644 index 00000000..139597f9 --- /dev/null +++ b/src/Structure/PowerPlants.cpp @@ -0,0 +1,2 @@ + + diff --git a/src/Structure/WarFactory.cpp b/src/Structure/WarFactory.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/WayPoint.cpp b/src/WayPoint.cpp new file mode 100644 index 00000000..3761d402 --- /dev/null +++ b/src/WayPoint.cpp @@ -0,0 +1,18 @@ +// +// Created by nudle on 2024/3/4. +// +#include "WayPoint.hpp" + +void WayPoint::Update([[maybe_unused]] const Util::Transform &transsform) { + static glm::vec2 dir = {1, 0.5}; + + auto &pos = m_Transform.translation; + + + m_Transform.scale = {0.5, 0.5}; + +} +void WayPoint::SetObjectLocation(glm::vec2 location){ + ObjectLocation=location; + m_Transform.translation=ObjectLocation; +} \ No newline at end of file diff --git a/src/WayPointTool.cpp b/src/WayPointTool.cpp new file mode 100644 index 00000000..193760bc --- /dev/null +++ b/src/WayPointTool.cpp @@ -0,0 +1,10 @@ +// +// Created by nudle on 2024/3/5. +// + +#include "WayPointTool.h" +#define SIZE 20 + +bool WayPointTool::checkMous(glm::vec2 objPos, glm::vec2 mousPos) { + return (mousPos.xobjPos.x-SIZE) && (mousPos.y>objPos.y-SIZE) && (mousPos.y