diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2009-01-19 16:22:50 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2009-01-19 16:22:50 -0500 |
commit | 80fd704e66e98d70e98da977b01568b7813d80e9 (patch) | |
tree | 8ea16d1f3d37a212c42025e3fbc86d1f4c15545f /src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java | |
parent | 69b495c392bffe96dab97306a42466edd4b2474e (diff) | |
download | fourpuzzle-80fd704e66e98d70e98da977b01568b7813d80e9.tar.gz fourpuzzle-80fd704e66e98d70e98da977b01568b7813d80e9.tar.bz2 fourpuzzle-80fd704e66e98d70e98da977b01568b7813d80e9.zip |
Fixed MoveEvent bug
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java')
-rw-r--r-- | src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java | 28 |
1 files changed, 23 insertions, 5 deletions
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 4c16197..d6971f3 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java | |||
@@ -5,9 +5,12 @@ | |||
5 | 5 | ||
6 | package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove; | 6 | package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove; |
7 | 7 | ||
8 | import com.fourisland.fourpuzzle.Game; | ||
8 | import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; | 9 | import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; |
10 | import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; | ||
11 | import java.util.List; | ||
12 | import java.util.Vector; | ||
9 | import java.util.concurrent.CountDownLatch; | 13 | import java.util.concurrent.CountDownLatch; |
10 | import java.util.concurrent.CyclicBarrier; | ||
11 | import java.util.logging.Level; | 14 | import java.util.logging.Level; |
12 | import java.util.logging.Logger; | 15 | import java.util.logging.Logger; |
13 | 16 | ||
@@ -19,6 +22,7 @@ public class MoveEventThread implements Runnable { | |||
19 | 22 | ||
20 | public static volatile CountDownLatch moveEventWait = new CountDownLatch(0); | 23 | public static volatile CountDownLatch moveEventWait = new CountDownLatch(0); |
21 | public static volatile int countMoveEventThreads = 0; | 24 | public static volatile int countMoveEventThreads = 0; |
25 | public static volatile List<Event> events = new Vector<Event>(); | ||
22 | 26 | ||
23 | Event ev; | 27 | Event ev; |
24 | MoveEvent[] actions; | 28 | MoveEvent[] actions; |
@@ -29,22 +33,36 @@ public class MoveEventThread implements Runnable { | |||
29 | this.actions = actions; | 33 | this.actions = actions; |
30 | } | 34 | } |
31 | 35 | ||
32 | public void run() { | 36 | public void run() |
37 | { | ||
38 | events.add(ev); | ||
39 | |||
33 | MoveEventThread.countMoveEventThreads++; | 40 | MoveEventThread.countMoveEventThreads++; |
34 | moveEventWait = new CountDownLatch(countMoveEventThreads); | 41 | moveEventWait = new CountDownLatch(countMoveEventThreads); |
35 | 42 | ||
36 | int i=0; | 43 | for (MoveEvent action : actions) |
37 | for (i=0;i<actions.length;i++) | ||
38 | { | 44 | { |
39 | try { | 45 | try { |
40 | actions[i].doAction(ev); | 46 | action.doAction(ev); |
41 | } catch (Exception ex) { | 47 | } catch (Exception ex) { |
42 | Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); | 48 | Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); |
43 | } | 49 | } |
44 | } | 50 | } |
45 | 51 | ||
52 | events.remove(ev); | ||
53 | |||
46 | MoveEventThread.countMoveEventThreads--; | 54 | MoveEventThread.countMoveEventThreads--; |
47 | moveEventWait.countDown(); | 55 | moveEventWait.countDown(); |
48 | } | 56 | } |
57 | |||
58 | public static boolean isHeroMoving() | ||
59 | { | ||
60 | return (events.contains(Game.getHeroEvent())); | ||
61 | } | ||
62 | |||
63 | public static boolean isOtherMoving(LayerEvent event) | ||
64 | { | ||
65 | return (events.contains(event)); | ||
66 | } | ||
49 | 67 | ||
50 | } | 68 | } |