-
Notifications
You must be signed in to change notification settings - Fork 0
/
qttdsprite.h
147 lines (110 loc) · 3.07 KB
/
qttdsprite.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef QTTDSPRITE_H
#define QTTDSPRITE_H
#include <QGraphicsItem>
#include "qttdpath.h"
#include "qttdcontext.h"
class QtTDSprite : public QGraphicsItem
{
public:
enum Color {
Red,
Green,
Blue,
Yellow,
Other
};
enum DamageType {
Normal,
Speed,
Power,
Time
};
struct Size {
QChar letter;
qreal scaleMod;
Size(QChar l, qreal scaleMod) {
letter = l;
scaleMod = scaleMod;
}
};
static const Size small;
static const Size normal;
static const Size large;
QtTDSprite();
qreal getPreferredDelay();
void doTick(int gameTime);
void resetScale();
//public void paint(Graphics2D g2, int gameTime);
qreal getX();
qreal getY();
qreal getPaintX();
qreal getPaintY();
bool isValidTarget();
bool isDead();
long getHealth();
qreal getProgress();
void remove();
void doDamage(int damage, Color c);
void doDamage(qreal damage, DamageType t, Color c);
qreal getSpeed();
bool isShielded();
//void setSize(Size s);
void setSelected(bool selected);
QString getInfoString();
QString getStatusString();
//void addStatusListener(EnemySpriteChangedListener l);
//void removeStatusListener(EnemySpriteChangedListener l);
//public EnemySprite create(Context context, int path, float delay, long health, int price, Size s);
protected:
Size size;
QString name;
//
bool inactive;
bool validTarget;
bool dead;
int price;
QColor damageColor;
QColor damageColorAnti;
qreal delay;
qreal xFloat, yFloat;
qreal xPaint, yPaint;
qreal paintScale;
QTransform atTranslate;
QtTDPath path;
int segment;
int segmentProgression;
QVector<qreal> segmentStartPoint;
QVector<qreal> segmentEndPoint;
qreal progress;
qreal preferredDelay;
qreal acceleration;
qreal speed; // * 1/1000 segments per tick
qreal speedMax; // * 1/1000 segments per tick
qreal speedMaxBase; // * 1/1000 segments per tick
qreal speedRepairTime;
qreal power; // power > speedMax => speed = speedMax
qreal powerBase; // power > speedMax => speed = speedMax
qreal powerRepairTime;
long health;
long healthMax;
QAbstractGraphicsShapeItem* healthLineShape;
QPainterPathStroker healthLineStroke;
QColor healthLineColor;
qreal shieldRotationStep;
qreal shieldW;
qreal shieldH;
int shieldO;
QColor shieldColor;
QPainterPathStroker shieldStroke;
bool shielded;
bool selected;
//
QtTDContext *context;
//Vector<EnemySpriteChangedListener> listeners; // signal slot
//
//static DecimalFormat form = new DecimalFormat("#,###.#");
};
const QtTDSprite::Size QtTDSprite::small(QChar('S'), qreal(0.5));
const QtTDSprite::Size QtTDSprite::normal(QChar('N'), qreal(1.0));
const QtTDSprite::Size QtTDSprite::large(QChar('L'), qreal(1.5));
#endif // QTTDSPRITE_H