Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jonylu7 committed May 24, 2024
1 parent dbd88e1 commit 1efef03
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 151 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ set(SRC_FILES

${SRC_DIR}/Scene/MapScene.cpp
${SRC_DIR}/Scene/TutorialScene.cpp
${SRC_DIR}/Scene/SandboxScene.cpp
${SRC_DIR}/Scene/SandBoxScene.cpp

${SRC_DIR}/Avatar/Runner.cpp
${SRC_DIR}/Avatar/Avatar.cpp
Expand Down Expand Up @@ -222,7 +222,7 @@ set(INCLUDE_FILES

${INCLUDE_DIR}/Scene/Scene.hpp
${INCLUDE_DIR}/Scene/TutorialScene.hpp
${INCLUDE_DIR}/Scene/SandboxScene.hpp
${INCLUDE_DIR}/Scene/SandBoxScene.hpp


${INCLUDE_DIR}/Enemy/Enemy.hpp
Expand Down
16 changes: 9 additions & 7 deletions include/Mechanics/BuiltStructure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,23 @@ class BuiltStructure {
void updateAvatarSpawnLocation() {
for (auto i : m_BuiltStructure) {
if (std::dynamic_pointer_cast<Barracks>(i)) {
m_PlayerBarrackCell = MapUtil::GlobalCoordToCellCoord(i->GetObjectLocation());
m_PlayerWayPointCell =MapUtil::GlobalCoordToCellCoord(
m_PlayerBarrackCell =
MapUtil::GlobalCoordToCellCoord(i->GetObjectLocation());
m_PlayerWayPointCell = MapUtil::GlobalCoordToCellCoord(
std::dynamic_pointer_cast<Barracks>(i)
->GetWayPointLocation());
}
}
}

glm::vec2 getPlayerBarrackCell() { return {m_PlayerBarrackCell.x-1,m_PlayerBarrackCell.y-1}; }
glm::vec2 getPlayerWayPointCell() { return m_PlayerWayPointCell; }
glm::vec2 getPlayerBarrackCell() {
return {m_PlayerBarrackCell.x - 1, m_PlayerBarrackCell.y - 1};
}
// glm::vec2 getPlayerWayPointCell() { return m_PlayerWayPointCell; }

public:
glm::vec2 getEnemyBarrackCell() { return m_EnemyBarrackCell; }
glm::vec2 getEnemyWayPointCell() { return m_EnemyWayPointCell; }
// glm::vec2 getEnemyBarrackCell() { return m_EnemyBarrackCell; }
// glm::vec2 getEnemyWayPointCell() { return m_EnemyWayPointCell; }
glm::vec2 getPlayerBarrackSpawnCell() { return m_PlayerBarrackCell; }
glm::vec2 getPlayerBarrackWayPointCell() { return m_PlayerWayPointCell; }

Expand Down Expand Up @@ -122,7 +125,6 @@ class BuiltStructure {
return false;
}


private:
std::shared_ptr<MapClass> m_Map = std::make_shared<MapClass>();
std::vector<std::shared_ptr<Structure>> m_BuiltStructure;
Expand Down
34 changes: 17 additions & 17 deletions include/Mechanics/UnitManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class UnitManager : public Player {
switch (unit) {
case UnitType::INFANTRY: {
auto avatar = std::make_shared<Infantry>(house);
m_StructureManager->getStructureArray()->updateAvatarSpawnLocation();
m_StructureManager->getStructureArray()
->updateAvatarSpawnLocation();
if (m_StructureManager->getStructureArray()
->getPlayerBarrackCell()
.x == -1) {
Expand All @@ -88,13 +89,15 @@ class UnitManager : public Player {
avatar->Start(m_StructureManager->getStructureArray()
->getPlayerBarrackCell());

m_AvatarManager->assignMoveOrderToAvatar(avatar,{m_StructureManager->getStructureArray()->getPlayerWayPointCell()});
m_AvatarManager->assignMoveOrderToAvatar(
avatar, {m_StructureManager->getStructureArray()
->getPlayerBarrackWayPointCell()});
// assign order
m_AvatarManager->assignMoveOrderToAvatar(
avatar, m_StructureManager->getStructureArray()
->getPlayerWayPointCell());
->getPlayerBarrackWayPointCell());
m_AvatarManager->AppendAvatar(avatar);
m_troopSize+=1;
m_troopSize += 1;
}

default: {
Expand All @@ -111,7 +114,8 @@ class UnitManager : public Player {
auto structure = std::make_shared<Barracks>(house);
auto globalPos = MapUtil::CellCoordToGlobal(cellPos);
structure->Start(globalPos);
structure->SetWayPointLocationByCellCoord({cellPos.x+2,cellPos.y-2});
structure->SetWayPointLocationByCellCoord(
{cellPos.x + 2, cellPos.y - 2});
m_StructureManager->getStructureArray()->buildNewStructure(
structure, true);
break;
Expand All @@ -136,7 +140,8 @@ class UnitManager : public Player {
auto structure = std::make_shared<WarFactory>(house);
auto globalPos = MapUtil::CellCoordToGlobal(cellPos);
structure->Start(globalPos);
structure->SetWayPointLocationByCellCoord({cellPos.x+2,cellPos.y-2});
structure->SetWayPointLocationByCellCoord(
{cellPos.x + 2, cellPos.y - 2});
m_StructureManager->getStructureArray()->buildNewStructure(
structure, true);
break;
Expand All @@ -153,9 +158,10 @@ class UnitManager : public Player {
auto avatar = std::make_shared<Infantry>(house);
avatar->Start(cellPos);
// avatar ->setNewDestination(cellPos);
m_AvatarManager->assignMoveOrderToAvatar(avatar,{cellPos.x+1,cellPos.y+1});
m_AvatarManager->assignMoveOrderToAvatar(
avatar, {cellPos.x + 1, cellPos.y + 1});
m_AvatarManager->AppendAvatar(avatar);
m_troopSize+=1;
m_troopSize += 1;
break;
}
case UnitType::NONE: {
Expand All @@ -172,15 +178,9 @@ class UnitManager : public Player {
void addUnitConstructCount(UnitType type, int value) {
unitCount[type] += value;
}
int getUnitConstructCount(UnitType type){
return unitCount[type];
}
int getAvatarCount(){
return unitCount[UnitType::INFANTRY];
}
void addAvatarCount(UnitType type,int value){
unitCount[type] += value;
}
int getUnitConstructCount(UnitType type) { return unitCount[type]; }
int getAvatarCount() { return unitCount[UnitType::INFANTRY]; }
void addAvatarCount(UnitType type, int value) { unitCount[type] += value; }

private:
std::unordered_map<UnitType, unsigned int> unitCount;
Expand Down
5 changes: 2 additions & 3 deletions include/Scene/SandBoxScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
#include "AI/EnemyScripts.hpp"
#include "Cursor.hpp"
#include "Scene.hpp"
#include "Task.hpp"
#include "Util/Prop.hpp"
#include <glm/glm.hpp>

#define DEBUG_KEY P


class SandBoxScene : public Scene {
enum class Stages { STAGE1, STAGE2, STAGE3, STAGE4 ,START ,END};
enum class Stages { STAGE1, STAGE2, STAGE3, STAGE4, START, END };

public:
SandBoxScene(){};
~SandBoxScene(){};
Expand Down
Loading

0 comments on commit 1efef03

Please sign in to comment.