24
24
public class Player extends HumanoidEntity {
25
25
26
26
private double [] moveTarget ;
27
- private boolean allowUserMovement , godMode ;
27
+ private boolean allowUserMovement , godMode , isCasting ;
28
28
29
29
public Player () {
30
30
@@ -50,17 +50,15 @@ public Player() {
50
50
.on (MousePressedEvent .class .toString (), new EventHandler () {
51
51
@ Override
52
52
public void handle (Event e ) {
53
- if (isDead () || !getActionQueue ("arms" ).isEmpty ()) return ;
54
53
MousePressedEvent mce = (MousePressedEvent )e ;
55
- ActionGroup actions = new ActionGroup ();
56
- if (getSpellbook ().getParent ().getMana () >= 1 && mce .getButton () == 0
57
- && that .getActionQueue ().isEmpty ()) {
58
- //HACK
59
- if (getLocation () != null ) getLocation ().lookAt (mce .getX (), mce .getY ());
60
- actions .add (new CastSpellAction (mce .getX (), mce .getY ()));
61
- actions .add (new ChangeAnimationAction ("arms" , "casting" , true , true ));
62
- getSpellbook ().getParent ().getActionQueue ("arms" ).queueActions (actions );
63
- }
54
+ if (mce .getButton () == 0 ) isCasting = true ;
55
+ }
56
+ })
57
+ .on (MouseReleaseEvent .class .toString (), new EventHandler () {
58
+ @ Override
59
+ public void handle (Event e ) {
60
+ MouseReleaseEvent mce = (MouseReleaseEvent )e ;
61
+ if (mce .getButton () == 0 ) isCasting = false ;
64
62
}
65
63
})
66
64
.on (KeyDownEvent .class .toString (), new EventHandler () {
@@ -133,6 +131,8 @@ public void update() {
133
131
getLocation ().getCoordinates ()[1 ],
134
132
mouse_wc [0 ], mouse_wc [1 ]));
135
133
134
+ if (isCasting ) cast (mouse_wc [0 ], mouse_wc [1 ]);
135
+
136
136
getMover ().setSpeed (4 );
137
137
getMover ().setIndependent (true );
138
138
if ((dx != 0 || dy != 0 ) && allowUserMovement ) {
@@ -162,4 +162,17 @@ public void activateGodMode() {
162
162
this .addDyes (1000 );
163
163
}
164
164
165
+ private void cast (double wx , double wy ) {
166
+ if (isDead () || !getActionQueue ("arms" ).isEmpty ()) return ;
167
+ ActionGroup actions = new ActionGroup ();
168
+ if (getSpellbook ().getParent ().getMana () >= 1
169
+ && getActionQueue ().isEmpty ()) {
170
+ //HACK
171
+ if (getLocation () != null ) getLocation ().lookAt (wx , wy );
172
+ actions .add (new CastSpellAction (wx , wy ));
173
+ actions .add (new ChangeAnimationAction ("arms" , "casting" , true , true ));
174
+ getSpellbook ().getParent ().getActionQueue ("arms" ).queueActions (actions );
175
+ }
176
+ }
177
+
165
178
}
0 commit comments