summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-03 16:45:25 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-03 16:45:25 -0500
commit0a37b19bc1afc4369c7e423bb07f432196273bc9 (patch)
tree718b70724a1fc2fa51b719e257b7df7be55b5e13 /src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
parent77a0ab8efb59cb86c2dfb57be2d41a80e12884ba (diff)
downloadfourpuzzle-0a37b19bc1afc4369c7e423bb07f432196273bc9.tar.gz
fourpuzzle-0a37b19bc1afc4369c7e423bb07f432196273bc9.tar.bz2
fourpuzzle-0a37b19bc1afc4369c7e423bb07f432196273bc9.zip
Added support for OnHeroTouch events
Also fixed two bugs:

1. In the condition where a StepMoveEvent is called upon an Event whose animation type does not allow them to turn in the desired direction, they will move in the direction they are already in and walk off the screen while doing so. This was fixed by checking (after the event's direction has been set during the startMoving() process) that the event was able to face in the correct direction.

2. If a StepMoveEvent was enacted on an event that was already moving, it would be skipped. This has been fixed by waiting for the desired event to complete moving at the start of MoveEventThread.
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java34
1 files changed, 33 insertions, 1 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())