forked from ShinyLuxray/LastStandDefence
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTower.java
More file actions
295 lines (254 loc) · 7.4 KB
/
Tower.java
File metadata and controls
295 lines (254 loc) · 7.4 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
import java.lang.Math;
import java.util.Random;
public class Tower
{
int id;
int period;
int damage;
int range;
int upPeriod = 0,upDamage = 0,upRange = 0;
int killcount = 0; //used for laser special ability
boolean overheat = false; //taser special ability
boolean gameover = false; //quick fix
double rotation;
final Position pos;
static int atkindex = 0;
public Tower (int initializeid, Position p)
{
this.pos = p;
this.id = initializeid;
System.out.println("This tower has ID: " + id);
//hardcode shit
//if (id == 0)
//{
// damage = ...; ...
//}
if(id == 1) // The cannon; slow-firing with low range, but relatively nice damage
{
period = 1250;
damage = 15;
range = 5;
}
else if(id == 2) // The laser; this piece of shit doesn't really have any redeeming qualities
{
period = 900;
damage = 7;
range = 7;
}
else if(id == 3) // The rocket; this thing is OP as fuck because of its long range
{
period = 1750;
damage = 25;
range = 10;
}
else if(id == 4) // The taser; basically just RoF
{
period = 250;
damage = 2;
range = 1;
}
}
public Position getPos()
{
return pos;
}
public int getRange()
{
return range;
}
public int getPower()
{
return damage;
}
public int getPeriod()
{
return period;
}
public int getType()
{
return id;
}
public int getUpPeriod()
{
return upPeriod;
}
public int getUpDamage()
{
return upDamage;
}
public int getUpRange()
{
return upRange;
}
public Double getRotation()
{
return rotation;
}
public void setRotation(Double radians)
{
rotation = radians;
}
public int getValue()
{
int moneyz = 100+id*100,price = 100;
for(int a = 0;a<5;a++)
{
price*=2;
if(upRange>a)
moneyz += price;
if(upDamage>a)
moneyz += price;
if(upPeriod>a)
moneyz += price;
}
return moneyz;
}
public boolean upgrade (String statToUpgrade)
{
if(statToUpgrade.toLowerCase().equals("period")||statToUpgrade.toLowerCase().equals("rate"))
{
System.out.println("Upgrading rate");
if(LSD.money<(int)Math.pow(2,upPeriod+1))
return false;
LSD.money-=(int)Math.pow(2,upPeriod+1);
upPeriod++;
if (id != 4)
{
period=(period*3)/4;
}
if (id == 4)
{
period = (period*5)/6;
}
if (id == 4 && upDamage == 8 && upPeriod == 8 && upRange == 8) //taser special ability
{
overheat = true;
damage*= 3;
range += 5;
}
return true;
}
else if (statToUpgrade.toLowerCase().equals("range"))
{
System.out.println("Upgrading Range");
if(LSD.money<(int)Math.pow(2,upRange+1))
return false;
LSD.money-=(int)Math.pow(2,upRange+1);
upRange++;
if (id != 4&&(upRange/2)*2 == upRange)
{
System.out.println ("Upgraded Range");
range = range++;
}
if (id == 4 && upDamage == 8 && upPeriod == 8 && upRange == 8) //taser special ability
{
overheat = true;
damage*= 3;
range += 5;
}
return true;
}
else if(statToUpgrade.toLowerCase().equals("damage"))
{
System.out.println("Upgrading Damage");
if(LSD.money<(int)Math.pow(2,upDamage+1))
System.out.println("NO MONEY");
LSD.money-=(int)Math.pow(2,upDamage+1);
upDamage++;
System.out.println("upDamage: " + upDamage);
damage++;
if (id == 4 && upDamage == 8 && upPeriod == 8 && upRange == 8) //taser special ability
{
overheat = true;
damage*= 3;
range += 5;
}
return true;
}
else
{
return false;
}
}
protected void fire()
{
atkindex = -1;
System.out.println("atkindex: " + atkindex);
int maxPathID = -1;
for (int i = 0; i < LSD.wave.size(); i++)
{
if (LSD.wave.get(i).inRange(Tower.this))
{
if (LSD.wave.get(i).getPathId() > maxPathID)
{
maxPathID = LSD.wave.get(i).getPathId();
atkindex = i;
//System.out.println ("Checking");
}
}
}
if(atkindex!=-1)
{
//System.out.println ("Attacking");
if (id == 3 && upDamage == 8 && upPeriod == 8 && upRange == 8) //taser special ability
{
overheat = true;
LSD.money += 5;
}
try
{
if(LSD.wave.get(atkindex).inRange(Tower.this)&&LSD.wave.get(atkindex).hit(damage))
{
if (overheat)
{
LSD.money-=100;
if (LSD.money < 0)
{
LSD.lives = 0;
if (!gameover)
{
LSD.gg();
gameover = true;
}
}
}
killcount++;
if (id == 2 && upDamage == 8 && upPeriod == 8 && upRange == 8) //laser special ability
{
if(killcount >= 75)
{
killcount = 0;
if (LSD.lives < 10)
{
LSD.lives++;
}
}
}
if (id == 3 && upDamage == 8 && upPeriod == 8 && upRange == 8) //rocket special ability
{
LSD.money+= LSD.waves;
}
//System.out.println("Removed: " + atkindex);
LSD.wave.remove(atkindex);
LSD.kills++;
if(LSD.wave.size()==0)
LSD.waveDone = true;
}
else
{
if (id == 2 && upDamage == 8 && upPeriod == 8 && upRange == 8) //cannon special ability
{
Random ran = new Random();
int i = ran.nextInt(5);
if (i == 3)
{
LSD.wave.get(atkindex).hit(999999999);
}
}
}
}
catch(Exception e)
{}
}
}
}