Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #4

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions include/AI/AIGroupCommander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,20 @@ class AIGroupCommander {
glm::vec2 findTargetForOffensiveUnit(std::shared_ptr<Avatar> unit){
glm::vec2 targetCell = {-1.f,-1.f};
//issue: empty group should delete before this
if(false&&static_cast<int>(m_offensiveGroup.size())>=static_cast<int>(m_PlayerUnitManager->getAvatarManager()->getAvatarArray().size())){
if(!m_PlayerUnitManager->getStructureManager()->getStructureArray()->getBuiltStructureArray().empty()){
targetCell=m_PlayerUnitManager->getStructureManager()->getStructureArray()->getBuiltStructureArray().front()->getCurrentLocationInCell();
}
for(auto i : m_PlayerUnitManager->getStructureManager()->getStructureArray()->getBuiltStructureArray()){
if(unit->getDistance(i->getCurrentLocationInCell())<unit->getDistance(targetCell)){
//attack
targetCell = i->getCurrentLocationInCell();
}
}
if(static_cast<int>(m_offensiveGroup.size())>=static_cast<int>(m_PlayerUnitManager->getAvatarManager()->getAvatarArray().size())){
targetCell = m_Map->findEnemyInRange(200,unit->getCurrentLocationInCell(),HouseType::ENEMY);
//attack
m_AIAvatarManager->assignAttackOrderToAvatar(unit,targetCell,HouseType::ENEMY);
}else{
if(!m_PlayerUnitManager->getAvatarManager()->getAvatarArray().empty()){
targetCell=m_PlayerUnitManager->getAvatarManager()->getAvatarArray().front()->getCurrentLocationInCell();
}
for(auto i : m_PlayerUnitManager->getAvatarManager()->getAvatarArray()){
if(i->getDistance(unit->getCurrentLocationInCell())<unit->getDistance(targetCell)){
//attack
if(m_AIAvatarManager->ifAvatarHasNemesis(m_Map->getTileByCellPosition(targetCell)->getAvatars().front())){
continue;
}
targetCell = i->getCurrentLocationInCell();
}
}
Expand Down
5 changes: 0 additions & 5 deletions include/Map/MapUtility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,5 @@ class MapUtil {
int _y = location.y / CELL_SIZE.y;
return {_x * CELL_SIZE.x, _y * CELL_SIZE.y};
}
static float findDistance(glm::vec2 cell1, glm::vec2 cell2) {
float dx = cell2.x - cell1.x;
float dy = cell2.y - cell1.y;
return sqrt(dx * dx + dy * dy);
}
};
#endif // PRACTICALTOOLSFORSIMPLEDESIGN_MAPUTILITY_HPP
3 changes: 3 additions & 0 deletions include/Mechanics/AvatarManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class AvatarManager {
bool ifAvatarHasNemesis(std::shared_ptr<Avatar> unit){
return m_NemesisManager->ifAvatarHasNemesis(unit);
}
bool ifAvatarHasHunter(std::shared_ptr<Avatar> unit){
return m_NemesisManager->ifAvatarHasNemesis(unit);
}
glm::vec2 getAvatarNemesisCell(std::shared_ptr<Avatar> unit){
return m_NemesisManager->getNemesisCell(unit);
}
Expand Down
4 changes: 3 additions & 1 deletion include/Structure/Structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ class Structure : public Util::GameObject, public Selectable, public Huntable {
glm::vec2 getCurrentLocationInCell() override {
return getAbsoluteOccupiedArea()[0];
};

glm::vec2 getTopRightCell(){
return getAbsoluteOccupiedArea()[-1];
};
protected:
float m_ElectricPower;
float m_BuildingTime;
Expand Down
Loading