-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSkillData.java
executable file
·1591 lines (1509 loc) · 41.7 KB
/
SkillData.java
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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.util.ArrayList;
import javax.swing.ImageIcon;
public class SkillData {
Data data;
int[] skillType = new int[4];//1,2,3=直接發動, 開關, 需要點擊目標
SkillData(){
}
SkillData(Data data){
this.data = data;
skillType = new int[]{1,3,2,3};
}
public void activate(Unit unit,int skillNum){
//CD轉好就可以發動
if(data.noCD||unit.skillCD[skillNum]>=unit.skillCDmax[skillNum]){
switch(unit.getSkill()[skillNum]){
case 1: //水夢靈
unit.skillCD[skillNum]=0;
if(data.noMP||unit.getMP()>=(100+10*unit.getLevel())){
if(!data.noMP)
unit.setMP(unit.getMP()-(100+10*unit.getLevel()));
skill1(unit,unit.getSkillLevel()[0]);
}
//nuclear(unit);
//laser(unit,3000,Color.BLUE,200,200);
//danmaku(unit,9,2,4,150,10,15,30);
break;
case 2://高壓噴泉
if(data.noMP||unit.getMP()>=100){
target();
data.setWaitSkill(2);
}
break;
case 3://水靈盾
unit.skillCD[skillNum]=0;
if(data.noMP||unit.getMP()>=(20*unit.getLevel())){
if(!data.noMP)
unit.setMP(unit.getMP()-(20*unit.getLevel()));
skill3(unit,unit.getSkillLevel()[2]);
}
break;
case 4://潮吹巨浪
unit.skillCD[skillNum]=0;
if(data.noMP||unit.getMP()>=(150+10*unit.getLevel())){
if(!data.noMP)
unit.setMP(unit.getMP()-(150+10*unit.getLevel()));
skill4(unit,unit.getSkillLevel()[3]);
}
break;
case 5: danmaku(unit,11,2,4,300,5,10,30);
break;
case 6: splitBomb(unit,12,2,3,100,1,60,30);
break;
case 7: laser(unit,1000,Color.BLUE,80,10);
break;
case 8: nuclear(unit);
break;
case 9:
flowerRecoveer(unit,unit.getLevel());
break;
case 10:
windflower(unit,unit.getLevel());
break;
case 11:
sakura(unit,unit.getLevel());
break;
case 12:
godnessflower(unit,unit.getLevel());
break;
case 13:OpenThroat(unit,unit.getLevel());
break;
case 14:Prelude(unit,unit.getLevel());
break;
case 15:TrebleSolo(unit,unit.getLevel());
break;
case 16:Glamorous(unit,unit.getLevel());
break;
case 17:
Fenglianyanfan(unit,unit.getLevel());
break;
case 18:
Zanwhirlwindfiveconsecutive(unit,unit.getLevel());
break;
case 19:
MeteorJianYu(unit,unit.getLevel());
break;
case 20:
WeekcutoffIaido(unit,unit.getLevel());
}
}
}
//魅力四射
public void Glamorous(final Unit unit,final int level){
AePlayWave bgm = new AePlayWave("./sound/effect/song.wav");
bgm.start();
playPngEffect(unit,"魅力四射",90,-320,-192,640,384,60,2,1,0);
}
//高音Solo
public void TrebleSolo(final Unit unit,final int level){
playPngEffect(unit,"高音Solo",35,-100,-100,200,200,60,2,1,0);
gun(unit,15,2,300,10,-30,30);
gun(unit,15,2,300,10,0,30);
gun(unit,15,2,300,10,30,30);
}
// 前奏
public void Prelude(final Unit unit,final int level){
AePlayWave bgm = new AePlayWave("./sound/effect/伊莉雅前奏.wav");
bgm.start();
playPngEffect(unit,"前奏2",35,-200,-200,200,200,80,1,1,0);
playPngEffect(unit,"前奏2",35,-200,0,200,200,80,1,1,0);
playPngEffect(unit,"前奏2",35,0,-200,200,200,80,1,1,0);
playPngEffect(unit,"前奏2",35,0,0,200,200,80,1,1,0);
playPngEffect(unit,"前奏1",35,-100,-100,200,200,80,2,1,0);
}
//開嗓
public void OpenThroat(final Unit unit,final int level){
playPngEffect(unit,"開嗓",20,-100,-100,200,200,80,2,2,0);
}
//周斷居合斬
public void WeekcutoffIaido(final Unit unit,final int level){
playPngEffect(unit,"周斷居合斬/1(60ms)",35,-100,-100,200,200,80,2,2,1);
// 右下
playMovableImage(unit,"./images/effect/周斷居合斬/2/1.png",-50,-50,100,100,1,1,2000,
2,1,0);
playMovableImage(unit,"./images/effect/周斷居合斬/2/2.png",-50,-50,100,100,1,-1,2000,
2,1,0);
playMovableImage(unit,"./images/effect/周斷居合斬/2/3.png",-50,-50,100,100,-1,-1,2000,
2,1,0);
playMovableImage(unit,"./images/effect/周斷居合斬/2/4.png",-50,-50,100,100,-1,1,2000,
2,1,0);
playMovableImage(unit,"./images/effect/周斷居合斬/2/5.png",-50,-50,100,100,-1,0,2000,
2,1,0);
playMovableImage(unit,"./images/effect/周斷居合斬/2/6.png",-50,-50,100,100,1,0,2000,
2,1,0);
playMovableImage(unit,"./images/effect/周斷居合斬/2/7.png",-50,-50,100,100,0,1,2000,
2,1,0);
playMovableImage(unit,"./images/effect/周斷居合斬/2/8.png",-50,-50,100,100,0,-1,2000,
2,1,0);
}
//流星劍雨
public void MeteorJianYu(final Unit unit,final int level){
playPngEffect(unit,"流星劍雨/1(60ms)",20,-50,10,100,50,60,2,2,1);
for(int i = 0;i < 5;i++){
int xOffset = (int)(200*Math.random()-100);
int yOffset = (int)(200*Math.random()-100);
playPngEffect(unit,"流星劍雨/2(60ms)",25,xOffset,yOffset,100,100,80,2,2,0);
}
}
//旋風五連斬
public void Zanwhirlwindfiveconsecutive(final Unit unit,final int level){
playPngEffect(unit,"旋風五連斬/1(60ms)",30,-100,-100,200,200,80,2,2,1);
playGifEffect(unit,"旋風五連斬/2.gif",2000,-25,-75,50,50,2,1,1);
playGifEffect(unit,"旋風五連斬/2.gif",2000,55,-5,50,50,2,1,1);
playGifEffect(unit,"旋風五連斬/2.gif",2000,-105,-5,50,50,2,1,1);
playGifEffect(unit,"旋風五連斬/2.gif",2000,15,75,50,50,2,1,1);
playGifEffect(unit,"旋風五連斬/2.gif",2000,-65,75,50,50,2,1,1);
}
//風鍊燕返
public void Fenglianyanfan(final Unit unit,final int level){
AePlayWave bgm = new AePlayWave("./sound/effect/凱瑟第1招.wav");
bgm.start();
playPngEffect(unit,"風鍊燕返1",20,-100,-100,200,200,80,2,2,0);
for (int i = 0; i < data.units.size(); i++) {
Unit u = data.units.get(i);
if (u != null)
if(u.getTeam()!=unit.getTeam())
if(new Button(unit.getX()-100, unit.getY()-100, 200, 200).isClicked(u
.getX()
+ u.getWidth() / 2, u.getY()
+ u.getHeight() / 2)){
playPngEffect(u,"風鍊燕返2",10,-50,-50,100,100,80,2,2,0);
}
}
}
//天女散花
public void godnessflower(final Unit unit,final int level){
AePlayWave bgm = new AePlayWave("./sound/effect/舞櫻花大絕.wav");
bgm.start();
playPngEffect(unit,"天女散花",35,-100,-250,200,200,80,2,2,0);
danmaku(unit,14,2,4,150,10,15,30);
}
//櫻沉香
public void sakura(final Unit unit,final int level){
playPngEffect(unit,"櫻沉香",35,-100,-100,200,200,80,2,2,0);
}
//風花雪月
public void windflower(final Unit unit,final int level){
AePlayWave bgm = new AePlayWave("./sound/effect/舞櫻花風花雪月.wav");
bgm.start();
playPngEffect(unit,"風花雪月1",23,-200,-200,200,200,80,1,1,0);
playPngEffect(unit,"風花雪月1",23,-200,0,200,200,80,1,1,0);
playPngEffect(unit,"風花雪月1",23,0,-200,200,200,80,1,1,0);
playPngEffect(unit,"風花雪月1",23,0,0,200,200,80,1,1,0);
playPngEffect(unit,"風花雪月2",25,-100,-100,200,200,80,2,1,0);
}
//花之祝福
public void flowerRecoveer(final Unit unit,final int level){
final int sx = unit.getX()+unit.getWidth()/2;
final int sy = unit.getY()+unit.getHeight()/2;
final Effect e1 = new Effect();
e1.setType(5);
e1.setUnderUI(true);
e1.setX1(sx-200);
e1.setY1(sy-200);
e1.setX2(400);
e1.setY2(400);
e1.setVisible(true);
e1.setLive(true);
data.effects.add(e1);
new Thread(){
public void run(){
int n = 1;
try{
while(true){
sleep(80);
e1.setImage(new ImageIcon("./images/effect/花之祝福/"+n+".png").getImage());
n++;
for (int i = 0; i < data.units.size(); i++) {
Unit u = data.units.get(i);
if (u != null)
if(u.getTeam()==unit.getTeam())
if(new Button(e1.getX1(), e1.getY1(), e1
.getX2(), e1.getY2()).isClicked(u
.getX()
+ u.getWidth() / 2, u.getY()
+ u.getHeight() / 2))
u.recovery(2*level,2*level);
}
if(n>=20)
break;
}
e1.setLive(false);
}catch(Exception ex){
}
}
}.start();
}
//分裂彈
public void splitBomb(final Unit unit, final int bulletNum,
final int radius, final int circleNum, final int interval,
final int times, final int nextTheta, final int atk) {
/* 彈幕 */
/* 發射子彈編號 */
/* 彈幕發射時距離自身半徑 */
/* 彈幕從自身前方算起繞一圈的數量1=前方,2=前後,4=十字,8=米字 */
/* 彈幕發射間隔 */
/* 彈幕發射次數 */
/* 下次彈幕距離上次彈幕偏移角度 */
/* 攻擊力 */
int x = 0;
int y = 0;
int a = unit.getX();// +unit.getWidth()/2;
int b = unit.getY();// +unit.getHeight()/2;
double theta = 120;
switch (unit.getDir()) {
case 1:
case 2:
theta = Math.PI * 3 / 2;// 270
break;
case 3:
case 4:
break;
case 5:
case 6:
theta = Math.PI / 2;// 90
break;
case 7:
case 8:
theta = Math.PI;// 180
break;
}
double offset = (2 * Math.PI) / circleNum;
theta += Math.toRadians(nextTheta);
BulletData bulletdata = data.bulletDatas.list.get(bulletNum - 1);
// 算子彈產生的位置
x = (int) (a + radius * Math.cos(theta));
y = (int) (b + radius * Math.sin(theta));
int vx = (int) (bulletdata.getSpeed() * Math.cos(theta));
int vy = (int) (bulletdata.getSpeed() * Math.sin(theta));
final Unit bullet1 = new Unit(x, y);
data.bulletDatas.createBullet(unit, bullet1, bulletdata, vx, vy,
bulletNum, atk);
data.bullets.add(bullet1);
theta += offset;
x = (int) (a + radius * Math.cos(theta));
y = (int) (b + radius * Math.sin(theta));
vx = (int) (bulletdata.getSpeed() * Math.cos(theta));
vy = (int) (bulletdata.getSpeed() * Math.sin(theta));
final Unit bullet2 = new Unit(x, y);
data.bulletDatas.createBullet(unit, bullet2, bulletdata, vx, vy,
bulletNum, atk);
data.bullets.add(bullet2);
theta += offset;
x = (int) (a + radius * Math.cos(theta));
y = (int) (b + radius * Math.sin(theta));
vx = (int) (bulletdata.getSpeed() * Math.cos(theta));
vy = (int) (bulletdata.getSpeed() * Math.sin(theta));
final Unit bullet3 = new Unit(x, y);
data.bulletDatas.createBullet(unit, bullet3, bulletdata, vx, vy,
bulletNum, atk);
data.bullets.add(bullet3);
// 發射分裂彈
final Effect e1 = new Effect();//
e1.setX1(bullet1.getX());
e1.setY1(bullet1.getY());
e1.setX2(150);
e1.setY2(150);
e1.setType(5);
e1.setUnderUI(true);
e1.setVisible(true);
e1.setImage(new ImageIcon("./images/effect/sbomb.gif").getImage());
e1.setLifeTime(3);
e1.setHasLifeTime(true);
data.effects.add(e1);
final Effect e2 = new Effect();//
e2.setX1(bullet1.getX());
e2.setY1(bullet1.getY());
e2.setX2(150);
e2.setY2(150);
e2.setType(5);
e2.setUnderUI(true);
e2.setVisible(true);
e2.setImage(new ImageIcon("./images/effect/sbomb.gif").getImage());
e2.setLifeTime(3);
e2.setHasLifeTime(true);
data.effects.add(e2);
final Effect e3 = new Effect();//
e3.setX1(bullet1.getX());
e3.setY1(bullet1.getY());
e3.setX2(150);
e3.setY2(150);
e3.setType(5);
e3.setUnderUI(true);
e3.setVisible(true);
e3.setImage(new ImageIcon("./images/effect/sbomb.gif").getImage());
e3.setLifeTime(3);
e3.setHasLifeTime(true);
data.effects.add(e3);
new Thread() {
public void run() {
int time = 0;
while (true) {
e1.setX1(bullet1.getX() + bullet1.getWidth() / 2 - 75);
e1.setY1(bullet1.getY() + bullet1.getHeight() / 2 - 75);
e2.setX1(bullet2.getX() + bullet2.getWidth() / 2 - 75);
e2.setY1(bullet2.getY() + bullet2.getWidth() / 2 - 75);
e3.setX1(bullet3.getX() + bullet3.getWidth() / 2 - 75);
e3.setY1(bullet3.getY() + bullet3.getWidth() / 2 - 75);
for (int i = 0; i < data.units.size(); i++) {
Unit u = data.units.get(i);
if (u != null)
if (u.getTeam() != unit.getTeam()) {
if (new Button(e1.getX1(), e1.getY1(), e1
.getX2(), e1.getY2()).isClicked(u
.getX()
+ u.getWidth() / 2, u.getY()
+ u.getHeight() / 2)) {
if (u.getHP() >= atk)
u.setHP(u.getHP() - atk);
else {
u.setHP(0);
}
}
if (new Button(e2.getX1(), e2.getY1(), e2
.getX2(), e2.getY2()).isClicked(u
.getX()
+ u.getWidth() / 2, u.getY()
+ u.getHeight() / 2)) {
if (u.getHP() >= atk)
u.setHP(u.getHP() - atk);
else {
u.setHP(0);
}
}
if (new Button(e3.getX1(), e3.getY1(), e3
.getX2(), e3.getY2()).isClicked(u
.getX()
+ u.getWidth() / 2, u.getY()
+ u.getHeight() / 2)) {
if (u.getHP() >= atk)
u.setHP(u.getHP() - atk);
else {
u.setHP(0);
}
}
}
}
try {
time+=100;
sleep(100);
} catch (InterruptedException e) {
// TODO 自動產生 catch 區塊
e.printStackTrace();
}
if(time>2000)
break;
}
e1.setLive(false);
e2.setLive(false);
e3.setLive(false);
playPngEffect(new Unit(e1.getX1(),e1.getY1(),e1.getX2(),e1.getY2(),unit.getTeam()),
"爆炸",35,-100,-100,200,200,80,2,2,0);
playPngEffect(new Unit(e2.getX1(),e2.getY1(),e2.getX2(),e2.getY2(),unit.getTeam()),
"爆炸",35,-100,-100,200,200,80,2,2,0);
playPngEffect(new Unit(e3.getX1(),e3.getY1(),e3.getX2(),e3.getY2(),unit.getTeam()),
"爆炸",35,-100,-100,200,200,80,2,2,0);
}
}.start();
}
// 雷射
public void laser(final Unit unit,final double time,final Color color,final int width,final double atk){
/*持續時間*/
/*顏色*/
/*寬度*/
/*傷害*/
new Thread(){
public void run(){
double theta = 0.0;
int x = 0;
int y = 0;
final int sx = unit.getX()+unit.getWidth()/2;
final int sy = unit.getY()+unit.getHeight()/2;
final Effect e1 = new Effect();//
e1.setType(5);
e1.setUnderUI(true);
data.effects.add(e1);
e1.setVisible(true);
e1.setImage(new ImageIcon("./images/effect/雷射.PNG").getImage());
e1.setColor(color);
final int maxX = 0;
final int maxY = 0;
final int maxWidth = 0;
final int maxHeight = 0;
final Region maxRegion = new Region();
switch(unit.getDir()){
case 1:
case 2:
//上
e1.setImage(new ImageIcon("./images/effect/雷射2.PNG").getImage());
e1.setX1(sx);
e1.setY1(sy-5000-unit.getHeight()/2);
e1.setX2(0);
e1.setY2(5000);
maxRegion.setX(sx-width/2);
maxRegion.setY(sy-5000-unit.getHeight()/2);
maxRegion.setWidth(width);
maxRegion.setHeight(5000);
break;
case 3:
case 4:
//右
e1.setX1(sx+unit.getWidth()/2);
e1.setY1(sy);
e1.setX2(5000);
e1.setY2(0);
maxRegion.setX(sx+unit.getWidth()/2);
maxRegion.setY(sy-width/2);
maxRegion.setWidth(5000);
maxRegion.setHeight(width);
break;
case 5:
case 6:
///下
e1.setImage(new ImageIcon("./images/effect/雷射2.PNG").getImage());
e1.setX1(sx);
e1.setY1(sy+unit.getHeight()/2);
e1.setX2(0);
e1.setY2(5000);
maxRegion.setX(sx-width/2);
maxRegion.setY(sy+unit.getHeight()/2);
maxRegion.setWidth(width);
maxRegion.setHeight(5000);
break;
case 7:
case 8:
//左
e1.setX1(sx-5000-unit.getWidth()/2);
e1.setY1(sy);
e1.setX2(5000);
e1.setY2(0);
maxRegion.setX(sx-5000-unit.getWidth()/2);
maxRegion.setY(sy-width/2);
maxRegion.setWidth(5000);
maxRegion.setHeight(width);
break;
}
double n = 0;
//每一點傷害過幾秒
int interval = 100;
int incWidth = width/(int)(time/interval);
int incHeight = width/(int)(time/interval);
unit.setStunned(true);
AePlayWave bgm = new AePlayWave("./sound/effect/laser.wav");
bgm.start();
while(true){
try {
switch(unit.getDir()){
case 1:
case 2:
case 5:
case 6:
e1.setX1(e1.getX1()-incWidth/2);
e1.setX2(e1.getX2()+incWidth);
break;
case 3:
case 4:
case 7:
case 8:
e1.setY1(e1.getY1()-incHeight/2);
e1.setY2(e1.getY2()+incHeight);
break;
}
for(int i = 0;i < data.units.size();i++){
Unit u = data.units.get(i);
if(u!=null)
if(u.getTeam()!=unit.getTeam())
if(new Button(e1.getX1(),e1.getY1(),e1.getX2(),e1.getY2()).isClicked(u.getX()+u.getWidth()/2, u.getY()+u.getHeight()/2)){
if(u.getHP()>=atk)
u.setHP(u.getHP()-atk);
else{
u.setHP(0);
}
}
}
sleep(interval/2);
} catch (InterruptedException e) {
// TODO 自動產生 catch 區塊
e.printStackTrace();
}
n+=interval/2;
if(n>=time/2)
break;
}
while(true){
try {
switch(unit.getDir()){
case 1:
case 2:
case 5:
case 6:
e1.setX1(e1.getX1()+incWidth/2);
e1.setX2(e1.getX2()-incWidth);
break;
case 3:
case 4:
case 7:
case 8:
e1.setY1(e1.getY1()+incHeight/2);
e1.setY2(e1.getY2()-incHeight);
break;
}
for(int i = 0;i < data.units.size();i++){
Unit u = data.units.get(i);
if(u!=null)
if(u.getTeam()!=unit.getTeam())
if(new Button(e1.getX1(),e1.getY1(),e1.getX2(),e1.getY2()).isClicked(u.getX()+u.getWidth()/2, u.getY()+u.getHeight()/2)){
if(u.getHP()>=atk)
u.setHP(u.getHP()-atk);
else{
u.setHP(0);
}
}
}
sleep(interval/2);
} catch (InterruptedException e) {
// TODO 自動產生 catch 區塊
e.printStackTrace();
}
n+=interval/2;
if(n>=time)
break;
}
e1.setLive(false);
unit.setStunned(false);
}
}.start();
}
//核彈
public void nuclear(final Unit u){
final AePlayWave bgm;
bgm = new AePlayWave("./sound/effect/nuclear.wav");
bgm.start();
//final int lev = level;
final Step step = new Step();
step.setNum(1);
final int sx = u.getX()+u.getWidth()/2;
final int sy = u.getY()+u.getHeight()/2;
final Effect e1 = new Effect();//核彈頭
e1.setType(5);
data.effects.add(e1);
e1.setVisible(true);
e1.setImage(new ImageIcon("./images/effect/核彈.gif").getImage());
e1.setX1(sx);
e1.setY1(sy-5000+500-207);
e1.setX2(33);
e1.setY2(207);
e1.setUnderUI(true);
final Effect e2 = new Effect();//準心
e2.setType(5);
data.effects.add(e2);
e2.setVisible(true);
e2.setImage(new ImageIcon("./images/effect/鎖定.gif").getImage());
e2.setX1(sx-96);
e2.setY1(sy-96);
e2.setX2(192);
e2.setY2(192);
e2.setUnderUI(true);
new Thread(){
public void run(){
int dir = 0;//1,2,3,4 上 右 下 左
int x = e2.getX1();
int y = e2.getY1();
int vy = 5;
int n = 0;
try {//Math.abs(x2-tx)<1||Math.abs(y2-ty)<1
while(true){
n++;
e1.setY1(e1.getY1()+vy);
sleep(10);
if(n>900)
break;
}
Unit e3u = new Unit(x,y,192,192);
playPngEffect(e3u,"核彈爆炸",22,-100,-200,400,400,0,0,0,0);
e2.setLive(false);
e1.setLive(false);
step.setNum(2);
System.out.println("停止");
//傷害
for(int i = 0;i < data.units.size();i++){
Unit unit = data.units.get(i);
if(unit!=null)
if(new Button(x-300,y-300,600,600).isClicked(unit.getX(), unit.getY())){
if(unit.getHP()>=300)
unit.setHP(unit.getHP()-300);
else{
unit.setHP(0);
}
}
}
bgm.stop();
final AePlayWave bgm2;
bgm2 = new AePlayWave("./sound/effect/bomb.wav");
bgm2.start();
} catch (InterruptedException e) {
// TODO 自動產生 catch 區塊
e.printStackTrace();
}
}
}.start();
}
public void gun(final Unit unit,final int bulletNum,final int radius,
final int interval,final int times,
final int thetaOffset,final int atk){
/*彈幕*/
/*發射子彈編號*/
/*彈幕發射時距離自身半徑*/
/*彈幕從自身前方算起繞一圈的數量1=前方,2=前後,4=十字,8=米字*/
/*彈幕發射間隔*/
/*彈幕發射次數*/
/*下次彈幕距離上次彈幕偏移角度*/
/*攻擊力*/
new Thread(){
public void run(){
for(int i = 0;i < times;i++){//次數
double theta = 0.0;
int x = 0;
int y = 0;
int a = unit.getX();//+unit.getWidth()/2;
int b = unit.getY();//+unit.getHeight()/2;
switch(unit.getDir()){
case 1:
case 2:theta=Math.PI*3/2;//270
break;
case 3:
case 4:
break;
case 5:
case 6:theta=Math.PI/2;//90
break;
case 7:
case 8:theta=Math.PI;//180
break;
}
theta+=Math.toRadians(thetaOffset);
BulletData bulletdata = data.bulletDatas.list.get(bulletNum-1);
//算子彈產生的位置
x = (int)(a+radius*Math.cos(theta));
y = (int)(b+radius*Math.sin(theta));
int vx = (int)(bulletdata.getSpeed()*Math.cos(theta));
int vy = (int)(bulletdata.getSpeed()*Math.sin(theta));
System.out.println(vx+","+vy);
Unit bullet = new Unit(x,y);
bullet.setVx(vx);
bullet.setVy(vy);
bullet.setWidth(bulletdata.getWidth());//寬度
bullet.setHeight(bulletdata.getHeight());//高度
bullet.setSpeed(bulletdata.getSpeed());//速度
bullet.setAtkType(bulletdata.getAtkType());//攻擊形態
//法球bulletdata[4]//攻擊形態
bullet.setLiveTime(bulletdata.getLifeTime());//生存時間
bullet.setNum(bulletNum);
bullet.setImageNum(bulletNum);
bullet.setDir(1);
bullet.setId(unit.getId());//所屬玩家
bullet.setTeam(unit.getTeam());//所屬隊伍
bullet.setType(5);//屬於子彈
bullet.setTrace(null);//追蹤目標
bullet.setHasLiveTime(true);
bullet.setHarm(atk);//傷害
data.bullets.add(bullet);
/*彈幕發射間隔*/
try {
sleep(interval);
} catch (InterruptedException e) {
// TODO 自動產生 catch 區塊
e.printStackTrace();
}
}
}
}.start();
}
public void danmaku(final Unit unit,final int bulletNum,final int radius,
final int circleNum,final int interval,final int times,final int nextTheta,final int atk){
/*彈幕*/
/*發射子彈編號*/
/*彈幕發射時距離自身半徑*/
/*彈幕從自身前方算起繞一圈的數量1=前方,2=前後,4=十字,8=米字*/
/*彈幕發射間隔*/
/*彈幕發射次數*/
/*下次彈幕距離上次彈幕偏移角度*/
/*攻擊力*/
new Thread(){
public void run(){
double theta = 0.0;
for(int i = 0;i < times;i++){//次數
int x = 0;
int y = 0;
int a = unit.getX();//+unit.getWidth()/2;
int b = unit.getY();//+unit.getHeight()/2;
switch(unit.getDir()){
case 1:
case 2:theta=Math.PI*3/2;//270
break;
case 3:
case 4:
break;
case 5:
case 6:theta=Math.PI/2;//90
break;
case 7:
case 8:theta=Math.PI;//180
break;
}
double offset = (2 * Math.PI)/circleNum;
theta+=Math.toRadians(nextTheta);
for(int j = 0;j < circleNum;j++){//每次彈幕發射的子彈數量
BulletData bulletdata = data.bulletDatas.list.get(bulletNum-1);
//算子彈產生的位置
x = (int)(a+radius*Math.cos(theta));
y = (int)(b+radius*Math.sin(theta));
int vx = (int)(bulletdata.getSpeed()*Math.cos(theta));
int vy = (int)(bulletdata.getSpeed()*Math.sin(theta));
System.out.println(vx+","+vy);
Unit bullet = new Unit(x,y);
bullet.setVx(vx);
bullet.setVy(vy);
bullet.setWidth(bulletdata.getWidth());//寬度
bullet.setHeight(bulletdata.getHeight());//高度
bullet.setSpeed(bulletdata.getSpeed());//速度
bullet.setAtkType(bulletdata.getAtkType());//攻擊形態
//法球bulletdata[4]//攻擊形態
bullet.setLiveTime(bulletdata.getLifeTime());//生存時間
bullet.setNum(bulletNum);
bullet.setImageNum(bulletNum);
bullet.setDir(1);
bullet.setId(unit.getId());//所屬玩家
bullet.setTeam(unit.getTeam());//所屬隊伍
bullet.setType(5);//屬於子彈
bullet.setTrace(null);//追蹤目標
bullet.setHasLiveTime(true);
bullet.setHarm(atk);//傷害
data.bullets.add(bullet);
theta+=offset;
}
/*彈幕發射間隔*/
try {
sleep(interval);
} catch (InterruptedException e) {
// TODO 自動產生 catch 區塊
e.printStackTrace();
}
}
}
}.start();
}
public void skill3(final Unit unit,final int level){
Step step = new Step();
step.setNum(1);
int sx = unit.getX()+unit.getWidth()/2;
int sy = unit.getY()+unit.getHeight()/2;
final Effect e1 = new Effect();
e1.setType(5);
e1.setUnderUI(true);
e1.setX1(sx-96);
e1.setY1(sy-unit.getHeight()-96);
e1.setX2(192);
e1.setY2(192);
e1.setVisible(true);
e1.setLive(true);
data.effects.add(e1);
new Thread(){
public void run(){
int n = 1;
try{
while(true){
sleep(60);
e1.setImage(new ImageIcon("./images/effect/水夢靈/"+n+".png").getImage());
n++;
if(n>=48)
break;
System.out.println("xx");
}
e1.setLive(false);
shield(unit,level);
}catch(Exception ex){
}
}
}.start();
}
public void skill4(Unit unit,int level){
wave(unit,level);
}
public void wave(Unit u,int level){//潮吹巨浪
final int lev = level;
final Step step = new Step();
step.setNum(1);
final int sx = u.getX();
final int sy = u.getY();
final int tempdir = u.getDir();
final int team = u.getTeam();
final Effect e1 = new Effect();
e1.setType(5);
data.effects.add(e1);
e1.setVisible(true);
e1.setX1(sx);
e1.setY1(sy);
switch(tempdir){
case 1:
case 2:
e1.setImage(new ImageIcon("./images/effect/技能4 - 潮吹巨浪(上).gif").getImage());
e1.setX2(96);
e1.setY2(96);
break;
case 5:
case 6:
e1.setImage(new ImageIcon("./images/effect/技能4 - 潮吹巨浪(下).gif").getImage());
e1.setX2(96);
e1.setY2(96);
break;
case 3:
case 4:
e1.setImage(new ImageIcon("./images/effect/技能4 - 潮吹巨浪(右).gif").getImage());
e1.setX2(96);
e1.setY2(96);
break;
case 7:
case 8:
e1.setImage(new ImageIcon("./images/effect/技能4 - 潮吹巨浪(左).gif").getImage());
e1.setX2(96);
e1.setY2(96);
break;
}
new Thread(){
public void run(){
int dir = 0;//1,2,3,4 上 右 下 左
int x = sx;
int y = sy;
int vx = 0;
int vy = 0;
int v = 2;
switch(tempdir){
case 1:
case 2: vy-=v; dir = 1;
break;
case 3:
case 4: vx+=v; dir = 2;
break;
case 5:
case 6: vy+=v; dir = 3;
break;
case 7:
case 8: vx-=v; dir = 4;
break;
}
int n = 0;
try {//Math.abs(x2-tx)<1||Math.abs(y2-ty)<1
while(true){
n++;
e1.setX1(e1.getX1()+vx);
e1.setY1(e1.getY1()+vy);
sleep(20);
if(n>100)
break;
}
e1.setLive(false);
step.setNum(2);
System.out.println("停止");
} catch (InterruptedException e) {
// TODO 自動產生 catch 區塊
e.printStackTrace();
}
}
}.start();
// 傷害
new Thread(){
public void run(){
try {
AePlayWave bgm;
bgm = new AePlayWave("./sound/effect/芙露雅大絕.wav");
bgm.start();
while(step.getNum()!=1){
sleep(100);
}
/*
//暈眩
for(int i = 0;i < data.units.size();i++){
Unit e = data.units.get(i);
if(e.getTeam()!=team){
if(e1.getX1()-70<e.getX()&&e.getX()<e1.getX1()+70&&
e1.getY1()-70<e.getY()&&e.getY()<e1.getY1()+70){
}
}
}*/
while(step.getNum()==1){
for(int i = 0;i < data.units.size();i++){
Unit e = data.units.get(i);
if(e!=null)
if(e.getTeam()!=team){
if(e1.getX1()-70<e.getX()&&e.getX()<e1.getX1()+70&&
e1.getY1()-70<e.getY()&&e.getY()<e1.getY1()+70){
e.damage(100*lev, 3, data.gameData.getArmorList());
if(!e.isStunned()){
// 暈眩
e.setStunned(true);
e.setStunTime(4);
//推
switch(tempdir){
case 1:
case 2: e.setY(e.getY()-20);
break;