Skip to content

Commit

Permalink
Merge pull request #95 from ntut-Tu/main
Browse files Browse the repository at this point in the history
sandbox update
  • Loading branch information
jonylu7 authored Jun 14, 2024
2 parents 3641f01 + e63c78e commit 0f01b52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/AI/AIScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) <
Expand Down Expand Up @@ -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});
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/Scene/SandBoxScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void SandBoxScene::Update() {
m_GameObjectManager->spawnToWayPoint(
m_UI->getUnitTypeReadyToBeSpawned(), HouseType::MY);
}

if (m_stage == Stages::FORMAL_UPDATE) {
if (m_GameObjectManager->getAvatarManager()->getAvatarArray().empty() &&
m_GameObjectManager->getStructureManager()
Expand Down Expand Up @@ -134,6 +135,7 @@ void SandBoxScene::stageStart() {
m_stage = Stages::END;
break;
}

case Stages::FORMAL_START: {
m_GameObjectManager->spawn(UnitType::INFANTRY, HouseType::MY, {7, 9});
m_EnemyObjectManager->spawn(UnitType::INFANTRY, HouseType::ENEMY,
Expand Down

0 comments on commit 0f01b52

Please sign in to comment.