@@ -17,31 +17,64 @@ class WeaponBehavior extends Sup.Behavior {
17
17
18
18
update ( ) {
19
19
if ( this . isAttacking && this . timer > - 1 ) {
20
+
21
+ // Process collisions with actors
22
+ let maybeHitActors = [ ] ;
23
+ if ( this . actor . getBehavior ( ItemBehavior ) . owner . getName ( ) == "Player" ) {
24
+ for ( let actor of Sup . getActor ( "Heroes" ) . getChildren ( ) ) {
25
+ maybeHitActors . push ( actor ) ;
26
+ }
27
+ } else {
28
+ maybeHitActors . push ( Sup . getActor ( "Player" ) ) ;
29
+ }
30
+ for ( let dragon of Sup . getActor ( "Dragons" ) . getChildren ( ) ) {
31
+ for ( let actor of dragon . getChild ( "Hitbox" ) . getChildren ( ) ) {
32
+ maybeHitActors . push ( actor ) ;
33
+ }
34
+ }
35
+
36
+ for ( let actor in maybeHitActors ) {
37
+
38
+ }
39
+
40
+
41
+ // Animate weapon movement
20
42
let flip = this . actor . getChild ( "Sprite" ) . spriteRenderer . getHorizontalFlip ( ) ? - 1 : 1 ;
43
+ let fliprot = this . actor . getChild ( "Sprite" ) . spriteRenderer . getHorizontalFlip ( ) ? 180 : 0 ;
21
44
switch ( this . timer ) {
22
45
case 0 :
23
46
default :
24
- //this.actor.getChild("Sprite").rotateEulerZ(this.initialRot);
25
- //this.actor.getChild("Sprite").setLocalPosition(this.localPos);
26
- //this.actor.getChild("Sprite").rotateLocalEulerZ(5);
27
47
this . actor . getChild ( "Sprite" ) . moveLocalX ( - this . deltaX ) ;
28
48
this . actor . getChild ( "Sprite" ) . moveLocalY ( - this . deltaY ) ;
29
- //this.actor.getChild("Sprite").rotateEulerZ(35);
30
49
this . deltaX = 0 ; this . deltaY = 0 ;
50
+ this . actor . getChild ( "Sprite" ) . setLocalEulerZ ( Sup . Math . toRadians ( 45 * flip ) ) ;
31
51
break ;
52
+
32
53
case 1 :
33
- //this.actor.getChild("Sprite").rotateLocalEulerZ(-5);
34
- this . actor . getChild ( "Sprite" ) . moveLocalX ( 0.5 * flip ) ;
35
- this . actor . getChild ( "Sprite" ) . moveLocalY ( 0.25 * flip ) ;
36
- this . deltaX += 0.5 * flip ; this . deltaY += 0.25 * flip ;
37
54
break ;
55
+
38
56
case 2 :
39
- this . actor . getChild ( "Sprite" ) . moveLocalX ( 0.5 * flip ) ;
40
- this . actor . getChild ( "Sprite" ) . moveLocalY ( 0.25 * flip ) ;
41
- this . deltaX += 0.5 * flip ; this . deltaY += 0.25 * flip ;
57
+ this . actor . getChild ( "Sprite" ) . moveLocalX ( - 0.5 * flip ) ;
58
+ this . actor . getChild ( "Sprite" ) . moveLocalY ( - 0.5 ) ;
59
+ this . deltaX += - 0.5 * flip ; this . deltaY += - 0.5 ;
60
+ this . actor . getChild ( "Sprite" ) . setLocalEulerZ ( Sup . Math . toRadians ( - 30 * flip ) ) ;
42
61
break ;
62
+
43
63
case 3 :
44
- //this.actor.getChild("Sprite").rotateLocalEulerZ(-35);
64
+ this . actor . getChild ( "Sprite" ) . moveLocalX ( 0.5 * flip ) ;
65
+ this . actor . getChild ( "Sprite" ) . moveLocalY ( - 0.5 ) ;
66
+ this . deltaX += 0.5 * flip ; this . deltaY += - 0.5 ;
67
+ this . actor . getChild ( "Sprite" ) . setLocalEulerZ ( Sup . Math . toRadians ( 0 * flip ) ) ;
68
+ break ;
69
+
70
+ case 4 :
71
+ this . actor . getChild ( "Sprite" ) . moveLocalX ( 1 * flip ) ;
72
+ this . actor . getChild ( "Sprite" ) . moveLocalY ( 0.5 ) ;
73
+ this . deltaX += 1 * flip ; this . deltaY += 0.5 ;
74
+ this . actor . getChild ( "Sprite" ) . setLocalEulerZ ( Sup . Math . toRadians ( 30 * flip ) ) ;
75
+ break ;
76
+
77
+ case 5 :
45
78
break ;
46
79
}
47
80
this . timer -- ;
@@ -50,7 +83,7 @@ class WeaponBehavior extends Sup.Behavior {
50
83
51
84
attack ( ) {
52
85
this . isAttacking = true ;
53
- this . timer = 3 ;
86
+ this . timer = 5 ;
54
87
}
55
88
}
56
89
Sup . registerBehavior ( WeaponBehavior ) ;
0 commit comments