summary refs log tree commit diff stats
path: root/src/com/fourisland
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
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')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java34
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java5
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java1
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java9
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;
9import java.awt.Graphics; 9import java.awt.Graphics;
10import java.util.ArrayList; 10import java.util.ArrayList;
11import com.fourisland.fourpuzzle.Direction; 11import com.fourisland.fourpuzzle.Direction;
12import com.fourisland.fourpuzzle.gamestate.mapview.Map;
13import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic; 12import 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++;