diff options
Diffstat (limited to 'src')
4 files changed, 47 insertions, 2 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java index c4194d9..9c66a9c 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java | |||
@@ -106,7 +106,22 @@ public class MapViewGameState implements GameState { | |||
106 | 106 | ||
107 | if (letsMove) | 107 | if (letsMove) |
108 | { | 108 | { |
109 | hero.startMoving(toMove); | 109 | if (!hero.startMoving(toMove)) |
110 | { | ||
111 | for (LayerEvent ev : currentMap.getEvents()) | ||
112 | { | ||
113 | if (ev.getCalltime() == EventCallTime.OnHeroTouch) | ||
114 | { | ||
115 | if (ev.getLayer() == Layer.Middle) | ||
116 | { | ||
117 | if (Functions.isFacing(hero, ev)) | ||
118 | { | ||
119 | ev.getCallback().activate(ev.getCalltime()); | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
110 | } | 125 | } |
111 | 126 | ||
112 | if ((Game.getKey().getKeyCode() == KeyEvent.VK_ENTER) || (Game.getKey().getKeyCode() == KeyEvent.VK_SPACE)) | 127 | if ((Game.getKey().getKeyCode() == KeyEvent.VK_ENTER) || (Game.getKey().getKeyCode() == KeyEvent.VK_SPACE)) |
@@ -143,6 +158,23 @@ public class MapViewGameState implements GameState { | |||
143 | if (hero.isMoving()) | 158 | if (hero.isMoving()) |
144 | { | 159 | { |
145 | hero.processMoving(); | 160 | hero.processMoving(); |
161 | |||
162 | if (!hero.isMoving()) | ||
163 | { | ||
164 | for (LayerEvent ev : currentMap.getEvents()) | ||
165 | { | ||
166 | if (ev.getCalltime() == EventCallTime.OnHeroTouch) | ||
167 | { | ||
168 | if (ev.getLayer() != Layer.Middle) | ||
169 | { | ||
170 | if (hero.getLocation().equals(ev.getLocation())) | ||
171 | { | ||
172 | ev.getCallback().activate(ev.getCalltime()); | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | } | ||
146 | } | 178 | } |
147 | 179 | ||
148 | for (LayerEvent ev : currentMap.getEvents()) | 180 | for (LayerEvent ev : currentMap.getEvents()) |
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java index 7e8dd0d..483ce49 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java | |||
@@ -50,6 +50,11 @@ public abstract class AbstractEvent implements Event { | |||
50 | 50 | ||
51 | setDirection(toMove); | 51 | setDirection(toMove); |
52 | 52 | ||
53 | if (getDirection() != toMove) | ||
54 | { | ||
55 | return false; | ||
56 | } | ||
57 | |||
53 | if (!getParentMap().checkForCollision(this, toMove)) | 58 | if (!getParentMap().checkForCollision(this, toMove)) |
54 | { | 59 | { |
55 | setAnimationStep(2); | 60 | setAnimationStep(2); |
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java index b31705d..530af6f 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java | |||
@@ -9,7 +9,6 @@ import com.fourisland.fourpuzzle.Layer; | |||
9 | import java.awt.Graphics; | 9 | import java.awt.Graphics; |
10 | import java.util.ArrayList; | 10 | import java.util.ArrayList; |
11 | import com.fourisland.fourpuzzle.Direction; | 11 | import com.fourisland.fourpuzzle.Direction; |
12 | import com.fourisland.fourpuzzle.gamestate.mapview.Map; | ||
13 | import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic; | 12 | import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic; |
14 | 13 | ||
15 | /** | 14 | /** |
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java index 2ee4dca..df4f4ee 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java | |||
@@ -36,6 +36,15 @@ public class MoveEventThread implements Runnable { | |||
36 | 36 | ||
37 | public void run() | 37 | public void run() |
38 | { | 38 | { |
39 | while (ev.isMoving()) | ||
40 | { | ||
41 | try { | ||
42 | Thread.sleep(2); | ||
43 | } catch (InterruptedException ex) { | ||
44 | Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); | ||
45 | } | ||
46 | } | ||
47 | |||
39 | events.add(ev); | 48 | events.add(ev); |
40 | 49 | ||
41 | MoveEventThread.countMoveEventThreads++; | 50 | MoveEventThread.countMoveEventThreads++; |