units
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#ifndef UNIT_H
|
||||
#define UNIT_H
|
||||
|
||||
#include <QString>
|
||||
#include <QVector3D>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include "unitconfig.h"
|
||||
#include "terrain.h"
|
||||
#include "matrix2d.h"
|
||||
|
||||
enum class UnitState {
|
||||
Idle,
|
||||
Moving,
|
||||
Attacking
|
||||
};
|
||||
|
||||
class Unit {
|
||||
public:
|
||||
Unit(int uId, int pId, const UnitConfig &cfg, int startX, int startY, float groundZ);
|
||||
|
||||
int id;
|
||||
int playerId;
|
||||
UnitConfig config;
|
||||
int tileX;
|
||||
int tileY;
|
||||
QVector3D worldPos;
|
||||
float health;
|
||||
float maxHealth;
|
||||
UnitState state;
|
||||
|
||||
// Movement Path
|
||||
std::vector<std::pair<int, int>> path;
|
||||
size_t pathIndex;
|
||||
float moveProgress; // 0.0 to 1.0 between hexes
|
||||
int targetTileX;
|
||||
int targetTileY;
|
||||
|
||||
// Attack cooldown / flash
|
||||
float attackFlashTimer;
|
||||
|
||||
void update(float deltaTime, float tickDuration, float simSpeedMultiplier,
|
||||
Matrix2D<TerrainPoint> *mapPoints, int numPoints05);
|
||||
void setPath(const std::vector<std::pair<int, int>> &newPath);
|
||||
void stopMovement();
|
||||
|
||||
bool canAttack(const Unit &other) const;
|
||||
void performAttack(Unit &target);
|
||||
void takeDamage(float damage);
|
||||
bool isDead() const { return health <= 0.001f; }
|
||||
|
||||
static float getTerrainHeight(float worldX, float worldY, Matrix2D<TerrainPoint> *mapPoints, int numPoints05);
|
||||
};
|
||||
|
||||
#endif // UNIT_H
|
||||
Reference in New Issue
Block a user