Skip to content

Commit

Permalink
un
Browse files Browse the repository at this point in the history
  • Loading branch information
jonylu7 committed Jun 16, 2024
1 parent 2cba26b commit 8500298
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/Mechanics/UnitManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include "Mechanics/UnitManager.hpp"

void UnitManager::spawnToWayPoint(UnitType unit, HouseType house) {

if (!m_StructureManager->getStructureArray()->ifBarrackBuilt()) {
return;
}
switch (unit) {
case UnitType::INFANTRY: {
auto avatar = std::make_shared<Infantry>(house);
Expand Down Expand Up @@ -41,42 +43,44 @@ void UnitManager::spawn(UnitType unit, HouseType house, glm::vec2 cellPos) {
auto structure = std::make_shared<Barracks>(house);
auto globalPos = MapUtil::CellCoordToGlobal(cellPos);
structure->Start(globalPos);
m_StructureManager->getStructureArray()->buildNewStructure(
structure, true);
structure->setWaypointLocationByCellCoord({cellPos.x+2,cellPos.y+2});
m_StructureManager->getStructureArray()->buildNewStructure(structure,
true);
structure->setWaypointLocationByCellCoord(
{cellPos.x + 2, cellPos.y + 2});
break;
}
case UnitType::ORE_REF: {
auto structure = std::make_shared<OreRefinery>(house);
auto globalPos = MapUtil::CellCoordToGlobal(cellPos);
structure->Start(globalPos);
m_StructureManager->getStructureArray()->buildNewStructure(
structure, true);
m_StructureManager->getStructureArray()->buildNewStructure(structure,
true);
break;
}
case UnitType::POWER_PLANT: {
auto structure = std::make_shared<PowerPlants>(house);
auto globalPos = MapUtil::CellCoordToGlobal(cellPos);
structure->Start(globalPos);
m_StructureManager->getStructureArray()->buildNewStructure(
structure, true);
m_StructureManager->getStructureArray()->buildNewStructure(structure,
true);
break;
}
case UnitType::WAR_FACT: {
auto structure = std::make_shared<WarFactory>(house);
auto globalPos = MapUtil::CellCoordToGlobal(cellPos);
structure->Start(globalPos);
structure->setWaypointLocationByCellCoord({cellPos.x+2,cellPos.y-2});
m_StructureManager->getStructureArray()->buildNewStructure(
structure, true);
structure->setWaypointLocationByCellCoord(
{cellPos.x + 2, cellPos.y - 2});
m_StructureManager->getStructureArray()->buildNewStructure(structure,
true);
break;
}
case UnitType::ADV_POWER_PLANT: {
auto structure = std::make_shared<ADVPowerPlants>(house);
auto globalPos = MapUtil::CellCoordToGlobal(cellPos);
structure->Start(globalPos);
m_StructureManager->getStructureArray()->buildNewStructure(
structure, true);
m_StructureManager->getStructureArray()->buildNewStructure(structure,
true);
break;
}
case UnitType::INFANTRY: {
Expand All @@ -94,8 +98,8 @@ void UnitManager::spawn(UnitType unit, HouseType house, glm::vec2 cellPos) {
break;
}
}
if(unit!=UnitType::NONE){
addUnitConstructCount(unit,1);
if (unit != UnitType::NONE) {
addUnitConstructCount(unit, 1);
}
}

Expand Down

0 comments on commit 8500298

Please sign in to comment.