-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActor.h
More file actions
295 lines (251 loc) · 8.21 KB
/
Actor.h
File metadata and controls
295 lines (251 loc) · 8.21 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#ifndef ACTOR_H_
#define ACTOR_H_
#include "GraphObject.h"
#include "StudentWorld.h"
class StudentWorld;
class Agent;
class Pea;
//Actor Def
class Actor: public GraphObject {
public:
Actor(int imageID, double startX, double startY, int HP, StudentWorld* world);
virtual~Actor() {}
virtual void doSomething() = 0;
bool isAlive() const {
if (m_HP <= 0) {
return false;
}
return true;
}
//Set dead
void setDead() { setHitPoints(0); }
void decHitPoints(int amt) { m_HP -= amt; }
StudentWorld* getWorld() const { return m_World; }
virtual bool allowsAgentColocation() const { return false; }
virtual bool allowsMarbleColocation() const { return false; }
virtual bool countsInFactoryCensus() const { return false; }
virtual bool stopsPea() const { return true; }
virtual bool isDamageable() const { return false; }
virtual void damage(int damageAmt) { m_HP -= damageAmt; }
virtual bool bePushedBy(Agent* a, int x, int y) { return false; }
virtual bool isSwallowable() const { return false; }
virtual bool isStealable() const { return false; }
virtual int getHP() const { return m_HP; }
virtual void setHitPoints(int amt) { m_HP = amt; }
virtual bool tryToBeKilled(int damageAmt) {
damage(damageAmt);
if (isAlive()) {
return true;
}
return false;
}
virtual bool isAPea() { return false; }
virtual bool isCrystal() { return false; }
virtual bool isThiefBot() { return false; }
void spaceInFrontofActor(int dir, int& x, int& y);
private:
StudentWorld* m_World;
int m_HP;
};
//Agent Def
class Agent : public Actor {
public:
Agent (int imageID, double startX, double startY, StudentWorld* world, int HP);
bool moveIfPossible();
virtual bool canPushMarbles() const { return false; }
virtual bool needsClearShot() const { return true; }
virtual int shootingSound() const { return SOUND_ENEMY_FIRE; }
virtual bool isDamagable() const { return true; } //Added by me
private:
};
//Avatar Def
class Avatar : public Agent {
public:
Avatar(double startX, double startY, StudentWorld* world);
virtual~Avatar() {}
//Virtual Functions
virtual bool allowsAgentColocation() { return true; }
virtual void doSomething();
virtual void damage(int damageAmt) { setHitPoints(getHP() - damageAmt);}
virtual bool canPushMarbles() const { return true; }
virtual bool needsClearShot() const { return false; }
virtual int shootingSound() const { return SOUND_PLAYER_FIRE; }
//Other Functions
int getHealthPct() const { return (getHP() / 20) * 100; }
int getAmmo() const { return m_ammo; }
void restoreHealth() { setHitPoints(20); }
void increaseAmmo() { m_ammo += 20; }
private:
int m_ammo = 20;
Pea* p;
};
//Robot Def
class Robot : public Agent {
public:
Robot(StudentWorld* world, int startX, int startY, int imageID,
int hitPoints, int score, int startDir);
virtual bool allowsAgentColocation() { return true; }
virtual void doSomething();
virtual void doDiffRobotSomething() { }
virtual bool isDamageable() const { return true; }
virtual bool canPushMarbles() const { return false; }
virtual bool needsClearShot() const { return true; }
virtual int shootingSound() const { return SOUND_ENEMY_FIRE; }
virtual bool isShootingRobot() const { return true; }
int getRobotScore() { return robot_score; }
virtual void damage(int damageAmt);
bool peaCanFire();
void firePea();
private:
bool actionTick();
int m_tick;
int robot_score;
Pea* robot_p;
};
//RageBot Definitions
class RageBot : public Robot {
public:
RageBot(StudentWorld* world, int startX, int startY, int startDir);
virtual void doDiffRobotSomething();
void moveRageBot();
};
//VerticalRageBot Definitions
class VerticalRageBot : public RageBot {
public:
VerticalRageBot(StudentWorld* world, int startX, int startY);
};
class HorizontalRageBot : public RageBot {
public:
HorizontalRageBot(StudentWorld* world, int startX, int startY);
};
class ThiefBot : public Robot {
public:
ThiefBot(StudentWorld* world, int startX, int startY, int imageID,
int hitPoints, int score);
virtual void doDiffRobotSomething();
virtual void doThiefBotSomething() = 0;
virtual bool countsInFactoryCensus() const { return true; }
virtual void damage(int damageAmt);
int getDistanceBeforeTurning() { return distanceBeforeTurning; }
virtual bool isThiefBot() { return true; }
private:
int distanceBeforeTurning;
int curDistance;
Actor* goodieP;
};
class RegularThiefBot : public ThiefBot {
public:
RegularThiefBot(StudentWorld* world, int startX, int startY);
virtual void doThiefBotSomething() {}
virtual bool isShootingRobot() const { return false; }
};
class MeanThiefBot : public ThiefBot {
public:
MeanThiefBot(StudentWorld* world, int startX, int startY);
virtual void doThiefBotSomething();
};
class ThiefBotFactory : public Actor {
public:
enum ProductType { REGULAR, MEAN };
ThiefBotFactory(StudentWorld* world, int startX, int startY, ProductType type);
virtual void doSomething();
virtual bool stopsPea() const { return true; }
private:
ProductType m_Type;
ThiefBot* m_ThiefBot;
};
//Exit Def
class Exit : public Actor {
public:
Exit(StudentWorld* world, int startX, int startY);
virtual void doSomething();
virtual bool allowsAgentColocation() const { return true; }
virtual bool allowsMarbleColocation() const {
if (isVisible()) {
return false;
}
return true;
}
};
//Wall Def
class Wall : public Actor {
public:
Wall(double startX, double startY, StudentWorld* world);
virtual void doSomething() { return; } //Need to fix
virtual bool stopsPea() const { return true; }
};
//Pea Def
class Pea : public Actor {
public:
Pea(StudentWorld* world, int startX, int startY, int startDir);
void checkToDoDamage(int& x, int& y);
virtual void doSomething();
virtual bool allowsAgentColocation() const { return true; };
virtual bool isAPea() { return true; }
};
//Marble Definitions
class Marble : public Actor {
public:
Marble(StudentWorld * world, int startX, int startY);
virtual void doSomething() {}
virtual bool isDamageable() const { return true; }
virtual void damage(int damageAmt);
virtual bool isSwallowable() const { return true; }
virtual bool bePushedBy(Agent * a, int x, int y);
};
//Pit Definitions
class Pit : public Actor {
public:
Pit(StudentWorld* world, int startX, int startY);
virtual void doSomething();
virtual bool allowsMarbleColocation() const { return true; }
virtual bool stopsPea() const { return false; }
};
//PickupableItem Defintions
class PickupableItem : public Actor {
public:
PickupableItem(StudentWorld* world, int startX, int startY, int imageID,
int score);
virtual void doSomething();
virtual void doItemSomething() = 0;
virtual bool allowsAgentColocation() const { return true; }
virtual bool allowsMarbleColocation() const { return true; }
int getItemScore() { return item_Score; }
private:
int item_Score;
};
//Crystal Definitions
class Crystal : public PickupableItem {
public:
Crystal(StudentWorld* world, int startX, int startY);
virtual void doItemSomething() {}
virtual bool isCrystal() { return true; }
};
//Goodie Definitions
class Goodie : public PickupableItem {
public:
Goodie(StudentWorld* world, int startX, int startY, int imageID,
int score);
virtual void doItemSomething() = 0;
virtual bool isStealable() const { return true; }
// Set whether this goodie is currently stolen.
void setStolen(bool status) { isStolen = status; }
private:
bool isStolen = false;
};
class ExtraLifeGoodie : public Goodie {
public:
ExtraLifeGoodie(StudentWorld* world, int startX, int startY);
virtual void doItemSomething();
};
class RestoreHealthGoodie : public Goodie {
public:
RestoreHealthGoodie(StudentWorld* world, int startX, int startY);
virtual void doItemSomething();
};
class AmmoGoodie : public Goodie {
public:
AmmoGoodie(StudentWorld* world, int startX, int startY);
virtual void doItemSomething();
};
#endif // ACTOR_H_