-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonsterDart.cs
415 lines (379 loc) · 8.19 KB
/
MonsterDart.cs
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
public class MonsterDart : Effect2
{
public int angle;
public int vx;
public int vy;
public short va = 12288;
public int x;
public int y;
public int z;
private int life;
public bool isSpeedUp;
public int dame;
public int dameMp;
public int typeAtt;
public Char c;
public BuNhin b;
public bool isBoss;
public int idBoss;
public short levelBoss;
private int countangle = 1;
public static int level;
public static MyVector vDomsang = new MyVector();
public bool isEnd;
public static int regMirro = 0;
private int frame;
private int index;
public static sbyte[] FRAME = new sbyte[25]
{
0, 1, 2, 1, 0, 1, 2, 1, 0, 1,
2, 1, 0, 1, 2, 1, 0, 1, 2, 1,
0, 1, 2, 1, 0
};
public static int[] TRANSFORM = new int[16]
{
0, 0, 0, 7, 6, 6, 6, 2, 2, 3,
3, 4, 5, 5, 5, 1
};
public static int[] ARROWINDEX = new int[18]
{
0, 15, 37, 52, 75, 105, 127, 142, 165, 195,
217, 232, 255, 285, 307, 322, 345, 370
};
public MonsterDart(int x, int y, bool isBoss, short levelBoss, int idBoss, int dame, int dameMp, Char c)
{
typeAtt = 0;
this.x = x;
this.y = y;
this.isBoss = isBoss;
this.levelBoss = levelBoss;
this.idBoss = idBoss;
this.dame = dame;
this.dameMp = dameMp;
this.c = c;
if (isBoss)
{
setAngle(countangle * 90);
countangle++;
if (countangle > 3)
{
countangle = 1;
}
}
else if (x > c.cx)
{
setAngle(240);
}
else
{
setAngle(300);
}
}
public MonsterDart(int x, int y, BuNhin b)
{
typeAtt = 1;
this.x = x;
this.y = y;
this.b = b;
if (x > b.x)
{
setAngle(240);
}
else
{
setAngle(300);
}
}
public void setAngle(int angle)
{
this.angle = angle;
vx = va * Res.cos(angle) >> 10;
vy = va * Res.sin(angle) >> 10;
}
public static void addMonsterDart(int x, int y, bool isBoss, short levelBoss, int idBoss, int dame, int dameMp, Char c)
{
level = levelBoss;
Effect2.vEffect2.addElement(new MonsterDart(x, y, isBoss, levelBoss, idBoss, dame, dameMp, c));
}
public static void addMonsterDart(int x, int y, BuNhin b)
{
Effect2.vEffect2.addElement(new MonsterDart(x, y, b));
}
public override void update()
{
if (level > 100)
{
Domsang o = new Domsang(x, y, 2);
vDomsang.addElement(o);
}
else if (level > 50 && level <= 100)
{
Domsang o2 = new Domsang(x, y, 5);
vDomsang.addElement(o2);
}
else if (level > 30 && level <= 50)
{
Domsang o3 = new Domsang(x, y, 4);
vDomsang.addElement(o3);
}
else if (level > 0 && level <= 30)
{
Domsang o4 = new Domsang(x, y, 3);
vDomsang.addElement(o4);
}
updateAngle();
int num = 0;
int num2 = 0;
if (typeAtt == 0)
{
num = c.cx - x;
num2 = c.cy - 10 - y;
life++;
if (c.statusMe == 5 || c.statusMe == 14)
{
x += (c.cx - x) / 2;
y += (c.cy - y) / 2;
}
if ((Res.abs(num) < 16 && Res.abs(num2) < 16) || life > 60)
{
c.doInjure(dame, dameMp, isBoss, idBoss);
Effect2.vEffect2.removeElement(this);
return;
}
}
else if (typeAtt == 1)
{
num = b.x - x;
num2 = b.y - 10 - y;
life++;
if ((Res.abs(num) < 16 && Res.abs(num2) < 16) || life > 60)
{
b.doInjure();
Effect2.vEffect2.removeElement(this);
return;
}
}
int num3 = Res.angle(num, num2);
if (Math.abs(num3 - angle) < 90 || num * num + num2 * num2 > 4096)
{
if (Math.abs(num3 - angle) < 15)
{
angle = num3;
}
else if ((num3 - angle >= 0 && num3 - angle < 180) || num3 - angle < -180)
{
angle = Res.fixangle(angle + 15);
}
else
{
angle = Res.fixangle(angle - 15);
}
}
num += vx;
int num4 = num >> 10;
x += num4;
num &= 0x3FF;
num2 += vy;
int num5 = num2 >> 10;
y += num5;
num2 &= 0x3FF;
for (int i = 0; i < vDomsang.size(); i++)
{
Domsang domsang = (Domsang)vDomsang.elementAt(i);
domsang.update();
if (domsang.frame > 3)
{
vDomsang.removeElementAt(i);
}
}
}
private int tickz(int time)
{
return GameCanvas.gameTick % time;
}
private void updateAngle()
{
if (c == null)
{
isEnd = true;
return;
}
int num = c.cx - x;
int num2 = c.cy - (c.ch >> 1) - y;
life++;
if ((Res.abs(num) < 16 && Res.abs(num2) < 16) || life > 60)
{
isEnd = true;
return;
}
int num3 = Res.angle(num, num2);
if (Math.abs(num3 - angle) < 90 || num * num + num2 * num2 > 4096)
{
if (Math.abs(num3 - angle) < 15)
{
angle = num3;
}
else if ((num3 - angle >= 0 && num3 - angle < 180) || num3 - angle < -180)
{
angle = Res.fixangle(angle + 15);
}
else
{
angle = Res.fixangle(angle - 15);
}
}
if (!isSpeedUp && va < 8192)
{
va += 1024;
}
vx = va * Res.cos(angle) >> 10;
vy = va * Res.sin(angle) >> 10;
num += vx;
int num4 = num >> 10;
x += num4;
num &= 0x3FF;
num2 += vy;
int num5 = num2 >> 10;
y += num5;
num2 &= 0x3FF;
index = findDirIndexFromAngle(Res.angle(num4, -num5));
frame = FRAME[index];
regMirro = TRANSFORM[index];
}
public static int findDirIndexFromAngle(int angle)
{
for (int i = 0; i < ARROWINDEX.Length - 1; i++)
{
if (angle >= ARROWINDEX[i] && angle <= ARROWINDEX[i + 1])
{
if (i >= 16)
{
return 0;
}
return i;
}
}
return 0;
}
public override void paint(mGraphics g)
{
if (isBoss)
{
int num = tickz(7);
if (idBoss == 114)
{
if (num < 4)
{
SmallImage.drawSmallImage(g, 1299, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else
{
SmallImage.drawSmallImage(g, 1307, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
}
else if (idBoss == 115)
{
num = tickz(20);
if (num < 4)
{
SmallImage.drawSmallImage(g, 1379, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 8)
{
SmallImage.drawSmallImage(g, 1380, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 12)
{
SmallImage.drawSmallImage(g, 1379, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 16)
{
SmallImage.drawSmallImage(g, 1382, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
}
else if (idBoss == 116)
{
num = tickz(17);
if (num < 4)
{
SmallImage.drawSmallImage(g, 1399, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 8)
{
SmallImage.drawSmallImage(g, 1400, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 12)
{
SmallImage.drawSmallImage(g, 1401, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 16)
{
SmallImage.drawSmallImage(g, 1402, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
}
else if (idBoss == 139)
{
num = tickz(20);
if (num < 4)
{
SmallImage.drawSmallImage(g, 1459, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 8)
{
SmallImage.drawSmallImage(g, 1380, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 12)
{
SmallImage.drawSmallImage(g, 1461, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 16)
{
SmallImage.drawSmallImage(g, 1382, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
}
else if (idBoss == 144 || idBoss == 163)
{
num = tickz(20);
if (num < 4)
{
SmallImage.drawSmallImage(g, 1459, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 8)
{
SmallImage.drawSmallImage(g, 1380, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 12)
{
SmallImage.drawSmallImage(g, 1461, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
else if (num < 16)
{
SmallImage.drawSmallImage(g, 1382, x, y, 0, mGraphics.VCENTER | mGraphics.HCENTER);
}
}
}
else
{
if (level > 100)
{
g.drawRegion(GameScr.imgEffMob, 0, frame * 23, 31, 23, regMirro, x, y, 0);
}
else if (level > 50 && level <= 100)
{
g.drawRegion(GameScr.imgEffMob, 0, 0, 14, 14, regMirro, x, y, 0);
}
else if (level > 30 && level <= 50)
{
g.drawRegion(GameScr.imgEffMob, 0, 0, 8, 8, regMirro, x, y, 0);
}
else if (level > 0 && level <= 30)
{
g.drawRegion(GameScr.imgEffMob, 0, 0, 8, 8, regMirro, x, y, 0);
}
for (int i = 0; i < vDomsang.size(); i++)
{
((Domsang)vDomsang.elementAt(i))?.paint(g);
}
}
}
}