-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathunit.h
102 lines (77 loc) · 2.02 KB
/
unit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef UNIT_H
#define UNIT_H
/* Base class of units(minions/towers) */
#include <QObject>
#include <QJsonObject>
#include "battle.h"
class Unit : public QObject
{
Q_OBJECT
public:
explicit Unit(int hp,
int cost,
float walkSpeed,
int atk,
int attackRange,
int attackDelay,
int group,
Battle *battle,
QObject *parent = 0);
virtual ~Unit();
enum status {
StatusWalkLeft = 0,
StatusWalkRight,
StatusWalkTop,
StatusWalkDown,
StatusWalkLT,
StatusWalkLD,
StatusWalkRT,
StatusWalkRD,
StatusAttackLeft,
StatusAttackRight,
StatusStopRight,
StatusStopLeft
};
int getCurrentHp();
int getMaxHp();
int getHpRatio();
int getHpChange();
int getCost();
void setTarget(int target);
void onhit(int enemyATK);
virtual QJsonObject toJsonObject(bool isNew = false) = 0;
friend class Minion;
friend class Tower;
friend class Battle;
friend class ElfArcher;
friend class ElfGiant;
friend class ElfWisp;
friend class ElfDancer;
friend class HumanKnight;
friend class HumanPriest;
friend class HumanThief;
friend class Sgram;
friend class UndeadSamurai;
// Add Rifleman
friend class HumanRifleman;
public slots:
virtual void active(); /* Game clock */
void setPreviousHpRatio();
private:
const int MaxHp;
int hp; /* Hitpoint */
int cost; /* summon cost */
float walkSpeed; /* walking speed */
int atk; /* attack damage */
int attackRange; /* unit detect range */
int attackDelay; /* unit attack delay */
int attackCnt = 0; /*unit attack delay count */
float x;
float y;
int group; /* friend or enemy */
int target; /* healers use minus attack at friend */
Battle *battle; /* parent battle field */
int stat;
int previousHpRatio;
};
#endif // UNIT_H