-
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.
Merge pull request #25 from ntut-Tu/TEST
button update
- Loading branch information
Showing
11 changed files
with
156 additions
and
56 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
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,51 @@ | ||
// | ||
// Created by nudle on 2024/3/15. | ||
// | ||
|
||
#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_PATHFINDINGUNIT_HPP | ||
#define PRACTICALTOOLSFORSIMPLEDESIGN_PATHFINDINGUNIT_HPP | ||
|
||
#include "Tile.hpp" | ||
#include "Util/GameObject.hpp" | ||
#include "Map.hpp" | ||
class PathfindingUnit:public Util::GameObject{ | ||
private: | ||
enum class UnitMode{ | ||
Attacking,Moving,Stop | ||
}; | ||
enum class MoveDirection{ | ||
Up,TopRight,TopLeft,Right,Left,DownRight,DownLeft,Down,Wait | ||
}; | ||
|
||
glm::vec2 m_targetCell; | ||
glm::vec2 m_nextCell; | ||
glm::vec2 m_currentCell; | ||
glm::vec2 m_currentLocation; | ||
|
||
MoveDirection m_currentDir=MoveDirection::Wait; | ||
|
||
float m_Hp=100.F; | ||
float m_MoveSpeed=1.F; | ||
|
||
public: | ||
PathfindingUnit(){}; | ||
~PathfindingUnit(){}; | ||
|
||
void setTargetCell(glm::vec2 target){this->m_targetCell=target;} | ||
glm::vec2 getTargetCell(){return m_targetCell;} | ||
|
||
void findNextCell() { | ||
if (m_targetCell.x - m_currentCell.x >m_targetCell.y - m_currentCell.y &&m_targetCell.x - m_currentCell.x > 0) { | ||
m_currentDir = MoveDirection::Right; | ||
} else if (m_targetCell.x - m_currentCell.x >m_targetCell.y - m_currentCell.y &&m_targetCell.x - m_currentCell.x < 0) { | ||
m_currentDir = MoveDirection::Up; | ||
} else if (m_targetCell.x - m_currentCell.x <m_targetCell.y - m_currentCell.y &&m_targetCell.x - m_currentCell.x > 0) { | ||
m_currentDir = MoveDirection::Down; | ||
}else if(m_targetCell.x-m_currentCell.x<m_targetCell.y-m_currentCell.y&&m_targetCell.x-m_currentCell.x<0){ | ||
m_currentDir=MoveDirection::Left; | ||
}else if(m_targetCell.x-m_currentCell.x==m_targetCell.y-m_currentCell.y&&m_targetCell.x-m_currentCell.x<0){ | ||
m_currentDir=MoveDirection::Down; | ||
} | ||
} | ||
}; | ||
#endif // PRACTICALTOOLSFORSIMPLEDESIGN_PATHFINDINGUNIT_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
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.