-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
233 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Created by 盧威任 on 4/24/24. | ||
// | ||
|
||
#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_BUILTSTRUCTURE_HPP | ||
#define PRACTICALTOOLSFORSIMPLEDESIGN_BUILTSTRUCTURE_HPP | ||
#include "Structure/Structure.hpp" | ||
#include "pch.hpp" | ||
class BuiltStructure { | ||
public: | ||
BuiltStructure() {} | ||
virtual ~BuiltStructure() {} | ||
|
||
void buildNewStructure(std::shared_ptr<MapClass> m_Map, | ||
std::shared_ptr<Structure> newstruct) { | ||
m_BuiltStructure.push_back(newstruct); | ||
std::vector<glm::vec2> coords = newstruct->GetAbsoluteOccupiedArea(); | ||
if (ifCanBuildStructureAtTile(m_Map, newstruct) == true) { | ||
m_Map->builtStructureByCellPosition(newstruct, coords); | ||
} | ||
} | ||
|
||
bool ifCanBuildStructureAtTile(std::shared_ptr<MapClass> m_Map, | ||
std::shared_ptr<Structure> newstruct) { | ||
std::vector<glm::vec2> coords = newstruct->GetAbsoluteOccupiedArea(); | ||
for (auto i : coords) { | ||
if (m_Map->getTileByCellPosition(i)->getBuildable() == false) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
std::vector<std::shared_ptr<Structure>> getBuiltStructureArray() { | ||
return m_BuiltStructure; | ||
} | ||
|
||
void StartBuiltStructure() { | ||
for (auto pair : m_BuiltStructure) { | ||
pair->Start(); | ||
} | ||
} | ||
|
||
void UpdateBuiltStructure() { | ||
for (auto pair : m_BuiltStructure) { | ||
pair->Update(); | ||
} | ||
} | ||
|
||
protected: | ||
std::vector<std::shared_ptr<Structure>> m_BuiltStructure; | ||
}; | ||
#endif // PRACTICALTOOLSFORSIMPLEDESIGN_BUILTSTRUCTURE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// Created by 盧威任 on 5/3/24. | ||
// | ||
|
||
#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_NEMESISMANAGER_HPP | ||
#define PRACTICALTOOLSFORSIMPLEDESIGN_NEMESISMANAGER_HPP | ||
#include "Map/MapUtility.hpp" | ||
class NemesisManager { | ||
|
||
public: | ||
void addNemesis(std::shared_ptr<Avatar> avatar, | ||
std::shared_ptr<Avatar> nemesis) { | ||
m_Nemesis[avatar] = nemesis; | ||
} | ||
|
||
void removeNemesis(std::shared_ptr<Avatar> avatar) { | ||
if (ifAvatarHasNemesis(avatar)) { | ||
m_Nemesis.erase(avatar); | ||
} | ||
} | ||
|
||
bool ifAvatarHasNemesis(std::shared_ptr<Avatar> avatar) { | ||
if (m_Nemesis.count(avatar)) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
bool ifNemesisWithinWeaponRange(std::shared_ptr<Avatar> avatar) { | ||
if (ifAvatarHasNemesis(avatar) == false) { | ||
return false; | ||
} | ||
if (1 == 0) // with in range | ||
{ | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
void Update() { | ||
for (auto pair : m_Nemesis) { | ||
if (ifNemesisWithinWeaponRange(pair.first)) { | ||
pair.first->setAvatarOrder(AvatarOrderType::OPEN_FIRE); | ||
pair.second->setAvatarOrder(AvatarOrderType::TAKEN_DAMAGE); | ||
pair.first->openFireToTarget(pair.second); | ||
} | ||
|
||
if (pair.second->getLivingStatus() == LivingStatus::DEAD) { | ||
removeNemesis(pair.first); | ||
pair.first->setAvatarOrder(AvatarOrderType::NO_ORDER); | ||
pair.second->setAvatarOrder(AvatarOrderType::NO_ORDER); | ||
} | ||
|
||
if (pair.first->getLivingStatus() == LivingStatus::DEAD) { | ||
removeNemesis(pair.first); | ||
pair.first->setAvatarOrder(AvatarOrderType::NO_ORDER); | ||
pair.second->setAvatarOrder(AvatarOrderType::NO_ORDER); | ||
} | ||
} | ||
} | ||
|
||
private: | ||
std::unordered_map<std::shared_ptr<Avatar>, std::shared_ptr<Avatar>> | ||
m_Nemesis; | ||
}; | ||
#endif // PRACTICALTOOLSFORSIMPLEDESIGN_NEMESISMANAGER_HPP |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.