-
Notifications
You must be signed in to change notification settings - Fork 0
/
m3.java
1170 lines (987 loc) · 43.2 KB
/
m3.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.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.concurrent.TimeUnit;
import java.util.logging.Handler;
import javax.sql.rowset.spi.SyncResolver;
import javax.swing.plaf.basic.BasicInternalFrameUI.InternalFramePropertyChangeListener;
import com.oracle.javafx.scenebuilder.kit.library.util.JarReportEntry.Status;
import javafx.animation.Animation;
import javafx.animation.AnimationTimer;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.RotateTransition;
import javafx.animation.Timeline;
import javafx.animation.TranslateTransition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
//import javafx.scene.input.DragEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.util.Duration;
import javafx.scene.Group;
import javafx.scene.Node;
//no exeptions or shit is handled it is raw code
public class m3 implements Initializable {
@FXML
private Rectangle under;
@FXML
private Rectangle deathline;
@FXML
private Pane p3;
@FXML
private ImageView island;
@FXML
private ImageView ORC;
@FXML
private Label willhero;
@FXML
private Label coincounter;
@FXML
private Label scorelLabel;
@FXML
private ImageView avatar;
@FXML
private ImageView shurimg;
@FXML
private ImageView knifimg;
@FXML
private ImageView cloud;
@FXML
private ImageView cloud2;
@FXML
private ImageView settings;
@FXML
private ImageView crest;
@FXML
private ImageView isl1;
@FXML
private ImageView isl2;
@FXML
private ImageView rorc3;
@FXML
private Button b1;
@FXML
private ImageView bigorc1;
@FXML
private ImageView bigorc11;
@FXML
private Pane pane;
@FXML
private Pane initt;
@FXML
private Pane pane2;
@FXML
private AnchorPane scenePane;
@FXML
private Label pause;// resume
@FXML
private Label save;
@FXML
private Label restart;
@FXML
private Label playagain;
@FXML
private Label gameover;
@FXML
private Label ressure;
@FXML
private Label exittomain;
@FXML
private Label exitm;// to main menu
int scorecount = 0;
int y;
ArrayList<coin> coins = new ArrayList<coin>();
int weaponobtained = 0;// -1 is no weapon 0 is shuri 1 is knife
weapon w1;
weapon w2;
windmill blade;
windmill blade1;
windmill blade2;
windmill blade3;
weaponchest wchest1;
weaponchest wchest2;
int knife = 0;
int shuri = 0;// keeps levels of weapons //update them too while updating weapon objects in
public void updateshuri(MouseEvent e) {
weaponobtained = 0;
shuri++;
}
// code
orc orc;
save svfile;
avatar hero;
save ldfile;
cChest coinchest;
ArrayList<island> ISLAND1 = new ArrayList<island>();
int setpowerup = 0;
int ressurect = 0;
ArrayList<island> ISLAND2 = new ArrayList<island>();
ArrayList<island> ISLAND3 = new ArrayList<island>();
ArrayList<Node> WeaponNode = new ArrayList<Node>();
Group group;
ArrayList<weapon> shoot_weapon = new ArrayList<weapon>();
ArrayList<weapon> shoot_weapon1 = new ArrayList<weapon>();
ArrayList<weapon> shoot_weapon2 = new ArrayList<weapon>();
ArrayList<TranslateTransition> shoot_trans = new ArrayList<TranslateTransition>();
ArrayList<TranslateTransition> shoot_trans1 = new ArrayList<TranslateTransition>();
ArrayList<TranslateTransition> shoot_trans2 = new ArrayList<TranslateTransition>();
ArrayList<TranslateTransition> shoot_trans21 = new ArrayList<TranslateTransition>();
ArrayList<orc> orcs = new ArrayList<orc>();
ArrayList<boundary> topboundaries = new ArrayList<boundary>();
ArrayList<boundary> bottomboundaries = new ArrayList<boundary>();
ArrayList<weaponchest> weaponchestsLIST = new ArrayList<weaponchest>();
ArrayList<Integer> oflags = new ArrayList<Integer>();
ArrayList<Double> ox = new ArrayList<Double>();
ArrayList<Double> oy = new ArrayList<Double>();
ArrayList<Double> tx = new ArrayList<Double>();
ArrayList<Double> ty = new ArrayList<Double>();
ArrayList<Double> bx = new ArrayList<Double>();
ArrayList<Double> by = new ArrayList<Double>();
ArrayList<windmill> blades = new ArrayList<windmill>();
TranslateTransition trans1 = new TranslateTransition();
TranslateTransition trans = new TranslateTransition();
TranslateTransition trans2 = new TranslateTransition();
TranslateTransition trans3 = new TranslateTransition();
TranslateTransition trans4 = new TranslateTransition();
TranslateTransition trans5 = new TranslateTransition();
int jump = 1;
MouseEvent mousie;
int coincount = 0;
// private double x;
// private double y;
// public void initial() {
// }
public void shootarray() throws InterruptedException, IOException {
magicpower(0, 5);
}
public void serialize() throws IOException {
ObjectOutputStream out = null;
for (orc orc : orcs) {
oflags.add(orc.getFlag());
ox.add(orc.getOrc().getLayoutX());
oy.add(orc.getOrc().getLayoutY());
}
for (boundary top : topboundaries) {
// oflags.add(orc.getFlag());
tx.add(top.gRectangle().getLayoutX());
ty.add(top.gRectangle().getLayoutY());
}
for (boundary bottom : bottomboundaries) {
bx.add(bottom.gRectangle().getLayoutX());
by.add(bottom.gRectangle().getLayoutY());
}
svfile = new save(hero.getOrc().getLayoutX(), hero.getOrc().getLayoutY(), coincount, scorecount, ressurect,
knife, shuri,
weaponobtained, scenePane.getLayoutX(), pane.getLayoutX(), pane2.getLayoutX(), settings.getLayoutX(),
coincounter.getLayoutX(), scorelLabel.getLayoutX(), p3.getLayoutX(), oflags, ox, oy, tx, ty, bx, by);// weaponflag
// =0
// is
// shuri
try {
out = new ObjectOutputStream(new FileOutputStream("out.txt"));
out.writeObject(svfile);
} finally {
out.close();
}
}
public void saving_progress(MouseEvent e) throws IOException {
serialize();
System.out.println("success serialized!");
}
public void shooting(int i) {
if (i == 0) {// is weapon flag and 0 is shuri 1 is knife
if (shuri == 1) {// shoot_weapon.get(shoot_weapon.size() - 1).getlvl()
shoot_weapon.add(new weapon(scenePane, 20, 20, hero.getOrc().getLayoutX(), hero.getOrc().getLayoutY(),
"The_Will_Hero-main/w1.png"));// used for lvl 1
shoot_weapon.get(shoot_weapon.size() - 1).setinp(scenePane);
shoot_trans.add(new TranslateTransition());
// weapon and trans added
shoot_trans.get(shoot_trans.size() - 1).setNode(shoot_weapon.get(shoot_weapon.size() - 1).getIsl1());
shoot_trans.get(shoot_trans.size() - 1).setDuration(Duration.millis(1000));
shoot_trans.get(shoot_trans.size() - 1).setByX(hero.getOrc().getX() + 500);
shoot_trans.get(shoot_trans.size() - 1).play();
System.out.println(" previous in t: " + shoot_trans.size());
} else if (shuri == 2) {
// System.out.println(" previous t: " + shoot_trans.size());
// System.out.println("next t1: " + shoot_trans1.size());
// System.out.println("next t2: " + shoot_trans2.size());
shoot_weapon1.add(new weapon(scenePane, 20, 20, hero.getOrc().getLayoutX(), hero.getOrc().getLayoutY(),
"The_Will_Hero-main/w1.png"));// used for lvl 2
shoot_weapon2.add(new weapon(scenePane, 20, 20, hero.getOrc().getLayoutX(), hero.getOrc().getLayoutY(),
"The_Will_Hero-main/w1.png"));// used for lvl 2 but 2nd layer or diagonal
shoot_weapon1.get(shoot_weapon1.size() - 1).setinp(scenePane);
shoot_weapon2.get(shoot_weapon2.size() - 1).setinp(scenePane);
shoot_trans1.add(new TranslateTransition());
shoot_trans2.add(new TranslateTransition());
shoot_trans21.add(new TranslateTransition());
shoot_trans1.get(shoot_trans1.size() - 1)
.setNode(shoot_weapon1.get(shoot_weapon1.size() - 1).getIsl1());
shoot_trans1.get(shoot_trans1.size() - 1).setDuration(Duration.millis(1000));
shoot_trans1.get(shoot_trans1.size() - 1).setByX(hero.getOrc().getX() + 500);
shoot_trans2.get(shoot_trans2.size() - 1)
.setNode(shoot_weapon2.get(shoot_weapon2.size() - 1).getIsl1());
shoot_trans2.get(shoot_trans2.size() - 1).setDuration(Duration.millis(1000));
shoot_trans2.get(shoot_trans2.size() - 1).setByX(hero.getOrc().getX() + 500);
shoot_trans21.get(shoot_trans21.size() - 1)
.setNode(shoot_weapon2.get(shoot_weapon2.size() - 1).getIsl1());
shoot_trans21.get(shoot_trans21.size() - 1).setDuration(Duration.millis(1000));
shoot_trans21.get(shoot_trans21.size() - 1).setByY(hero.getOrc().getY() - 100);
shoot_trans1.get(shoot_trans1.size() - 1).play();
shoot_trans2.get(shoot_trans2.size() - 1).play();
shoot_trans21.get(shoot_trans21.size() - 1).play();
}
} else if (i == 1) {
// try {
// shoot_weapon
// .add(new weapon(scenePane, 20, 5, hero.getOrc().getLayoutX(),
// hero.getOrc().getLayoutY() + 26,
// "The_Will_Hero-main/w2.png"));
// } catch (Exception e) {
// System.out.println("hi");
if (knife == 1) {
shoot_weapon.add(new weapon(scenePane, 20, 5, hero.getOrc().getLayoutX(), hero.getOrc().getLayoutY(),
"The_Will_Hero-main/w2.png"));// used for lvl 1
shoot_weapon.get(shoot_weapon.size() - 1).setinp(scenePane);
shoot_trans.add(new TranslateTransition());
// weapon and trans added
shoot_trans.get(shoot_trans.size() - 1).setNode(shoot_weapon.get(shoot_weapon.size() - 1).getIsl1());
shoot_trans.get(shoot_trans.size() - 1).setDuration(Duration.millis(1000));
shoot_trans.get(shoot_trans.size() - 1).setByX(hero.getOrc().getX() + 500);
shoot_trans.get(shoot_trans.size() - 1).play();
} else if (knife == 2) {
// System.out.println(" previous t: " + shoot_trans.size());
// System.out.println("next t1: " + shoot_trans1.size());
// System.out.println("next t2: " + shoot_trans2.size());
shoot_weapon1.add(new weapon(scenePane, 20, 5, hero.getOrc().getLayoutX(), hero.getOrc().getLayoutY(),
"The_Will_Hero-main/w2.png"));// used for lvl 2
shoot_weapon2.add(new weapon(scenePane, 20, 5, hero.getOrc().getLayoutX(), hero.getOrc().getLayoutY(),
"The_Will_Hero-main/w2.png"));// used for lvl 2 but 2nd layer or diagonal
shoot_weapon1.get(shoot_weapon1.size() - 1).setinp(scenePane);
shoot_weapon2.get(shoot_weapon2.size() - 1).setinp(scenePane);
shoot_trans1.add(new TranslateTransition());
shoot_trans2.add(new TranslateTransition());
shoot_trans21.add(new TranslateTransition());
shoot_trans1.get(shoot_trans1.size() - 1)
.setNode(shoot_weapon1.get(shoot_weapon1.size() - 1).getIsl1());
shoot_trans1.get(shoot_trans1.size() - 1).setDuration(Duration.millis(1000));
shoot_trans1.get(shoot_trans1.size() - 1).setByX(hero.getOrc().getX() + 500);
shoot_trans2.get(shoot_trans2.size() - 1)
.setNode(shoot_weapon2.get(shoot_weapon2.size() - 1).getIsl1());
shoot_trans2.get(shoot_trans2.size() - 1).setDuration(Duration.millis(1000));
shoot_trans2.get(shoot_trans2.size() - 1).setByX(hero.getOrc().getX() + 500);
shoot_trans21.get(shoot_trans21.size() - 1)
.setNode(shoot_weapon2.get(shoot_weapon2.size() - 1).getIsl1());
shoot_trans21.get(shoot_trans21.size() - 1).setDuration(Duration.millis(1000));
shoot_trans21.get(shoot_trans21.size() - 1).setByY(hero.getOrc().getY() - 100);
shoot_trans1.get(shoot_trans1.size() - 1).play();
shoot_trans2.get(shoot_trans2.size() - 1).play();
shoot_trans21.get(shoot_trans21.size() - 1).play();
}
}
// shootcheck.start();
}
// trans4.stop();
public void magicpower(int k, int n) throws InterruptedException, IOException {
// TimeUnit.MILLISECONDS.sleep(50);
// change_skin();
// TimeUnit.MILLISECONDS.sleep(50);
for (int i = 0; i < n; i++) {
shooting(k);
TimeUnit.MILLISECONDS.sleep(50);
}
}
public void change_skin() {
hero.getOrc().setImage(new Image("The_Will_Hero-main/Helmet2.png"));
}
public void change_skin2() {
hero.getOrc().setImage(new Image("The_Will_Hero-main/avatar1.png"));
}
public void magicpower2() {
setpowerup = 1;
}
public void play(MouseEvent m2) throws IOException, InterruptedException {
// avatar.setTranslateX(avatar.getX() + 50);
// avatar.setLayoutX(avatar.getLayoutX() + 50);
Stage stage;
Scene scene;
mousie = m2;
int prevX = (int) hero.getOrc().getLayoutX();
willhero.setVisible(false);
Parent root = FXMLLoader.load(getClass().getResource("load.fxml"));
stage = (Stage) ((Node) m2.getSource()).getScene().getWindow();
scene = new Scene(root);
String css = this.getClass().getResource("bg.css").toExternalForm();
scene.getStylesheets().add(css);
hero.getOrc().setLayoutX(hero.getOrc().getLayoutX() + 50);
pane.setLayoutX(pane.getLayoutX() + 50);
scenePane.setLayoutX(scenePane.getLayoutX() - 50);
settings.setLayoutX(settings.getLayoutX() + 50);
pane2.setLayoutX(pane2.getLayoutX() + 50);
coincounter.setLayoutX(coincounter.getLayoutX() + 50);
scorelLabel.setLayoutX(scorelLabel.getLayoutX() + 50);
p3.setLayoutX(p3.getLayoutX() + 50);
// jumping.start();
// magicpower2();
// change_skin();
try {
if (setpowerup == 0) {
shooting(weaponobtained);
// System.out.println("print "+weaponobtained); // 0 is for shuriken 1 is for
// knife
} else if (setpowerup == 1) {
shooting(0);
shooting(1);
} // if pwerup is 1 then it shoots 2 weapons
// magicpower(0, 5);
// shooting(0);
if (hero.getOrc().getLayoutX() > prevX) {
scorecount++;
}
scorelLabel.setText("" + scorecount);
if (scorecount > 100) {
change_skin();
}
} catch (Exception e) {
System.out.println(e);
}
// shooting.start();
// trans4.setNode(knife.getIsl1());
// trans4.setDuration(Duration.millis(100));
// trans4.setByX(avatar.getY() + 90);
// // trans4.setCycleCount(TranslateTransition.INDEFINITE);
// // trans4.setAutoReverse(true);
// trans4.play();
// // trans4.stop();
// knife.getIsl1().relocate(avatar.getLayoutX(), avatar.getLayoutY());
// stage.setX(stage.getX() + 50);
}
public void gear() {
// init(m);
trans.pause();
jumping.stop();
trans1.pause();
trans2.pause();
trans3.pause();
pane.setDisable(true);
pane2.setDisable(false);
pane2.setOpacity(1);
pause.setVisible(true);
restart.setVisible(true);
exitm.setVisible(true);
save.setVisible(true);
}
public void resume(MouseEvent a) {
pane2.setDisable(true);
pane.setDisable(false);
pause.setVisible(false);
restart.setVisible(false);
exitm.setVisible(false);
save.setVisible(false);
trans.play();
jumping.start();
// trans1.play();
trans2.play();
trans3.play();
}
public void restart(MouseEvent b) throws IOException {
Stage stage;
Scene scene;
Stop[] stops = new Stop[] { new Stop(0, Color.WHITE), new Stop(1, Color.rgb(80, 200, 255)) };
LinearGradient lg1 = new LinearGradient(0, 1, 0, 0, true, CycleMethod.NO_CYCLE, stops);
Parent root = FXMLLoader.load(getClass().getResource("test.fxml"));
stage = (Stage) ((Node) b.getSource()).getScene().getWindow();
scene = new Scene(root, lg1);
String css = this.getClass().getResource("bg.css").toExternalForm();
scene.getStylesheets().add(css);
stage.setScene(scene);
stage.show();
}
public void exit(MouseEvent c) throws IOException {
Stage stage;
Scene scene;
mousie = c;
Stop[] stops = new Stop[] { new Stop(0, Color.WHITE), new Stop(1, Color.rgb(80, 200, 255)) };
LinearGradient lg1 = new LinearGradient(0, 1, 0, 0, true, CycleMethod.NO_CYCLE, stops);
Parent root = FXMLLoader.load(getClass().getResource("m2.fxml"));
stage = (Stage) ((Node) c.getSource()).getScene().getWindow();
scene = new Scene(root, lg1);
String css = this.getClass().getResource("bg.css").toExternalForm();
scene.getStylesheets().add(css);
stage.setScene(scene);
stage.show();
}
public void chooseshuri() {
weaponobtained = 0;
}
public void chooseknife() {
weaponobtained = 1;
}
// }
// };
public void victory() {
System.out.println("you won my friend!");
}
public void revive(MouseEvent e) throws IOException {
if (coincount >= 1000 && ressurect == 0) {
System.out.println("in revive");
coincount = coincount - 1000;
// hero.getOrc().relocate(1000, 255);// random spawn
ressurect = 1;
p3.toBack();
p3.setDisable(true);
gameover.setDisable(true);
playagain.setDisable(true);
ressure.setDisable(true);
exittomain.setDisable(true);
pane.setDisable(false);
p3.setOpacity(0);
p3.setVisible(false);
gameover.setOpacity(0);
gameover.setVisible(false);
ressure.setOpacity(0);
ressure.setVisible(false);
playagain.setOpacity(0);
playagain.setVisible(false);
exittomain.setOpacity(0);
exittomain.setVisible(false);
saving_progress(e);
// scenePane.setLayoutX(1000);
// pane.setLayoutX(1000);
// pane2.setLayoutX(1000);
// p3.setLayoutX(1000);
// hero.getOrc().relocate(1000, 255);
Stage stage;
Scene scene;
Stop[] stops = new Stop[] { new Stop(0, Color.WHITE), new Stop(1, Color.rgb(80, 200, 255)) };
LinearGradient lg1 = new LinearGradient(0, 1, 0, 0, true, CycleMethod.NO_CYCLE, stops);
Parent root = FXMLLoader.load(getClass().getResource("load.fxml"));
stage = (Stage) ((Node) e.getSource()).getScene().getWindow();
scene = new Scene(root, lg1);
String css = this.getClass().getResource("bg.css").toExternalForm();
scene.getStylesheets().add(css);
stage.setScene(scene);
// controller c = new controller();
// c.init();
stage.show();
} else {
exit(mousie);
}
}
public void endgame() {
// pane.setDisable(true);
p3.setDisable(false);
p3.toFront();
gameover.setDisable(false);
playagain.setDisable(false);
ressure.setDisable(false);
exittomain.setDisable(false);
pane.setDisable(true);
p3.setOpacity(1);
p3.setVisible(true);
gameover.setOpacity(1);
gameover.setVisible(true);
ressure.setOpacity(1);
ressure.setVisible(true);
playagain.setOpacity(1);
playagain.setVisible(true);
exittomain.setOpacity(1);
exittomain.setVisible(true);
exittomain.toFront();
// pause.setVisible(true);
// restart.setVisible(true);
// exitm.setVisible(true);
// save.setVisible(true);
}
AnimationTimer endscreen = new AnimationTimer() {
public void handle(long arg0) {
if (checkOrcCrush(hero.getOrc(), deathline)) {
endgame();
} else if (scorecount > 122) {
victory();
}
};
};
AnimationTimer chest = new AnimationTimer() {
@Override
public void handle(long arg0) {
if (checkCollision(hero.getOrc(), weaponchestsLIST.get(0).getOrc()) == true) {
weaponchestsLIST.remove(0);
weaponchestsLIST.add(0,
new weaponchest(scenePane, 55, 40, 451, 212, "The_Will_Hero-main/ChestOpen.png"));
if (weaponobtained == 0) {
// shurimg.setDisable(false);
shurimg.setOpacity(1);
} else if (weaponobtained == 1) {
// knifimg.setDisable(false);
knifimg.setOpacity(1);
}
} else if (checkCollision(hero.getOrc(), weaponchestsLIST.get(1).getOrc()) == true) {
weaponchestsLIST.remove(1);
weaponchestsLIST.add(1,
new weaponchest(scenePane, 55, 40, 1451, 212, "The_Will_Hero-main/ChestOpen.png"));
if (weaponobtained == 0) {
// shurimg.setDisable(false);
shurimg.setOpacity(1);
} else if (weaponobtained == 1) {
// knifimg.setDisable(false);
knifimg.setOpacity(1);
}
} else if (checkCollision(hero.getOrc(), weaponchestsLIST.get(2).getOrc()) == true) {
weaponchestsLIST.remove(2);
weaponchestsLIST.add(2,
new weaponchest(scenePane, 55, 40, 4661, 212, "The_Will_Hero-main/ChestOpen.png"));
if (weaponobtained == 0) {
// shurimg.setDisable(false);
shurimg.setOpacity(1);
} else if (weaponobtained == 1) {
// knifimg.setDisable(false);
knifimg.setOpacity(1);
}
}
if (checkCollision(hero.getOrc(), coinchest.getOrc()) == true) {
coinchest = new cChest(scenePane, 55, 40, 2651, 212, "The_Will_Hero-main/ChestOpen.png");
coincount = coincount + 1000;
}
if (hero.getOrc().getLayoutX() > weaponchestsLIST.get(0).getOrc().getLayoutX()) {
shuri = 1;
weaponobtained = 0;
}
if (hero.getOrc().getLayoutX() > weaponchestsLIST.get(0).getOrc().getLayoutX() + 1100) {
knife = 1;
weaponobtained = 1;
}
if (hero.getOrc().getLayoutX() > weaponchestsLIST.get(0).getOrc().getLayoutX() + 4000) {
shuri = 2;
weaponobtained = 0;
}
// if(checkCollision(hero.getOrc(), weaponchestsLIST.get(0).getOrc())){
// weaponobtained=weaponchestsLIST.get(0).openchest();
// if(weaponobtained==0){
// shuri=1;
// }
// if(weaponobtained==1){
// knife=1;
// }
// }
};
};
AnimationTimer shootcheck = new AnimationTimer() {
@Override
public void handle(long now) {
if (weaponobtained == 0) {
if (shuri == 1) {
for (int i = 0; i < shoot_trans.size(); i++) {
if (shoot_trans.get(i).getStatus() == Animation.Status.STOPPED) {
shoot_weapon.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon.get(i).getIsl1());
// shoot_weapon.remove(i);
// shoot_trans.remove(i);
}
if (shoot_trans.get(i).getStatus() == Animation.Status.RUNNING) {
for (int k = 0; k < orcs.size(); k++) {
if (checkCollision(orcs.get(k).getOrc(), shoot_weapon.get(i).getIsl1())) {
shoot_weapon.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon.get(i).getIsl1());
// shoot_weapon2.get(i).getIsl1().setVisible(false);
// scenePane.getChildren().remove(shoot_weapon2.get(i).getIsl1());
}
}
}
}
}
if (shuri == 2) {// level check from shoot weapon only
for (int i = 0; i < shoot_trans1.size(); i++) {
if (shoot_trans1.get(i).getStatus() == Animation.Status.STOPPED) {
shoot_weapon1.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon1.get(i).getIsl1());
shoot_weapon2.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon2.get(i).getIsl1());
} else if (shoot_trans1.get(i).getStatus() == Animation.Status.RUNNING) {
for (int k = 0; k < orcs.size(); k++) {
if (checkCollision(orc.getOrc(), shoot_weapon.get(i).getIsl1())) {
shoot_weapon.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon.get(i).getIsl1());
// shoot_weapon2.get(i).getIsl1().setVisible(false);
// scenePane.getChildren().remove(shoot_weapon2.get(i).getIsl1());
}
}
}
}
}
}
if (weaponobtained == 1) {
if (knife == 1) {
for (int i = 0; i < shoot_trans.size(); i++) {
if (shoot_trans.get(i).getStatus() == Animation.Status.STOPPED) {
shoot_weapon.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon.get(i).getIsl1());
}
if (shoot_trans.get(i).getStatus() == Animation.Status.RUNNING) {
for (int k = 0; k < orcs.size(); k++) {
if (checkCollision(orcs.get(k).getOrc(), shoot_weapon.get(i).getIsl1())) {
shoot_weapon.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon.get(i).getIsl1());
// shoot_weapon2.get(i).getIsl1().setVisible(false);
// scenePane.getChildren().remove(shoot_weapon2.get(i).getIsl1());
}
}
}
}
}
if (knife == 2) {// level check from shoot weapon only
for (int i = 0; i < shoot_trans2.size(); i++) {
if (shoot_trans2.get(i).getStatus() == Animation.Status.STOPPED) {
shoot_weapon.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon.get(i).getIsl1());
shoot_weapon2.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon2.get(i).getIsl1());
}
if (shoot_trans2.get(i).getStatus() == Animation.Status.RUNNING) {
for (int k = 0; k < orcs.size(); k++) {
if (checkCollision(orcs.get(k).getOrc(), shoot_weapon.get(i).getIsl1())) {
shoot_weapon.get(i).getIsl1().setVisible(false);
scenePane.getChildren().remove(shoot_weapon.get(i).getIsl1());
// shoot_weapon2.get(i).getIsl1().setVisible(false);
// scenePane.getChildren().remove(shoot_weapon2.get(i).getIsl1());
}
}
}
}
}
}
};
};
AnimationTimer jumping2 = new AnimationTimer() {
double time = 0;
double velocityY = 0;
double velocityX = 0;
int counter = 0;
@Override
public void handle(long timestamp) {
for (int k = 0; k < ISLAND1.size(); k++) {
if (checkCollision(ORC, ISLAND1.get(k).getIsl1())) {
velocityY = -4.5;
coincount++;
velocityX = 0;
coincounter.setText("Coins " + coincount);
// System.out.println("vsl set to 0 by isl1");
time = .13;
}
}
for (int k = 0; k < ISLAND2.size(); k++) {
if (checkCollision(ORC, ISLAND2.get(k).getIsl1())) {
velocityY = -4.5;
velocityX = 0;
// System.out.println("vx set to 0 by isl2");
time = .13;
}
}
for (int k = 0; k < shoot_weapon.size(); k++) {
if (checkCollision(ORC, shoot_weapon.get(k).getIsl1())) {
velocityX = 0;
// System.out.println("vslset3");
time = .13;
}
}
for (int k = 0; k < shoot_weapon2.size(); k++) {
if (checkCollision(ORC, shoot_weapon2.get(k).getIsl1())) {
velocityX = 0;
time = .13;
// System.out.println("vslset2");
// velocityY = 0;
}
}
if (checkCollision(ORC, hero.getOrc())) {// || checkCollision(avatar,
// ISLAND1.get(1).getIsl1())) {
velocityX = 0;
// System.out.println("vslset1");
time = .13;
}
// ORC.relocate(x, y);
// time+=0.001;
}
};
AnimationTimer jumping = new AnimationTimer() {
@Override
public void handle(long timestamp) {
double x = hero.getOrc().getLayoutX();
double y = hero.getOrc().getLayoutY();
for (int k = 0; k < ISLAND1.size(); k++) {
if (checkCollision(hero.getOrc(), ISLAND1.get(k).getIsl1())) {// ||
// checkCollision(avatar,
coincount++;
coincounter.setText("Coins " + coincount);
}
}
for (int k = 0; k < ISLAND2.size(); k++) {
if (checkCollision(hero.getOrc(), ISLAND2.get(k).getIsl1())) {// ||
// checkCollision(avatar,
// ISLAND1.get(1).getIsl1())) {
}
}
if (checkOrcCrush(hero.getOrc(), deathline)) {
// gear();
}
// hero.getOrc().relocate(x, y);
// time+=0.001;
}
};
// public void up(ActionEvent e) {
// // System.out.println("t1");
// }
RotateTransition rotate = new RotateTransition();
RotateTransition rot2 = new RotateTransition();
RotateTransition rot3 = new RotateTransition();
RotateTransition rot4 = new RotateTransition();
Rotate rotate2 = new Rotate();
Rotate rotate3 = new Rotate();
Rotate rotate4 = new Rotate();
Rotate rotate5 = new Rotate();
AnimationTimer rot = new AnimationTimer() {
Group group;
@Override
public void handle(long timestamp) {
rotate.setAxis(Rotate.Z_AXIS);
rotate.setByAngle(360000);
rotate.setCycleCount(Animation.INDEFINITE);
rotate.setDuration(Duration.millis(1000000));
// rotate.setAutoReverse(true);
rotate.setRate(1);
rotate.setNode(blade.getwindmill());
rotate.play();
rot2.setAxis(Rotate.Z_AXIS);
rot2.setByAngle(360000);
// rot2.currentRateProperty(10);
// rot2.cycleDurationProperty(1000000);
rot2.setRate(1);
rot2.setCycleCount(Animation.INDEFINITE);
rot2.setDuration(Duration.millis(1000000));
// rotate.setAutoReverse(true);
rot2.setNode(blade1.getwindmill());
rot2.play();
rot3.setAxis(Rotate.Z_AXIS);
rot3.setByAngle(360000);
// rot2.currentRateProperty(10);
// rot2.cycleDurationProperty(1000000);
rot3.setRate(1);
rot3.setCycleCount(Animation.INDEFINITE);
rot3.setDuration(Duration.millis(1000000));
// rotate.setAutoReverse(true);
rot3.setNode(blade2.getwindmill());
rot3.play();
rot4.setAxis(Rotate.Z_AXIS);
rot4.setByAngle(360000);
// rot2.currentRateProperty(10);
// rot2.cycleDurationProperty(1000000);
rot4.setRate(1);
rot4.setCycleCount(Animation.INDEFINITE);
rot4.setDuration(Duration.millis(1000000));
// rotate.setAutoReverse(true);
rot4.setNode(blade3.getwindmill());
rot4.play();
}
};
AnimationTimer playa;
AnimationTimer newa;
ArrayList<AnimationTimer> anims = new ArrayList<AnimationTimer>();
public void deserialize() throws IOException, ClassNotFoundException {
ObjectInputStream in = null;
try {
in = new ObjectInputStream(new FileInputStream("out.txt"));
ldfile = (save) in.readObject();
System.out.println("sucess");
} finally {
in.close();
}
}
public void init(MouseEvent m) throws ClassNotFoundException, IOException {
deserialize();
oflags = ldfile.orcflags;
ox = ldfile.orcx;
oy = ldfile.orcy;
tx = ldfile.topx;
ty = ldfile.topy;
bx = ldfile.botx;
by = ldfile.boty;
boundary barrier = new boundary(scenePane, 6000, 1, 0, 300);
for (int k = 0; k < 10; k++) {
System.out.println("oflag " + oflags.get(k));
if (oflags.get(k) == 1) {
topboundaries.add(new boundary(scenePane, 30, 1, tx.get(k), 230));
bottomboundaries.add(new boundary(scenePane, 30, 1, bx.get(k), 280));
}
}
blade = new windmill(scenePane, 180, 20, 400, 80);
blade1 = new windmill(scenePane, 180, 20, 400, 80);
blade2 = new windmill(scenePane, 180, 20, 3400, 100);
blade3 = new windmill(scenePane, 180, 20, 3400, 100);
blade1.getwindmill().setRotate(90);
// blade2.getwindmill().setRotate(180);
blade3.getwindmill().setRotate(90);
blades.add(blade);
blades.add(blade1);
blades.add(blade2);
blades.add(blade3);
hero = new avatar(scenePane, 20, 25, 300, 225, barrier.gRectangle(), topboundaries, bottomboundaries, ISLAND1,