From 7f5b1258392219b26705b91119d3b696efbe2e3e Mon Sep 17 00:00:00 2001 From: quinndu0 <160988691+ntut-Tu@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:26:00 +0800 Subject: [PATCH] formal sandbox fix --- src/AI/AIScripts.cpp | 15 +++++++++------ src/Scene/SandBoxScene.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/AI/AIScripts.cpp b/src/AI/AIScripts.cpp index 8935d6e..2d9641c 100644 --- a/src/AI/AIScripts.cpp +++ b/src/AI/AIScripts.cpp @@ -128,6 +128,9 @@ void AIScript::setCost(float cost, SpawnMode spawnMode) { void AIScript::buildBasic() { if (m_selectedBuildingType != UnitType::NONE) { + if(m_selectedBuildingType != UnitType::ORE_REF && m_EnemyObjectManager->getTotalCurrency() > 2000+100){ + spawnUnit(); + } return; } if (m_EnemyObjectManager->getUnitConstructCount(UnitType::POWER_PLANT) < @@ -190,6 +193,12 @@ void AIScript::UpdateSpawnScript(SpawnMode spawnMode) { if (m_selectedBuildingType == UnitType::NONE) { return; } + if (constructCountX > 10) { + constructCountY += 5; + constructCountX = 0; + } else { + constructCountX += 5; + } m_EnemyObjectManager->spawn( m_selectedBuildingType, HouseType::ENEMY, {m_baseCell.x + constructCountX, m_baseCell.y + constructCountY}); @@ -198,12 +207,6 @@ void AIScript::UpdateSpawnScript(SpawnMode spawnMode) { setCDTime(0.f, SpawnMode::BUILDINGS); m_selectedBuildingType = UnitType::NONE; - if (constructCountX > 10) { - constructCountY += 5; - constructCountX = 0; - } else { - constructCountX += 5; - } } if (spawnMode == SpawnMode::AVATAR) { if (m_selectedAvatarType == UnitType::NONE) { diff --git a/src/Scene/SandBoxScene.cpp b/src/Scene/SandBoxScene.cpp index 90c79fb..86e4ca2 100644 --- a/src/Scene/SandBoxScene.cpp +++ b/src/Scene/SandBoxScene.cpp @@ -55,7 +55,7 @@ void SandBoxScene::Update() { m_UI->getUnitTypeReadyToBeSpawned(), HouseType::MY); } if(m_stage==Stages::FORMAL_UPDATE){ - if(m_GameObjectManager->getAvatarManager()->getAvatarArray().empty()&&m_GameObjectManager->getStructureManager()->getStructureArray()->getBuiltStructureArray().empty()){ + if(m_GameObjectManager->getStructureManager()->getStructureArray()->getBuiltStructureArray().empty()){ m_stage=Stages::AI_WON; m_Text->SetDrawable( std::make_unique("../assets/sprites/Task/AIWon.png")); @@ -66,7 +66,7 @@ void SandBoxScene::Update() { trans.scale = {0.7, 0.7}; m_Text->SetTransform(trans); } - if(m_EnemyObjectManager->getAvatarManager()->getAvatarArray().empty()&&m_EnemyObjectManager->getStructureManager()->getStructureArray()->getBuiltStructureArray().empty()){ + if(m_EnemyObjectManager->getStructureManager()->getStructureArray()->getBuiltStructureArray().empty()){ m_stage=Stages::PLAYER_WON; m_Text->SetDrawable( std::make_unique("../assets/sprites/Task/PlayerWon.png")); @@ -132,8 +132,8 @@ void SandBoxScene::stageStart() { break; } case Stages::FORMAL_START:{ - m_GameObjectManager->spawn(UnitType::INFANTRY, HouseType::MY, {7, 9}); - m_EnemyObjectManager->spawn(UnitType::INFANTRY, HouseType::ENEMY, {36, 36}); + m_GameObjectManager->spawn(UnitType::POWER_PLANT, HouseType::MY, {7, 9}); + m_EnemyObjectManager->spawn(UnitType::POWER_PLANT, HouseType::ENEMY, {20, 30}); break; } }