-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeaponProperties.cpp
223 lines (201 loc) · 4.73 KB
/
WeaponProperties.cpp
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
#include "WeaponProperties.h"
#include <iostream>
// This method exists as array initialization. It should not be used in any other context
WeaponProperties::WeaponProperties():weaponQuantity(0),maxQuantity(0),type(_None),shotsTaken(0)
{
Initialize(type);
}
WeaponProperties::WeaponProperties(WeaponType type, int maxQuantity):weaponQuantity(0),maxQuantity(maxQuantity),type(type),shotsTaken(0)
{
Initialize(type);
}
void WeaponProperties::AddShotTaken()
{
shotsTaken++;
}
bool WeaponProperties::GetActive() const
{
return active;
}
int WeaponProperties::GetCost() const
{
return cost;
}
int WeaponProperties::GetClipSize() const
{
return clipSize;
}
int WeaponProperties::GetDamage() const
{
return damage;
}
int WeaponProperties::GetFireRate() const
{
return fireRate;
}
int WeaponProperties::GetMaxQuantity() const
{
return maxQuantity;
}
int WeaponProperties::GetRadius() const
{
return radius;
}
int WeaponProperties::GetRange() const
{
return range;
}
int WeaponProperties::GetReloadRate() const
{
return reloadRate;
}
int WeaponProperties::GetShotsTaken() const
{
return shotsTaken;
}
WeaponType WeaponProperties::GetType() const
{
return type;
}
int WeaponProperties::GetWeaponQuantity() const
{
return weaponQuantity;
}
/* Defaults
Type None Gun WideShot ExplodingShot Grenade Mine Nuke WallBreaker
Cost 0 0 1000 8000 300 1000 10000 5000
Range 0 120 120 120 240 0 0 600
Damage 0 10 15 20 80 200 1000 0
Radius 0 1 3 20 30 5 400 0
Clip Size 0 25 25 25 1 1 1 1
Fire Rate 0 10 10 20 200 200 10000 200
Reload Rate 0 60 60 60 0 0 0 0
Active F T T T T T T T
*/
void WeaponProperties::Initialize(WeaponType type)
{
switch (type)
{
case _None:
cost = 0;
range = 0;
damage = 0;
radius = 0;
clipSize = 0;
fireRate = 0;
reloadRate = 0;
active = false;
break;
case _Gun:
cost = 0;
range = 120;
damage = 10;
radius = 1;
clipSize = 25;
fireRate = 10;
reloadRate = 60;
active = true;
break;
case _WideShot:
cost = 1000;
range = 120;
damage = 2;
radius = 3;
clipSize = 25;
fireRate = 10;
reloadRate = 60;
active = true;
break;
case _ExplodingShot:
cost = 8000;
range = 120;
damage = 5;
radius = 20; // only after contact. Implemented in separate class.
clipSize = 25;
fireRate = 20;
reloadRate = 60;
active = true;
break;
case _Grenade:
cost = 60;
range = 240;
damage = 80;
radius = 30;
clipSize = 1;
fireRate = 50;
reloadRate = 0;
active = true;
break;
case _Mine:
cost = 1000;
range = 0;
damage = 200;
radius = 30;
clipSize = 1;
fireRate = 10;
reloadRate = 0;
active = true;
break;
case _Nuke:
cost = 10000;
range = 0;
damage = 1000; // > MAX_HEALTH of an enemy
radius = 400;
clipSize = 1;
fireRate = 100;
reloadRate = 0;
active = true;
break;
case _WallBreaker:
cost = 5000;
range = 600;
damage = 0;
radius = 0;
clipSize = 1;
fireRate = 10;
reloadRate = 0;
active = true;
break;
case _Enemy:
cost = 0;
range = 1;
damage = 5;
radius = 10;
clipSize = 1;
fireRate = 10;
reloadRate = 0;
active = false;
break;
default:
std::cerr << "The selected weapon type does not have an initializer.\n";
}
}
void WeaponProperties::ResetShotsTaken()
{
shotsTaken = 0;
}
void WeaponProperties::SetActive(bool active)
{
this->active = active;
}
void WeaponProperties::SetClipSize(int clipSize)
{
this->clipSize = clipSize;
}
void WeaponProperties::SetDamage(int damage)
{
this->damage = damage;
}
void WeaponProperties::SetFireRate(int fireRate)
{
this->fireRate = fireRate;
}
void WeaponProperties::SetRange(int range)
{
this->range = range;
}
void WeaponProperties::SetWeaponQuantity(int quantity)
{
if (quantity <= maxQuantity)
weaponQuantity = quantity;
}