diff --git a/assets/sprites/.DS_Store b/assets/sprites/.DS_Store index ea923d77..4cd0e843 100644 Binary files a/assets/sprites/.DS_Store and b/assets/sprites/.DS_Store differ diff --git a/assets/sprites/mech.png b/assets/sprites/mech.png deleted file mode 100644 index 1c49b5ce..00000000 Binary files a/assets/sprites/mech.png and /dev/null differ diff --git a/assets/sprites/mech_dead.png b/assets/sprites/mech_dead.png new file mode 100644 index 00000000..fe0853cd Binary files /dev/null and b/assets/sprites/mech_dead.png differ diff --git a/assets/sprites/mech_open_fire.png b/assets/sprites/mech_open_fire.png new file mode 100644 index 00000000..d66eefba Binary files /dev/null and b/assets/sprites/mech_open_fire.png differ diff --git a/assets/sprites/mech_taken_damage.png b/assets/sprites/mech_taken_damage.png new file mode 100644 index 00000000..96ffd139 Binary files /dev/null and b/assets/sprites/mech_taken_damage.png differ diff --git a/include/Avatar/AttackAndDamage.hpp b/include/Avatar/AttackAndDamage.hpp index cfb9dd9e..f98daba6 100644 --- a/include/Avatar/AttackAndDamage.hpp +++ b/include/Avatar/AttackAndDamage.hpp @@ -16,10 +16,10 @@ class AttackAndDamage { void damageTargetWithWeapon(std::shared_ptr target, std::shared_ptr weapon) { auto targethealth = target->getHealth(); - targethealth->addHP(-1 * (100 - targethealth->getArmorRate()) * - (1 / 100) * m_Weapon->getSoftAttack() + - targethealth->getArmorRate() * (1 / 100) * - m_Weapon->getHardAttack()); + auto damage = + ((1 - targethealth->getArmorRate()) * m_Weapon->getSoftAttack()) + + (targethealth->getArmorRate() * m_Weapon->getHardAttack()); + targethealth->addHP(-1 * damage); } void openFireToTarget(std::shared_ptr target) { diff --git a/include/Avatar/Avatar.hpp b/include/Avatar/Avatar.hpp index b5a12e47..6c68c95c 100644 --- a/include/Avatar/Avatar.hpp +++ b/include/Avatar/Avatar.hpp @@ -15,30 +15,24 @@ #include "Selectable.hpp" #include "Util/Image.hpp" -class Avatar : public Moving, - public AttackAndDamage, - public Util::GameObject, - public Selectable, - public AvatarOrder, - public IHealthable { +class Avatar : public Util::GameObject, public Selectable, public IHealthable { public: Avatar(){}; Avatar(UnitType unit, HouseType house) - : m_ID(GameObjectID(UnitType::NONE, HouseType::MY)){}; + : m_ID(GameObjectID(UnitType::NONE, house)){}; ~Avatar() override{}; virtual void Start(glm::vec2 spawnlocationcell); - void noOrderUpdate(); + void noorderUpdate(); void spawnedUpdate(); - void finishedmovingUpdate(); void moveUpdate(); void deadUpdate(); void attackUpdate(); float getDistance(glm::vec2 cell) { - return sqrt(pow(cell.x - getCurrentCell().x, 2) + - pow(cell.y - getCurrentCell().y, 2)); + return sqrt(pow(cell.x - m_Moving->getCurrentCell().x, 2) + + pow(cell.y - m_Moving->getCurrentCell().y, 2)); } void setSpriteSheet() { @@ -61,25 +55,35 @@ class Avatar : public Moving, "../assets/sprites/mech_single.png"); } + virtual void Update() override; + + void DrawAvatar(); + +public: GameObjectID getID() { return m_ID; } - virtual void Update() override; + std::shared_ptr getAttackAndDamage() { + return m_AttackAndDamage; + } + std::shared_ptr getMoving() { return m_Moving; } + std::shared_ptr getAvatarOrder() { return m_Order; } std::shared_ptr getHealth() override { return m_Health; } + void setHealth(std::shared_ptr health) override { m_Health = health; } - std::shared_ptr getAttackAndDamager() { - return m_AttackAndDamage; - } - protected: std::shared_ptr m_AvatarSpriteSheet = std::make_shared(); std::shared_ptr m_SpriteSheetAnimation = std::make_shared(); + // order + std::shared_ptr m_Order = std::make_shared(); + // moving + std::shared_ptr m_Moving = std::make_shared(); // health std::shared_ptr m_Health = std::make_shared(); // attack and damage diff --git a/include/Avatar/Infantry.hpp b/include/Avatar/Infantry.hpp index bc84e8cb..c1b7bf7f 100644 --- a/include/Avatar/Infantry.hpp +++ b/include/Avatar/Infantry.hpp @@ -9,15 +9,15 @@ class Infantry : public Avatar { public: Infantry() : Avatar() { - setMovementSpeed(4), + getMoving()->setMovementSpeed(4), m_Health = std::make_shared( std::make_shared(LivingStatus::NOT_BORN_YET), 100, 0.5); } Infantry(HouseType house) - : Avatar(UnitType::INFANTRY,house){ + : Avatar(UnitType::INFANTRY, house) { // setHp(50); - setMovementSpeed(4); + getMoving()->setMovementSpeed(4); } private: diff --git a/include/Avatar/Moving.hpp b/include/Avatar/Moving.hpp index 8db0fd5e..e4585202 100644 --- a/include/Avatar/Moving.hpp +++ b/include/Avatar/Moving.hpp @@ -20,7 +20,6 @@ class Moving { std::vector m_lineVector; glm::vec2 m_CurrentLocation; - glm::vec2 m_DestinationLocation; MoveDirection m_CurrentDir = MoveDirection::IDLE; @@ -37,7 +36,7 @@ class Moving { }; Moving(){}; - virtual ~Moving(){}; + ~Moving(){}; glm::vec2 getCurrentCell() { return MapUtil::GlobalCoordToCellCoord(getCurrentLocation()); @@ -47,6 +46,25 @@ class Moving { m_CurrentLocation = location; } MoveDirection getCurrentDir() { return m_CurrentDir; } + void setCurrentDir(MoveDirection dir) { m_CurrentDir = dir; } + + void moveUpdate() { + if (ifArrivedAtNextCell()) { + m_MovePath.pop_front(); + m_PrevCell = getCurrentCell(); + if (!m_MovePath.empty()) { + setCurrentDir(m_MovePath.front()); + } else { + finishedmovingUpdate(); + } + } + moveToNextCell(); + } + + void finishedmovingUpdate() { + moveToCellCorner(AvatarStandingCorner::CENTER); + setCurrentDir(MoveDirection::IDLE); + } void moveToNextCell(); void moveToCellCorner(AvatarStandingCorner corner); @@ -55,17 +73,17 @@ class Moving { void setMovePath(std::deque movepath) { m_MovePath = movepath; m_CurrentDir = m_MovePath.front(); - m_MovePath.pop_front(); m_PrevCell = getCurrentCell(); } - void setMovementSpeed(float speed) { m_MovementSpeed = speed; } - - glm::vec2 getDestinationCell() { - return MapUtil::CellCoordToGlobal(m_DestinationLocation); - } - void setDestinationCell(glm::vec2 destination) { - m_DestinationLocation = MapUtil::GlobalCoordToCellCoord(destination); + bool ifMovePathEmpty() { + if (m_MovePath.empty()) { + return true; + } else { + return false; + } } + + void setMovementSpeed(float speed) { m_MovementSpeed = speed; } }; #endif // PRACTICALTOOLSFORSIMPLEDESIGN_MOVING_HPP diff --git a/include/Avatar/Weapon.hpp b/include/Avatar/Weapon.hpp index c4081c4a..36b32bab 100644 --- a/include/Avatar/Weapon.hpp +++ b/include/Avatar/Weapon.hpp @@ -14,12 +14,18 @@ enum class WeaponType { Art_105mm, Art_120mm, Nuke, - Grenade + Grenade, + NONE }; class Weapon { public: - Weapon() {} + Weapon() + : m_FireRange(1), + m_SoftAttack(10), + m_HardAttack(10), + m_FireRateInMs(180), + m_Type(WeaponType::NONE) {} Weapon(float firerate, float firerange, float softattack, float hardattack, WeaponType weapontype) : m_FireRange(firerange), diff --git a/include/Map/Map.hpp b/include/Map/Map.hpp index 0bb97b6a..036f9400 100644 --- a/include/Map/Map.hpp +++ b/include/Map/Map.hpp @@ -45,11 +45,16 @@ class MapClass : public Core::Drawable { getTileByCellPosition(position)->setBuildable(false); getTileByCellPosition(position)->pushAvatars(avatar); } - void removeAvatarsByCellPosition(std::shared_ptr avatar, - glm::vec2 position) { + + void removeAvatarByCellPosition(std::shared_ptr avatar, + glm::vec2 position) { getTileByCellPosition(position)->removeAvatar(avatar); } + void removeStrcutureByCellPosition(glm::vec2 position) { + getTileByCellPosition(position)->removeStructure(); + } + protected: void InitGrid(); diff --git a/include/Mechanics/AvatarManager.hpp b/include/Mechanics/AvatarManager.hpp index 7b356d93..518a7fbf 100644 --- a/include/Mechanics/AvatarManager.hpp +++ b/include/Mechanics/AvatarManager.hpp @@ -29,9 +29,10 @@ class AvatarManager { std::vector> getAvatarArray() { return m_AvatarArray; } - void forceMove(std::shared_ptr unit,glm::vec2 cell); + void forceMove(std::shared_ptr unit, glm::vec2 cell); + protected: - void giveOrderToAvatar(std::shared_ptr unit); + void giveOrderToMyAvatar(std::shared_ptr unit); void updateTileWhileAvatarMoving(std::shared_ptr unit); diff --git a/include/Mechanics/BuiltStructure.hpp b/include/Mechanics/BuiltStructure.hpp index d6d38cf1..2759c33f 100644 --- a/include/Mechanics/BuiltStructure.hpp +++ b/include/Mechanics/BuiltStructure.hpp @@ -7,34 +7,38 @@ #include "Structure/Barracks.hpp" #include "Structure/Structure.hpp" #include "pch.hpp" + class BuiltStructure { public: BuiltStructure() {} virtual ~BuiltStructure() {} - - void buildNewStructure(std::shared_ptr m_Map, - std::shared_ptr newstruct,bool force=false) { - std::vector coords = newstruct->GetAbsoluteOccupiedArea(); - if(!force){ + void Start(std::shared_ptr map) { + m_Map = map; + StartBuiltStructure(); + } + void buildNewStructure(std::shared_ptr newstruct, + bool force = false) { + std::vector coords = newstruct->getAbsoluteOccupiedArea(); + if (!force) { if (Util::Input::IsKeyPressed(Util::Keycode::MOUSE_LB)) { - if (ifCanBuildStructureAtTile(m_Map, newstruct) == true) { + // check whehter or not can built at tile + if (ifCanBuildStructureAtTile(newstruct) == true) { m_BuiltStructure.push_back(newstruct); m_Map->builtStructureByCellPosition(newstruct, coords); - newstruct->setStructOrder( - StructureOrder::StructureOrderType::BUILT); + newstruct->getStructureOrder()->setStructOrder( + StructureOrderType::BUILT); } } - }else{ + } else { m_BuiltStructure.push_back(newstruct); m_Map->builtStructureByCellPosition(newstruct, coords); - newstruct->setStructOrder( - StructureOrder::StructureOrderType::BUILT); + newstruct->getStructureOrder()->setStructOrder( + StructureOrderType::BUILT); } } - bool ifCanBuildStructureAtTile(std::shared_ptr m_Map, - std::shared_ptr newstruct) { - std::vector coords = newstruct->GetAbsoluteOccupiedArea(); + bool ifCanBuildStructureAtTile(std::shared_ptr newstruct) { + std::vector coords = newstruct->getAbsoluteOccupiedArea(); for (auto i : coords) { if (m_Map->getTileByCellPosition(i)->getBuildable() == false) { return false; @@ -48,44 +52,60 @@ class BuiltStructure { } void StartBuiltStructure() { - for (auto pair : m_BuiltStructure) { - pair->Start(); + for (auto structure : m_BuiltStructure) { + structure->Start(); } } void UpdateBuiltStructure() { - for (auto pair : m_BuiltStructure) { - pair->Update(); + // check whether the structure is dead or update + for (int i = 0; i < m_BuiltStructure.size(); i++) { + if (m_BuiltStructure[i]->getHealth()->ifDead()) { + // remove from map + for (auto a : m_BuiltStructure[i]->getAbsoluteOccupiedArea()) { + m_Map->removeStrcutureByCellPosition(a); + } + // remove from builtstructure array + m_BuiltStructure.erase(m_BuiltStructure.begin() + i); + i--; + } else { + m_BuiltStructure[i]->Update(); + } } } void add(std::shared_ptr structure) { m_BuiltStructure.push_back(structure); } - void updateAvatarSpawnLocation(std::vector> structure){ - for(auto i:structure){ - if(std::dynamic_pointer_cast(i)){ - if(i->getHouseType()==HouseType::ENEMY){ - m_EnemyBarrackCell=i->GetObjectLocation(); - m_EnemyWayPointCell=std::dynamic_pointer_cast(i)->GetWayPointLocation(); - } else{ - m_PlayerBarrackCell=i->GetObjectLocation(); - m_PlayerWayPointCell=std::dynamic_pointer_cast(i)->GetWayPointLocation(); + void updateAvatarSpawnLocation( + std::vector> structure) { + for (auto i : structure) { + if (std::dynamic_pointer_cast(i)) { + if (i->getHouseType() == HouseType::ENEMY) { + m_EnemyBarrackCell = i->GetObjectLocation(); + m_EnemyWayPointCell = std::dynamic_pointer_cast(i) + ->GetWayPointLocation(); + } else { + m_PlayerBarrackCell = i->GetObjectLocation(); + m_PlayerWayPointCell = + std::dynamic_pointer_cast(i) + ->GetWayPointLocation(); } } } } - glm::vec2 getEnemyBarrackCell(){return m_EnemyBarrackCell;} - glm::vec2 getEnemyWayPointCell(){return m_EnemyWayPointCell;} - glm::vec2 getPlayerBarrackCell(){return m_PlayerBarrackCell;} - glm::vec2 getPlayerWayPointCell(){return m_PlayerWayPointCell;} + glm::vec2 getEnemyBarrackCell() { return m_EnemyBarrackCell; } + glm::vec2 getEnemyWayPointCell() { return m_EnemyWayPointCell; } + glm::vec2 getPlayerBarrackCell() { return m_PlayerBarrackCell; } + glm::vec2 getPlayerWayPointCell() { return m_PlayerWayPointCell; } -protected: +private: + std::shared_ptr m_Map = std::make_shared(); std::vector> m_BuiltStructure; - glm::vec2 m_EnemyBarrackCell={-1,-1}; - glm::vec2 m_EnemyWayPointCell={-1,-1}; - glm::vec2 m_PlayerBarrackCell={-1,-1}; - glm::vec2 m_PlayerWayPointCell={-1,-1}; + glm::vec2 m_EnemyBarrackCell = {-1, -1}; + glm::vec2 m_EnemyWayPointCell = {-1, -1}; + glm::vec2 m_PlayerBarrackCell = {-1, -1}; + glm::vec2 m_PlayerWayPointCell = {-1, -1}; }; #endif // PRACTICALTOOLSFORSIMPLEDESIGN_BUILTSTRUCTURE_HPP diff --git a/include/Mechanics/NemesisManager.hpp b/include/Mechanics/NemesisManager.hpp index e554bcde..67cc0736 100644 --- a/include/Mechanics/NemesisManager.hpp +++ b/include/Mechanics/NemesisManager.hpp @@ -33,8 +33,10 @@ class NemesisManager { if (ifAvatarHasNemesis(hunter) == false) { return false; } - if (hunter->getDistance(m_Nemesis[hunter]->getCurrentCell()) <= - hunter->getWeapon()->getFireRange()) // check with in range + if (hunter->getDistance( + m_Nemesis[hunter]->getMoving()->getCurrentCell()) <= + hunter->getAttackAndDamage()->getWeapon()->getFireRange() * + CELL_SIZE.x) // check with in range { return true; } else { @@ -48,27 +50,31 @@ class NemesisManager { auto hunter = pair.first; auto prey = pair.second; if (ifNemesisWithinWeaponRange(hunter)) { - hunter->setAvatarOrder(AvatarOrderType::OPEN_FIRE); - prey->setAvatarOrder(AvatarOrderType::TAKEN_DAMAGE); - hunter->getAttackAndDamager()->openFireToTarget(prey); - // 反擊 - prey->setAvatarOrder(AvatarOrderType::OPEN_FIRE); - hunter->setAvatarOrder(AvatarOrderType::TAKEN_DAMAGE); - prey->getAttackAndDamager()->openFireToTarget(prey); + hunter->getAvatarOrder()->setAvatarOrder( + AvatarOrderType::OPEN_FIRE); + prey->getAvatarOrder()->setAvatarOrder( + AvatarOrderType::TAKEN_DAMAGE); + hunter->getAttackAndDamage()->openFireToTarget(prey); } if (*pair.second->getHealth()->getLivingStatus() == LivingStatus::DEAD) { removeNemesis(hunter); - hunter->setAvatarOrder(AvatarOrderType::NO_ORDER); - prey->setAvatarOrder(AvatarOrderType::NO_ORDER); + hunter->getAvatarOrder()->setAvatarOrder( + AvatarOrderType::NO_ORDER); + prey->getAvatarOrder()->setAvatarOrder( + AvatarOrderType::NO_ORDER); + break; } if (*pair.first->getHealth()->getLivingStatus() == LivingStatus::DEAD) { removeNemesis(hunter); - hunter->setAvatarOrder(AvatarOrderType::NO_ORDER); - prey->setAvatarOrder(AvatarOrderType::NO_ORDER); + hunter->getAvatarOrder()->setAvatarOrder( + AvatarOrderType::NO_ORDER); + prey->getAvatarOrder()->setAvatarOrder( + AvatarOrderType::NO_ORDER); + break; } } } diff --git a/include/Mechanics/StructureManager.hpp b/include/Mechanics/StructureManager.hpp index 43bf4aee..60921b2b 100644 --- a/include/Mechanics/StructureManager.hpp +++ b/include/Mechanics/StructureManager.hpp @@ -12,7 +12,7 @@ class StructureManager { virtual ~StructureManager() {} void Start(std::shared_ptr map) { - m_StructureArray.StartBuiltStructure(); + m_StructureArray.Start(map); m_Map = map; } void Update() { @@ -27,16 +27,17 @@ class StructureManager { newstruct->Start(); m_StructSelectingConstructionSite = newstruct; - newstruct->setStructOrder( - StructureOrder::StructureOrderType::SELECTING_SITE); + newstruct->getStructureOrder()->setStructOrder( + StructureOrderType::SELECTING_SITE); } void SelectingBuildSite() { // bulit or not - if (m_StructSelectingConstructionSite->getStructOrder() == - StructureOrder::StructureOrderType::SELECTING_SITE) { + if (m_StructSelectingConstructionSite->getStructureOrder() + ->getStructureOrderType() == + StructureOrderType::SELECTING_SITE) { m_StructureArray.buildNewStructure( - m_Map, m_StructSelectingConstructionSite); + m_StructSelectingConstructionSite); } } diff --git a/include/Mechanics/UnitManager.hpp b/include/Mechanics/UnitManager.hpp index 2007280a..eb871591 100644 --- a/include/Mechanics/UnitManager.hpp +++ b/include/Mechanics/UnitManager.hpp @@ -91,8 +91,6 @@ class UnitManager : public Player { return; } - - avatar->Start(m_StructureManager->getStructureArray() ->getPlayerBarrackCell()); // avatar @@ -109,45 +107,40 @@ class UnitManager : public Player { void spawn(std::shared_ptr m_Map, UnitType unit, HouseType house, glm::vec2 cellPos) { // 缺檢查敵方擁有建築的位置,並重生在該處 - if (house == HouseType::ENEMY) { - // m_Enemy->addUnitConstructCount(unit, 1); - } else { - // m_Player->setUnitConstructCount(unit, 1); - } switch (unit) { case UnitType::BARRACKS: { auto structure = std::make_shared(house); structure->Start(cellPos); m_StructureManager->getStructureArray()->buildNewStructure( - m_Map, structure, true); + structure, true); break; } case UnitType::ORE_REF: { auto structure = std::make_shared(house); structure->Start(cellPos); m_StructureManager->getStructureArray()->buildNewStructure( - m_Map, structure, true); + structure, true); break; } case UnitType::POWER_PLANT: { auto structure = std::make_shared(house); structure->Start(cellPos); m_StructureManager->getStructureArray()->buildNewStructure( - m_Map, structure, true); + structure, true); break; } case UnitType::WAR_FACT: { auto structure = std::make_shared(house); structure->Start(cellPos); m_StructureManager->getStructureArray()->buildNewStructure( - m_Map, structure, true); + structure, true); break; } case UnitType::ADV_POWER_PLANT: { auto structure = std::make_shared(house); structure->Start(cellPos); m_StructureManager->getStructureArray()->buildNewStructure( - m_Map, structure, true); + structure, true); break; } case UnitType::INFANTRY: { diff --git a/include/Structure/Structure.hpp b/include/Structure/Structure.hpp index 004e1d62..47d94eb0 100644 --- a/include/Structure/Structure.hpp +++ b/include/Structure/Structure.hpp @@ -8,13 +8,13 @@ #include "Display/SpriteSheet.hpp" #include "Display/SpriteSheetAnimation.hpp" #include "HighLight.h" +#include "Map/MapUtility.hpp" #include "Mechanics/GameObjectID.hpp" #include "Selectable.hpp" #include "Structure/StructureOrder.hpp" -#include "Util/Image.hpp" - #include "Unit/Health.hpp" #include "Unit/IHealthable.hpp" +#include "Util/Image.hpp" #include "Util/GameObject.hpp" #include "Util/Input.hpp" @@ -26,7 +26,6 @@ class Structure : public Util::GameObject, public Selectable, - public StructureOrder, public IHealthable { public: @@ -79,34 +78,34 @@ class Structure : public Util::GameObject, glm::vec2 GetObjectLocation() { return this->m_ObjectLocation; } virtual void SetAttachVisible(bool visible); glm::vec2 GetDrawLocation() { return m_DrawLocation; }; - void SetID(GameObjectID id) { m_ID = id; }; virtual void attachmentUpdate(); float getElectricPower() { return this->m_ElectricPower; } float getBuildingTime() { return this->m_BuildingTime; } float getBuildingCost() { return this->m_BuildingCost; } - HouseType getHouseType() { return this->m_ID.getHouseType(); } - glm::vec2 GlobalCoordToCellCoord(glm::vec2 globalCoord) { - return glm::vec2(int(globalCoord[0] / CELL_SIZE.x), - int(globalCoord[1] / CELL_SIZE.y)); - } + HouseType getHouseType() { return this->m_ID.getHouseType(); } - glm::vec2 GetObjectCell() { - return GlobalCoordToCellCoord(m_ObjectLocation); + glm::vec2 getLocationCell() { + return MapUtil::GlobalCoordToCellCoord(m_ObjectLocation); } - std::vector GetAbsoluteOccupiedArea(); + std::vector getAbsoluteOccupiedArea(); void SetRelativeOccupiedArea(std::vector Area) { m_RelativeOccupiedArea = Area; } +public: GameObjectID getID() { return m_ID; } - std::shared_ptr getHealth() override { return m_Health; } void setHealth(std::shared_ptr health) override { m_Health = health; } + std::shared_ptr getStructureOrder() { return m_Order; } + + std::shared_ptr getAttackAndDamage() { + return m_AttackAndDamage; + } protected: float m_ElectricPower; @@ -127,6 +126,9 @@ class Structure : public Util::GameObject, glm::vec2 m_ObjectLocation = {100, 100}; std::vector m_RelativeOccupiedArea = {{0, 0}}; + // structure order + std::shared_ptr m_Order = + std::make_shared(); // health std::shared_ptr m_Health = std::make_shared(); // attack and damage diff --git a/include/Structure/StructureOrder.hpp b/include/Structure/StructureOrder.hpp index 7a9b4eb0..a8a58c02 100644 --- a/include/Structure/StructureOrder.hpp +++ b/include/Structure/StructureOrder.hpp @@ -4,20 +4,19 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTUREORDER_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTUREORDER_HPP - +enum class StructureOrderType { + NOT_CONSTRUCTED_YET, + CONSTRUCTED, + SELECTING_SITE, + BUILT, + NO_ORDER +}; class StructureOrder { - public: StructureOrder() {} virtual ~StructureOrder() {} - enum class StructureOrderType { - NOT_CONSTRUCTED_YET, - CONSTRUCTED, - SELECTING_SITE, - BUILT, - NO_ORDER - }; - StructureOrderType getStructOrder() { return m_StructOrder; } + + StructureOrderType getStructureOrderType() { return m_StructOrder; } void setStructOrder(StructureOrderType structorder) { m_StructOrder = structorder; diff --git a/include/Structure/WayPointStructure.hpp b/include/Structure/WayPointStructure.hpp index aa02b718..54ac6044 100644 --- a/include/Structure/WayPointStructure.hpp +++ b/include/Structure/WayPointStructure.hpp @@ -47,7 +47,8 @@ class WayPointStructure : public Structure, public IWayPointStructure { break; } case LivingStatus::ALIVE: { - if (m_StructOrder == StructureOrderType::SELECTING_SITE) { + if (getStructureOrder()->getStructureOrderType() == + StructureOrderType::SELECTING_SITE) { this->updateMoveable(); } else { this->updateFixed(); diff --git a/include/Unit/Health.hpp b/include/Unit/Health.hpp index f52529bd..c96c0d6c 100644 --- a/include/Unit/Health.hpp +++ b/include/Unit/Health.hpp @@ -40,21 +40,25 @@ class Health { void setHP(int hp) { m_HP = hp; - if (m_HP <= 0) { - m_LivingStatus = std::make_shared(LivingStatus::DEAD); - } + ifDead(); } void addHP(int value) { m_HP += value; - if (m_HP <= 0) { - m_LivingStatus = std::make_shared(LivingStatus::DEAD); - } + ifDead(); } int getHP() { return m_HP; } void setArmorRate(float armorrate) { m_ArmorRate = armorrate; } float getArmorRate() { return m_ArmorRate; } + bool ifDead() { + if (m_HP <= 0) { + m_LivingStatus = std::make_shared(LivingStatus::DEAD); + return true; + } else { + return false; + } + } private: std::shared_ptr m_LivingStatus = diff --git a/include/pch.hpp b/include/pch.hpp index 194373d7..1d9e82aa 100644 --- a/include/pch.hpp +++ b/include/pch.hpp @@ -19,8 +19,8 @@ #include -//suppose to be "GL/glut", yet GLUT/glut on mac -//#include +// suppose to be "GL/glut", yet GLUT/glut on mac +// #include #include #include diff --git a/src/Avatar/Avatar.cpp b/src/Avatar/Avatar.cpp index 30ea5564..2106e901 100644 --- a/src/Avatar/Avatar.cpp +++ b/src/Avatar/Avatar.cpp @@ -9,22 +9,37 @@ void Avatar::whenSelected() { } void Avatar::Update() { + DrawAvatar(); + if (getMoving()->ifMovePathEmpty()) { + getAvatarOrder()->setAvatarOrder(AvatarOrderType::NO_ORDER); + } switch (*m_Health->getLivingStatus()) { + case (LivingStatus::DEAD): SetVisible(false); break; case (LivingStatus::ALIVE): + SetVisible(true); whenSelected(); - if (m_AvatarOrder == AvatarOrderType::OPEN_FIRE) { - - } else if (m_AvatarOrder == AvatarOrderType::MOVE) { - moveUpdate(); - } else if (m_AvatarOrder == AvatarOrderType::NO_ORDER) { - noOrderUpdate(); - } else if (m_AvatarOrder == AvatarOrderType::TAKEN_DAMAGE) { - } else if (m_AvatarOrder == AvatarOrderType::SPAWNED) { + if (getAvatarOrder()->getAvatarOrder() == AvatarOrderType::OPEN_FIRE) { + // open fire + } else if (getAvatarOrder()->getAvatarOrder() == + AvatarOrderType::MOVE) { + m_Moving->moveUpdate(); + if (getMoving()->getCurrentDir() == MoveDirection::IDLE) { + getAvatarOrder()->setAvatarOrder(AvatarOrderType::NO_ORDER); + } + } else if (getAvatarOrder()->getAvatarOrder() == + AvatarOrderType::NO_ORDER) { + noorderUpdate(); + } else if (getAvatarOrder()->getAvatarOrder() == + AvatarOrderType::TAKEN_DAMAGE) { + + // takendamage + } else if (getAvatarOrder()->getAvatarOrder() == + AvatarOrderType::SPAWNED) { spawnedUpdate(); } @@ -32,39 +47,13 @@ void Avatar::Update() { } } -void Avatar::noOrderUpdate() { - m_CurrentDir = MoveDirection::IDLE; - SetVisible(true); - m_Transform.translation = getCurrentLocation(); - - Draw(); +void Avatar::noorderUpdate() { + getMoving()->setCurrentDir(MoveDirection::IDLE); + m_Transform.translation = getMoving()->getCurrentLocation(); } void Avatar::spawnedUpdate() { - SetVisible(true); - m_Transform.translation = getCurrentLocation(); - - Draw(); -} -void Avatar::moveUpdate() { - - if (ifArrivedAtNextCell()) { - m_PrevCell = getCurrentCell(); - if (!m_MovePath.empty()) { - m_CurrentDir = m_MovePath.front(); - m_MovePath.pop_front(); - } else { - finishedmovingUpdate(); - m_CurrentDir = MoveDirection::IDLE; - m_AvatarOrder = AvatarOrderType::NO_ORDER; - } - } - moveToNextCell(); - - SetVisible(true); - m_Transform.translation = getCurrentLocation(); - - Draw(); + m_Transform.translation = getMoving()->getCurrentLocation(); } void Avatar::Start(glm::vec2 spawnlocationcell) { // destination = Barrack's @@ -72,10 +61,10 @@ void Avatar::Start(glm::vec2 spawnlocationcell) { // destination = Barrack's // setCurrentCell() //CurrentCell = Structure's Location this->SetDrawable(customizeImage()); // setSpriteSheet(); - SetVisible(true); - setMovementSpeed(4); - m_AvatarOrder = AvatarOrderType::SPAWNED; - m_CurrentLocation = MapUtil::CellCoordToGlobal(spawnlocationcell); + getMoving()->setMovementSpeed(4); + getAvatarOrder()->setAvatarOrder(AvatarOrderType::SPAWNED); + getMoving()->setCurrentLocation( + MapUtil::CellCoordToGlobal(spawnlocationcell)); m_Transform.scale = {1, 1}; getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); @@ -124,9 +113,25 @@ void Avatar::DEBUG_printCurrentMoveDirection(MoveDirection Dir) { } } -void Avatar::finishedmovingUpdate() { - Moving::moveToCellCorner(AvatarStandingCorner::CENTER); - m_Transform.translation = getCurrentLocation(); +void Avatar::DrawAvatar() { + m_Transform.translation = getMoving()->getCurrentLocation(); + + if (getAvatarOrder()->getAvatarOrder() == AvatarOrderType::OPEN_FIRE) { + this->SetDrawable(std::make_shared( + "../assets/sprites/mech_open_fire.png")); + } else if (getAvatarOrder()->getAvatarOrder() == + AvatarOrderType::TAKEN_DAMAGE) { + if (getHealth()->getHP() < 50) { + this->SetDrawable(std::make_shared( + "../assets/sprites/mech_dead.png")); + } else { + this->SetDrawable(std::make_shared( + "../assets/sprites/mech_taken_damage.png")); + } + } else { + this->SetDrawable( + std::make_shared("../assets/sprites/mech_single.png")); + } Draw(); } diff --git a/src/Avatar/Hunter.cpp b/src/Avatar/Hunter.cpp index bdc4af69..338bc324 100644 --- a/src/Avatar/Hunter.cpp +++ b/src/Avatar/Hunter.cpp @@ -5,17 +5,16 @@ #include "Avatar/Hunter.hpp" void Hunter::customizeUpdate() { - glm::vec2 targetCell = m_target->getCurrentCell(); + glm::vec2 targetCell = m_target->getMoving()->getCurrentCell(); if (getDistance(targetCell) > ATTACK_RANGE - 1 && - lastTargetCell != m_target->getCurrentCell()) { + lastTargetCell != m_target->getMoving()->getCurrentCell()) { // glm::vec2 nextCell = // getNextCellByCurrent(getDirByRelativeCells(getCurrentCell(),targetCell),getCurrentCell()); - setDestinationCell(m_target->getCurrentCell()); - lastTargetCell = m_target->getCurrentCell(); + + lastTargetCell = m_target->getMoving()->getCurrentCell(); // setNewDestination(nextCell); } else if (getDistance(targetCell) < ATTACK_RANGE - 1) { - setDestinationCell(getCurrentCell()); - lastTargetCell = getCurrentCell(); + lastTargetCell = getMoving()->getCurrentCell(); attack(m_target); } } diff --git a/src/Avatar/Runner.cpp b/src/Avatar/Runner.cpp index 3fd11c99..b2edb930 100644 --- a/src/Avatar/Runner.cpp +++ b/src/Avatar/Runner.cpp @@ -6,30 +6,30 @@ void Runner::setBeingChase(std::shared_ptr hunter) { b_beingChase = true; m_hunter = hunter; - lastTargetCell = getCurrentCell(); + lastTargetCell = m_Moving->getCurrentCell(); } void Runner::customizeUpdate() { if (b_beingChase && *m_hunter->getHealth()->getLivingStatus() == LivingStatus::ALIVE) { - glm::vec2 hunterCell = m_hunter->getCurrentCell(); + glm::vec2 hunterCell = m_hunter->getMoving()->getCurrentCell(); if (getDistance(hunterCell) <= ATTACK_RANGE - 1 && - lastTargetCell == getCurrentCell()) { + lastTargetCell == getMoving()->getCurrentCell()) { edgeCount = 0; - MoveDirection Dir = oppositeDir(PathUtility::getDirByRelativeCells( - getCurrentCell(), hunterCell), - runMode::LIDL_RANDOM); + MoveDirection Dir = + oppositeDir(PathUtility::getDirByRelativeCells( + getMoving()->getCurrentCell(), hunterCell), + runMode::LIDL_RANDOM); DEBUG_printCurrentMoveDirection(Dir); - glm::vec2 nextCell = - getNextCellByCurrentPlus3(Dir, getCurrentCell(), 3, 1); + glm::vec2 nextCell = getNextCellByCurrentPlus3( + Dir, getMoving()->getCurrentCell(), 3, 1); while (nextCell.x < 0 || nextCell.y < 0) { edgeCount += rand() % 2 + 1; Dir = findNewDir(Dir, edgeCount); DEBUG_printCurrentMoveDirection(Dir); - nextCell = - getNextCellByCurrentPlus3(Dir, getCurrentCell(), 1, 3); + nextCell = getNextCellByCurrentPlus3( + Dir, getMoving()->getCurrentCell(), 1, 3); } lastTargetCell = nextCell; - setDestinationCell(nextCell); } } else { b_beingChase = false; diff --git a/src/Mechanics/AvatarManager.cpp b/src/Mechanics/AvatarManager.cpp index a1cf3cdf..1a3db282 100644 --- a/src/Mechanics/AvatarManager.cpp +++ b/src/Mechanics/AvatarManager.cpp @@ -5,54 +5,82 @@ #include "Mechanics/AvatarManager.hpp" void AvatarManager::Update() { - for (auto unit : m_AvatarArray) { - unit->Update(); - if (unit->getAvatarOrder() == AvatarOrderType::MOVE) { - updateTileWhileAvatarMoving(unit); - } - if (unit->getSelected()) { - giveOrderToAvatar(unit); + m_NemesisManager->Update(); + for (int i = 0; i < m_AvatarArray.size(); i++) { + // if dead remove, else update it + if (m_AvatarArray[i]->getHealth()->ifDead()) { + // remove from map + m_Map->removeAvatarByCellPosition( + m_AvatarArray[i], + m_AvatarArray[i]->getMoving()->getCurrentCell()); + // remove from array + m_AvatarArray.erase(m_AvatarArray.begin() + i); + i--; + } else { + m_AvatarArray[i]->Update(); + + // update tile while avatar is moving + if (m_AvatarArray[i]->getAvatarOrder()->getAvatarOrder() == + AvatarOrderType::MOVE) { + updateTileWhileAvatarMoving(m_AvatarArray[i]); + } + + // give order to avatar + if (m_AvatarArray[i]->getSelected()) { + giveOrderToMyAvatar(m_AvatarArray[i]); + } } } } -void AvatarManager::giveOrderToAvatar(std::shared_ptr unit) { - if (Util::Input::IsKeyDown(Util::Keycode::MOUSE_RB)) { - auto dest = Util::Input::GetCursorPosition(); - auto queue = m_Navigator->findPath( - unit->getCurrentCell(), MapUtil::GlobalCoordToCellCoord( - MapUtil::ScreenToGlobalCoord(dest))); - // unit - unit->setMovePath(queue); - - if (m_Map->getTileByCellPosition(unit->getDestinationCell()) - ->ifEnemyAtTile()) { - m_NemesisManager->addNemesis( - unit, m_Map->getTileByCellPosition(unit->getDestinationCell()) - ->getAvatars()[0]); - } else { - unit->setAvatarOrder(AvatarOrderType::MOVE); +void AvatarManager::giveOrderToMyAvatar(std::shared_ptr unit) { + if (unit->getID().getHouseType() == HouseType::MY) { + if (Util::Input::IsKeyDown(Util::Keycode::MOUSE_RB)) { + auto dest = Util::Input::GetCursorPosition(); + auto queue = + m_Navigator->findPath(unit->getMoving()->getCurrentCell(), + MapUtil::GlobalCoordToCellCoord( + MapUtil::ScreenToGlobalCoord(dest))); + // unit + unit->getMoving()->setMovePath(queue); + + if (m_Map + ->getTileByCellPosition(MapUtil::GlobalCoordToCellCoord( + MapUtil::ScreenToGlobalCoord(dest))) + ->ifEnemyAtTile()) { + unit->getAvatarOrder()->setAvatarOrder(AvatarOrderType::MOVE); + m_NemesisManager->addNemesis( + unit, + m_Map + ->getTileByCellPosition(MapUtil::GlobalCoordToCellCoord( + MapUtil::ScreenToGlobalCoord(dest))) + ->getAvatars()[0]); + } else { + unit->getAvatarOrder()->setAvatarOrder(AvatarOrderType::MOVE); + } } } } -void AvatarManager::forceMove(std::shared_ptr unit,glm::vec2 cell){ - unit->setAvatarOrder(AvatarOrderType::MOVE); - auto queue = m_Navigator->findPath(unit->getCurrentCell(), cell); - unit->setMovePath(queue); - } +void AvatarManager::forceMove(std::shared_ptr unit, glm::vec2 cell) { + unit->getAvatarOrder()->setAvatarOrder(AvatarOrderType::MOVE); + auto queue = + m_Navigator->findPath(unit->getMoving()->getCurrentCell(), cell); + unit->getMoving()->setMovePath(queue); +} void AvatarManager::updateTileWhileAvatarMoving( std::shared_ptr avatar) { - if (avatar->ifArrivedAtNextCell()) { - m_Map->removeAvatarsByCellPosition(avatar, - unitArrayAndLocation[avatar]); - m_Map->setAvatarByCellPosition(avatar, avatar->getCurrentCell()); - unitArrayAndLocation[avatar] = avatar->getCurrentCell(); + if (avatar->getMoving()->ifArrivedAtNextCell()) { + m_Map->removeAvatarByCellPosition(avatar, unitArrayAndLocation[avatar]); + m_Map->setAvatarByCellPosition(avatar, + avatar->getMoving()->getCurrentCell()); + unitArrayAndLocation[avatar] = avatar->getMoving()->getCurrentCell(); } } void AvatarManager::AppendAvatar(std::shared_ptr newAvatar) { m_AvatarArray.push_back(newAvatar); - unitArrayAndLocation[newAvatar] = newAvatar->getCurrentCell(); - m_Map->setAvatarByCellPosition(newAvatar, newAvatar->getCurrentCell()); + unitArrayAndLocation[newAvatar] = newAvatar->getMoving()->getCurrentCell(); + m_Map->setAvatarByCellPosition(newAvatar, + newAvatar->getMoving()->getCurrentCell()); } diff --git a/src/Scene/TutorialScene.cpp b/src/Scene/TutorialScene.cpp index 90ed8c98..a8b55df6 100644 --- a/src/Scene/TutorialScene.cpp +++ b/src/Scene/TutorialScene.cpp @@ -8,6 +8,7 @@ void TutorialScene::Start() { LOG_TRACE("Start"); m_Map->Init(100, 100); m_GameObjectManager->Start(m_Map); + m_EnemyObjectManager->Start(m_Map); m_UI.Start(m_Map, m_GameObjectManager); m_Player->setTotalCurrency(5000); m_Enemy->setTotalCurrency(5000); @@ -25,6 +26,9 @@ void TutorialScene::Start() { */ m_GameObjectManager->spawn(m_Map, UnitType::INFANTRY, HouseType::MY, {5, 5}); + // combat test + m_EnemyObjectManager->spawn(m_Map, UnitType::INFANTRY, HouseType::ENEMY, + {6, 6}); stageStart(); } @@ -88,7 +92,7 @@ void TutorialScene::stageUpdate() { for (auto i : m_GameObjectManager->getAvatarManager()->getAvatarArray()) { if (i->getHouseType() == HouseType::MY) { - if (m_cellProp->isOverlaps(i->getCurrentCell()) || + if (m_cellProp->isOverlaps(i->getMoving()->getCurrentCell()) || Util::Input::IsKeyPressed(Util::Keycode::DEBUG_KEY)) { // change next stage's text&prop here m_Text->SetDrawable(std::make_unique( @@ -138,7 +142,7 @@ void TutorialScene::stageUpdate() { for (auto i : m_GameObjectManager->getAvatarManager()->getAvatarArray()) { if (i->getHouseType() == HouseType::MY) { - if (m_cellProp->isOverlaps(i->getCurrentCell())) { + if (m_cellProp->isOverlaps(i->getMoving()->getCurrentCell())) { avatarCount++; } } diff --git a/src/Structure/Barracks.cpp b/src/Structure/Barracks.cpp index ca6b90af..95f28481 100644 --- a/src/Structure/Barracks.cpp +++ b/src/Structure/Barracks.cpp @@ -20,7 +20,7 @@ void Barracks::Start() { m_HighLight.SetHLScale(this->GetTransform().scale); whenSelected(); // State - setStructOrder(StructureOrderType::CONSTRUCTED); + getStructureOrder()->setStructOrder(StructureOrderType::CONSTRUCTED); // health Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); @@ -47,7 +47,7 @@ void Barracks::Start(glm::vec2 location) { SetVisible(true); m_SpriteSheetAnimation->initSpriteSheetAnimation(m_StructureSpriteSheet, false, INTERVAL, false); - setStructOrder(StructureOrderType::BUILT); + getStructureOrder()->setStructOrder(StructureOrderType::BUILT); Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); -} \ No newline at end of file +} diff --git a/src/Structure/OreRefinery.cpp b/src/Structure/OreRefinery.cpp index d489d820..b6bd1020 100644 --- a/src/Structure/OreRefinery.cpp +++ b/src/Structure/OreRefinery.cpp @@ -20,7 +20,8 @@ void OreRefinery::Start() { m_HighLight.SetHLScale(this->GetTransform().scale); whenSelected(); // State - setStructOrder(StructureOrderType::NOT_CONSTRUCTED_YET); + getStructureOrder()->setStructOrder( + StructureOrderType::NOT_CONSTRUCTED_YET); Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); } @@ -46,7 +47,7 @@ void OreRefinery::Start(glm::vec2 location) { SetVisible(true); m_SpriteSheetAnimation->initSpriteSheetAnimation(m_StructureSpriteSheet, false, INTERVAL, false); - setStructOrder(StructureOrderType::BUILT); + getStructureOrder()->setStructOrder(StructureOrderType::BUILT); Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); -} \ No newline at end of file +} diff --git a/src/Structure/Structure.cpp b/src/Structure/Structure.cpp index a286c992..df404de3 100644 --- a/src/Structure/Structure.cpp +++ b/src/Structure/Structure.cpp @@ -11,7 +11,7 @@ void Structure::Start() { if (this->m_ID.getUnitType() == UnitType::NONE) { Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::NOT_BORN_YET)); - m_StructOrder = StructureOrderType::NO_ORDER; + getStructureOrder()->setStructOrder(StructureOrderType::NO_ORDER); } else { m_Transform.scale = {2.f, 2.f}; m_HighLight.SetDrawable( @@ -23,7 +23,7 @@ void Structure::Start() { SetSpriteSheet(); Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); - m_StructOrder = StructureOrderType::SELECTING_SITE; + getStructureOrder()->setStructOrder(StructureOrderType::SELECTING_SITE); } } void Structure::Start(glm::vec2 location) { @@ -37,15 +37,15 @@ void Structure::Start(glm::vec2 location) { SetSpriteSheet(); Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); - m_StructOrder = StructureOrderType::SELECTING_SITE; + getStructureOrder()->setStructOrder(StructureOrderType::SELECTING_SITE); this->SetObjectLocation(location); SetVisible(true); m_SpriteSheetAnimation->initSpriteSheetAnimation(m_StructureSpriteSheet, false, INTERVAL, false); - setStructOrder(StructureOrderType::BUILT); + getStructureOrder()->setStructOrder(StructureOrderType::BUILT); Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); - } +} void Structure::Update() { switch (*getHealth()->getLivingStatus()) { @@ -54,9 +54,12 @@ void Structure::Update() { break; case LivingStatus::ALIVE: whenSelected(); - if (m_StructOrder == StructureOrderType::SELECTING_SITE) { + + if (getStructureOrder()->getStructureOrderType() == + StructureOrderType::SELECTING_SITE) { this->updateMoveable(); - } else if (m_StructOrder == StructureOrderType::BUILT) { + } else if (getStructureOrder()->getStructureOrderType() == + StructureOrderType::BUILT) { this->updateFixed(); } break; @@ -105,10 +108,10 @@ void Structure::attachmentUpdate() { m_HighLight.SetObjectLocation(this->GetDrawLocation()); m_HighLight.Draw(); } -std::vector Structure::GetAbsoluteOccupiedArea() { +std::vector Structure::getAbsoluteOccupiedArea() { std::vector Area; for (auto i : m_RelativeOccupiedArea) { - Area.push_back({i.x + GetObjectCell().x, i.y + GetObjectCell().y}); + Area.push_back({i.x + getLocationCell().x, i.y + getLocationCell().y}); } return Area; } diff --git a/src/Structure/WarFactory.cpp b/src/Structure/WarFactory.cpp index 641fa3d4..32457ade 100644 --- a/src/Structure/WarFactory.cpp +++ b/src/Structure/WarFactory.cpp @@ -44,7 +44,7 @@ void WarFactory::Start(glm::vec2 location) { SetVisible(true); m_SpriteSheetAnimation->initSpriteSheetAnimation(m_StructureSpriteSheet, false, INTERVAL, false); - setStructOrder(StructureOrderType::BUILT); + getStructureOrder()->setStructOrder(StructureOrderType::BUILT); Structure::getHealth()->setLivingStatus( std::make_shared(LivingStatus::ALIVE)); -} \ No newline at end of file +} diff --git a/src/Structure/WayPointStructure.cpp b/src/Structure/WayPointStructure.cpp index 49461e1c..e13838bf 100644 --- a/src/Structure/WayPointStructure.cpp +++ b/src/Structure/WayPointStructure.cpp @@ -5,7 +5,7 @@ #include "Map/MapUtility.hpp" void WayPointStructure::whenSelected() { - if (this->getSelected() && this->getBuilt()) { + if (this->getSelected() && this->getStructureOrder()->getBuilt()) { if (Util::Input::IsKeyPressed(Util::Keycode(Util::Keycode::MOUSE_RB))) { this->SetWayPointLocationByCellCoord( MapUtil::GlobalCoordToCellCoord(MapUtil::ScreenToGlobalCoord( diff --git a/src/UI/UI.cpp b/src/UI/UI.cpp index beb9538d..59654d8f 100644 --- a/src/UI/UI.cpp +++ b/src/UI/UI.cpp @@ -442,7 +442,7 @@ std::shared_ptr UIClass::getUnitFromUI() { Avatar->Start({m_barrackCell.x + 1, m_barrackCell.y - 1}); - Avatar->setDestinationCell(m_barrackTargetCell); + // Avatar->setDestinationCell(m_barrackTargetCell); } printf("(UI)return to GOM success\n"); return Avatar;