summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-01-27 14:28:43 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-01-27 14:28:43 -0500
commit9ca53b553cfaf488f7e8e678721bf9e655fa377e (patch)
treefa110584eb1b083fbe0e005ab9f235f3a8f931f1 /src/com/fourisland/fourpuzzle/gamestate/mapview/event
parentcd6b39590b8aced78fc2f6ed0c345fb9af1960c0 (diff)
downloadfourpuzzle-9ca53b553cfaf488f7e8e678721bf9e655fa377e.tar.gz
fourpuzzle-9ca53b553cfaf488f7e8e678721bf9e655fa377e.tar.bz2
fourpuzzle-9ca53b553cfaf488f7e8e678721bf9e655fa377e.zip
Fixed "walk-thru-me" bug
Previously, Map's checkForCollision did not properly check collision and would allow an event to initiate movement to a location another event was already moving to (but wasn't at yet).
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java2
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java20
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java16
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java14
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/MovementType.java1
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java18
6 files changed, 64 insertions, 7 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java index fbcfd7a..71b507f 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java
@@ -32,4 +32,6 @@ public interface Event {
32 public void startMoving(Direction direction); 32 public void startMoving(Direction direction);
33 33
34 public Layer getLayer(); 34 public Layer getLayer();
35
36 public boolean isOccupyingSpace(int x, int y);
35} 37}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java index 50e16c8..6e8c359 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java
@@ -12,6 +12,7 @@ import com.fourisland.fourpuzzle.Direction;
12import com.fourisland.fourpuzzle.Game; 12import com.fourisland.fourpuzzle.Game;
13import com.fourisland.fourpuzzle.GameCharacter; 13import com.fourisland.fourpuzzle.GameCharacter;
14import com.fourisland.fourpuzzle.gamestate.mapview.CharSet; 14import com.fourisland.fourpuzzle.gamestate.mapview.CharSet;
15import com.fourisland.fourpuzzle.util.Functions;
15 16
16/** 17/**
17 * 18 *
@@ -65,6 +66,10 @@ public class HeroEvent implements Event {
65 } 66 }
66 } 67 }
67 68
69 /* TODO Change the specification of GameCharacter
70 * to require an EventGraphic instead of a graphic name
71 * and offset
72 */
68 GameCharacter toDraw = Game.getSaveFile().getParty().getLeader(); 73 GameCharacter toDraw = Game.getSaveFile().getParty().getLeader();
69 if (!toDraw.getGraphic().equals("blank")) 74 if (!toDraw.getGraphic().equals("blank"))
70 { 75 {
@@ -147,5 +152,20 @@ public class HeroEvent implements Event {
147 { 152 {
148 return Layer.Middle; 153 return Layer.Middle;
149 } 154 }
155
156 public boolean isOccupyingSpace(int x, int y)
157 {
158 if (getLocation().equals(new Point(x,y)))
159 {
160 return true;
161 }
162
163 if (Functions.isMovingTo(this, x, y))
164 {
165 return true;
166 }
167
168 return false;
169 }
150 170
151} 171}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java index 05192ce..4f8b51c 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java
@@ -11,6 +11,7 @@ import java.awt.Point;
11import java.util.ArrayList; 11import java.util.ArrayList;
12import com.fourisland.fourpuzzle.Direction; 12import com.fourisland.fourpuzzle.Direction;
13import com.fourisland.fourpuzzle.gamestate.mapview.Map; 13import com.fourisland.fourpuzzle.gamestate.mapview.Map;
14import com.fourisland.fourpuzzle.util.Functions;
14 15
15/** 16/**
16 * 17 *
@@ -209,4 +210,19 @@ public class LayerEvent implements Event {
209 this.label = string; 210 this.label = string;
210 } 211 }
211 212
213 public boolean isOccupyingSpace(int x, int y)
214 {
215 if (getLocation().equals(new Point(x,y)))
216 {
217 return true;
218 }
219
220 if (Functions.isMovingTo(this, x, y))
221 {
222 return true;
223 }
224
225 return false;
226 }
227
212} \ No newline at end of file 228} \ No newline at end of file
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 077f42e..52b75de 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java
@@ -17,6 +17,14 @@ import java.util.logging.Logger;
17 * @author hatkirby 17 * @author hatkirby
18 */ 18 */
19public class SpecialEvent { 19public class SpecialEvent {
20
21 /* TODO Create a manager for SpecialEvent action threads that
22 * controls when they are executed and allows MapViewGameState
23 * to poll it to see if it is currently managing any action
24 * threads. If it is, MapViewGameState should be able to prevent
25 * certain actions from occuring (unless the action thread is
26 * ParallelProcess) such as keyboard input.
27 */
20 28
21 /** 29 /**
22 * Display a message on the screen. 30 * Display a message on the screen.
@@ -120,11 +128,7 @@ public class SpecialEvent {
120 */ 128 */
121 public void MoveEventWait() 129 public void MoveEventWait()
122 { 130 {
123 try { 131 MoveEventThread.moveAll();
124 MoveEventThread.moveEventWait.await();
125 } catch (InterruptedException ex) {
126 Logger.getLogger(SpecialEvent.class.getName()).log(Level.SEVERE, null, ex);
127 }
128 } 132 }
129 133
130 /** 134 /**
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/MovementType.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/MovementType.java index 5d5822e..7b9ee0c 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/MovementType.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/MovementType.java
@@ -13,6 +13,7 @@ import com.fourisland.fourpuzzle.Direction;
13 */ 13 */
14public interface MovementType { 14public interface MovementType {
15 15
16 // TODO Rename the following method to getNextDirection
16 public Direction startMoving(); 17 public Direction startMoving();
17 18
18} 19}
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 ab160f1..2ee4dca 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java
@@ -20,9 +20,10 @@ import java.util.logging.Logger;
20 */ 20 */
21public class MoveEventThread implements Runnable { 21public class MoveEventThread implements Runnable {
22 22
23 public static volatile CountDownLatch moveEventWait = new CountDownLatch(0);
24 public static volatile int countMoveEventThreads = 0; 23 public static volatile int countMoveEventThreads = 0;
25 public static volatile List<Event> events = new Vector<Event>(); 24
25 static volatile List<Event> events = new Vector<Event>();
26 static volatile CountDownLatch moveEventWait = new CountDownLatch(0);
26 27
27 Event ev; 28 Event ev;
28 MoveEvent[] actions; 29 MoveEvent[] actions;
@@ -51,6 +52,10 @@ public class MoveEventThread implements Runnable {
51 moveEventWait.countDown(); 52 moveEventWait.countDown();
52 } 53 }
53 54
55 /* TODO Rename the two following methods (isHeroMoving and isOtherMoving)
56 * to isHeroActive and isOtherActive respectively.
57 */
58
54 public static boolean isHeroMoving() 59 public static boolean isHeroMoving()
55 { 60 {
56 return (events.contains(Game.getHeroEvent())); 61 return (events.contains(Game.getHeroEvent()));
@@ -60,5 +65,14 @@ public class MoveEventThread implements Runnable {
60 { 65 {
61 return (events.contains(event)); 66 return (events.contains(event));
62 } 67 }
68
69 public static void moveAll()
70 {
71 try {
72 moveEventWait.await();
73 } catch (InterruptedException ex) {
74 Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex);
75 }
76 }
63 77
64} 78}