From d97e124ef42bc9c888be2d2d59954198ac0e9ff9 Mon Sep 17 00:00:00 2001 From: jonylu7 Date: Fri, 24 May 2024 12:00:32 +0800 Subject: [PATCH] s --- CMakeLists.txt | 7 +++---- include/Mechanics/BuiltStructure.hpp | 4 ++-- src/{Enemy => AI}/Enemy.cpp | 0 src/Map/Map.cpp | 5 ++--- src/Scene/DefaultScene.cpp | 8 +++----- src/Scene/TutorialScene.cpp | 13 +++++++++++-- 6 files changed, 21 insertions(+), 16 deletions(-) rename src/{Enemy => AI}/Enemy.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c2aad42..9b249c7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,8 +84,7 @@ set(SRC_FILES ${SRC_DIR}/App.cpp - ${SRC_DIR}/Enemy/Enemy.cpp - + ${SRC_DIR}/AI/Enemy.cpp ${SRC_DIR}/AI/EnemyScripts.cpp ${SRC_DIR}/Structure/Structure.cpp @@ -225,8 +224,8 @@ set(INCLUDE_FILES ${INCLUDE_DIR}/Scene/SandBoxScene.hpp - ${INCLUDE_DIR}/Enemy/Enemy.hpp - ${INCLUDE_DIR}/Enemy/EnemyScripts.hpp + ${INCLUDE_DIR}/AI/Enemy.hpp + ${INCLUDE_DIR}/AI/EnemyScripts.hpp ${INCLUDE_DIR}/Core/Context.hpp ${INCLUDE_DIR}/Core/DebugMessageCallback.hpp diff --git a/include/Mechanics/BuiltStructure.hpp b/include/Mechanics/BuiltStructure.hpp index e1d0111f..ef748413 100644 --- a/include/Mechanics/BuiltStructure.hpp +++ b/include/Mechanics/BuiltStructure.hpp @@ -100,7 +100,7 @@ class BuiltStructure { glm::vec2 getPlayerBarrackSpawnCell() { return m_PlayerBarrackCell; } glm::vec2 getPlayerBarrackWayPointCell() { return m_PlayerWayPointCell; } - bool ifBarracksBuilt() { + bool ifBarrackBuilt() { for (auto i : m_BuiltStructure) { if (i->getID().getUnitType() == UnitType::BARRACKS) { return true; @@ -108,7 +108,7 @@ class BuiltStructure { } return false; } - bool ifPowerPlantsBuilt() { + bool ifPowerPlantBuilt() { for (auto i : m_BuiltStructure) { if (i->getID().getUnitType() == UnitType::POWER_PLANT) { return true; diff --git a/src/Enemy/Enemy.cpp b/src/AI/Enemy.cpp similarity index 100% rename from src/Enemy/Enemy.cpp rename to src/AI/Enemy.cpp diff --git a/src/Map/Map.cpp b/src/Map/Map.cpp index 9d8097cf..5a83d57b 100644 --- a/src/Map/Map.cpp +++ b/src/Map/Map.cpp @@ -38,9 +38,8 @@ std::shared_ptr MapClass::getTileByCellPosition(glm::vec2 position) { if (position.x > m_MapWdith - 1 || position.y > m_MapHeight - 1 || position.x < 0 || position.y < 0) { - std::cerr << "False Position Getting" << position.x << position.y - << std::endl; - return nullptr; + LOG_DEBUG("False Position Getting"); + return std::make_shared(); } return m_Map[position.x][position.y]; } diff --git a/src/Scene/DefaultScene.cpp b/src/Scene/DefaultScene.cpp index 3597b6ff..c19e067c 100644 --- a/src/Scene/DefaultScene.cpp +++ b/src/Scene/DefaultScene.cpp @@ -9,7 +9,7 @@ void DefaultScene::Start() { LOG_TRACE("Start"); // create map - m_Map->Init(98, 98); + m_Map->Init(60, 60); /* m_Map->getTileByCellPosition(glm::vec2(6, 5))->setWalkable(0); @@ -22,13 +22,11 @@ void DefaultScene::Start() { m_GameObjectManager->Start(m_Map); 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))); + m_SceneCamera->Start(MapUtil::CellCoordToGlobal(glm::vec2(-5, -5)), + MapUtil::CellCoordToGlobal(glm::vec2(70, 70))); } void DefaultScene::Update() { - // m_hunter->Update(); - // m_runner->Update(); m_GameObjectManager->Update(); diff --git a/src/Scene/TutorialScene.cpp b/src/Scene/TutorialScene.cpp index fca90702..b343977c 100644 --- a/src/Scene/TutorialScene.cpp +++ b/src/Scene/TutorialScene.cpp @@ -15,7 +15,8 @@ void TutorialScene::Start() { m_SceneCamera->Start(MapUtil::CellCoordToGlobal(glm::vec2(-10, -10)), MapUtil::CellCoordToGlobal(glm::vec2(100, 100))); -// m_EnemyScripts->Start(m_Enemy,m_GameObjectManager, m_EnemyObjectManager, m_Map); + // m_EnemyScripts->Start(m_Enemy,m_GameObjectManager, + // m_EnemyObjectManager, m_Map); m_GameObjectManager->spawn(m_Map, UnitType::INFANTRY, HouseType::MY, {5, 5}); @@ -136,7 +137,15 @@ void TutorialScene::stage2Update() { structCount++; } } - if (structCount >= 3 || + if (m_GameObjectManager->getStructureManager() + ->getStructureArray() + ->ifBarrackBuilt() && + m_GameObjectManager->getStructureManager() + ->getStructureArray() + ->ifPowerPlantBuilt() && + m_GameObjectManager->getStructureManager() + ->getStructureArray() + ->ifWarFactoryBuilt() || Util::Input::IsKeyPressed(Util::Keycode::DEBUG_KEY)) { // change next stage's text&prop here m_PlayerObjectivesText->SetDrawable(