-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData.java
More file actions
370 lines (323 loc) · 10.8 KB
/
Data.java
File metadata and controls
370 lines (323 loc) · 10.8 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
import greenfoot.*;
/**
* The class to hold various data
*
* @author James Lu
* @version 0.01
*/
public class Data
{
/** ------------------------------- Mob Data ------------------------------**/
private mobQueue q;
private mobNode mob;
private int type;
private int nextType;
private int spawnRate;
private int maxSpawn;
private int hp;
private int armor;
private float speed;
private boolean isBoss;
private boolean isFlying;
/** -------------------------- Other Random Stuff ------------------------**/
/** The elemental damage chart*/
public static final float[][] elementDamage =
//2 supper effective, 1 normal, 0.75 not really effective, 0.5 not effective
// defender //attacker
{ //air, water, fire, earth
{0.75f, 2, 1, 0.5f}, //air
{0.5f, 0.75f, 2, 1}, //water
{1, 0.5f, 0.75f, 2}, //fire
{2, 1, 0.5f, 0.75f} //earth
};
public static final String[] elementName =
{
"Air", "Water", "Fire", "Earth"
};
public static final GreenfootImage[] debuffs =
{
new GreenfootImage ("Debuff/stunned.png"), new GreenfootImage ("Debuff/lightning.png"),
new GreenfootImage ("Debuff/freeze.png"), new GreenfootImage ("Debuff/burning.png"),
new GreenfootImage ("Debuff/stone.png")
};
public static final int[][] debuffDuration = {
//stun lightning, freeze, burn, earth
{ 11, 100, 100, 100, 100}
};
public static final double[] debuffChance = {
0.05f, 0.1f, 0.15f, 0.07f, 0.09f
};
public static final GreenfootImage[] stun = {
new GreenfootImage ("Debuff/stun/1.png"), new GreenfootImage ("Debuff/stun/2.png"),
new GreenfootImage ("Debuff/stun/3.png"), new GreenfootImage ("Debuff/stun/4.png"),
new GreenfootImage ("Debuff/stun/5.png"), new GreenfootImage ("Debuff/stun/6.png")
};
public static final GreenfootImage[] air = {
new GreenfootImage ("Debuff/air/1.png"), new GreenfootImage ("Debuff/air/1.png")
};
public static final GreenfootImage[] freeze = {
new GreenfootImage ("Debuff/freeze/1.png"), new GreenfootImage ("Debuff/freeze/1.png")
};
public static final GreenfootImage[] burn = {
new GreenfootImage ("Debuff/burn/1.png"), new GreenfootImage ("Debuff/burn/1.png")
};
public static final GreenfootImage[] stone = {
new GreenfootImage ("Debuff/stone/1.png"), new GreenfootImage ("Debuff/stone/1.png")
};
public Data(){
q = new mobQueue();
populate();
}
private void updateData(){
this.type = mob.type;
this.nextType = mob.nextType;
this.spawnRate = mob.spawnRate;
this.maxSpawn = mob.maxSpawn;
this.hp = mob.hp;
this.armor = mob.armor;
this.speed = mob.speed;
this.isBoss = mob.isBoss;
this.isFlying = mob.flying;
}
/**
* Updates this class with the next level enemy stats
*/
public void nextLevel(){
mob = q.dequeue();
updateData();
}
/**
* populates the mobs queue with 50 levels worth of data
*/
public void populate(){
int currentElement = 1;
boolean isBoss = false;
//hard code first level
q.enqueueFirst (1, 2, 20, 12, 20, 1, 3, false, false);
for (int i = 2; i <= 50; i++){
currentElement = i%4;
isBoss = i%10 == 0;
if (!isBoss){ //if its not a boss
if (currentElement == 1){ //air
type = 1;
nextType = 2;
spawnRate = 20;
maxSpawn = 12;
hp = i * 20;
armor = i;
speed = 2;
}
else if (currentElement == 2){ //water
type = 2;
nextType = 3;
spawnRate = 20;
maxSpawn = 7;
hp = i * 20;
armor = i / 3 * 4;
speed = 1.7f;
}
else if (currentElement == 3){ //fire
type = 3;
nextType = 4;
spawnRate = 5;
maxSpawn = 20;
hp = i * 10;
armor = i / 2;
speed = 2.4f;
}
else if (currentElement == 0){ //earth
type = 4;
nextType = 1;
spawnRate = 20;
maxSpawn = 10;
hp = i * 30;
armor = i * 2;
speed = 1;
}
hp = Math.round(hp * i * 0.3f);
}
else{ //if its a boss
if (currentElement == 1){ //air boss
type = 1;
nextType = 2;
hp = i * 20;
armor = i/10 + 1;
speed = 4;
}
else if (currentElement == 2){ //water boss
type = 2;
nextType = 3;
hp = i * 20;
armor = i + i/5;
speed = 0.3f;
}
else if (currentElement == 3){ //fire boss
type = 3;
nextType= 4;
hp = i * 20;
armor = i/10 + 2;
speed = 2.5f;
}
else if (currentElement == 0){ //earth boss
type = 4;
nextType= 1;
hp = i * 60;
armor = i + 1;
speed = 0.5f;
}
spawnRate = 5;
maxSpawn = 1;
hp =Math.round( hp * 0.5f*i + 800) ;
}
q.enqueue (type, nextType, spawnRate, maxSpawn, hp, armor, speed, isBoss, isFlying);
}
}
/** ------------------------------- methods that return data -------------------------------*/
/**
* Returns the type of the current enemy
*/
public int getType(){
return type;
}
/**
* Returns the type of the next wave enemy
*/
public int getNextType(){
return nextType;
}
/**
* Returns the spawn rate of the current enemy
*/
public int getSpawnRate(){
return spawnRate;
}
/**
* Returns the max amount of the current enemy that will spawn
*/
public int getMaxSpawn(){
return maxSpawn;
}
/**
* Returns the max hp of the current enemy
*/
public int getHp(){
return hp;
}
/**
* Returns the armor of the current enemy
*/
public int getArmor(){
return armor;
}
/**
* Returns the speed of the current enemy
*/
public float getSpeed(){
return speed;
}
/**
* Returns true if the currenent emeny is a boss
*/
public boolean ifBoss(){
return isBoss;
}
/**
* Returns true if the currenent enemy is flying
*/
public boolean ifFlying(){
return isFlying;
}
/**
* Returns the max number of enemies in the next wave
*/
public int getNextWaveSpawnCount(){
return q.first.next.maxSpawn;
}
/**
* Returns the current max spawn count without dequing
*/
public int getCurrentMaxSpawn(){
return q.first.maxSpawn;
}
/**================================= Data Structure Class ==================================**/
private class mobQueue{
private mobNode first;
private mobNode last;
private int length;
public mobQueue(){
first = null;
last = null;
length = 0;
}
/**
* Returns true if the queue is empty
*/
public boolean isEmpty(){
return length == 0;
}
/**
* Enques a level's worth of information <br>
* Each level's mob stats is stored here
*/
public void enqueue(int type, int nextType, int spawnRate, int maxSpawn,
int hp, int armor, float speed, boolean isBoss, boolean flying){
mobNode temp = new mobNode (type, nextType, spawnRate, maxSpawn, hp, armor, speed, isBoss, flying);
last.next = temp;
last = temp;
length++;
}
/**
* Only called once; for the first time to initalize the queue <br>
* The stats of the first level is stored in here
*/
public void enqueueFirst(int type, int nextType, int spawnRate, int maxSpawn,
int hp, int armor, float speed, boolean isBoss, boolean flying){
first = new mobNode (type, nextType, spawnRate, maxSpawn, hp, armor, speed, isBoss, flying);
last = first;
}
/**
* Returns a mobNode that stores the data of the current wave
*/
public mobNode dequeue(){
if (length != 0){
mobNode temp = first;
first = first.next;
length --;
return temp;
}
return null;
}
}
private class mobNode{
private mobNode next;
private int type;
private int nextType;
private int spawnRate;
private int maxSpawn;
private int hp;
private int armor;
private float speed;
private boolean isBoss;
private boolean flying;
public mobNode(){
next = null;
}
/**
* Creates a new mobNode with the passed on parameters <br>
* It holds the data for each wave
*/
public mobNode(int type, int nextType, int spawnRate, int maxSpawn,
int hp, int armor, float speed, boolean isBoss, boolean flying){
this();
this.type = type;
this.nextType = nextType;
this.spawnRate = spawnRate;
this.maxSpawn = maxSpawn;
this.hp = hp;
this.armor = armor;
this.speed = speed;
this.isBoss = isBoss;
this.flying = flying;
}
}
}