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-01-19 16:22:50 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-01-19 16:22:50 -0500
commit80fd704e66e98d70e98da977b01568b7813d80e9 (patch)
tree8ea16d1f3d37a212c42025e3fbc86d1f4c15545f /src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
parent69b495c392bffe96dab97306a42466edd4b2474e (diff)
downloadfourpuzzle-80fd704e66e98d70e98da977b01568b7813d80e9.tar.gz
fourpuzzle-80fd704e66e98d70e98da977b01568b7813d80e9.tar.bz2
fourpuzzle-80fd704e66e98d70e98da977b01568b7813d80e9.zip
Fixed MoveEvent bug
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java55
1 files changed, 26 insertions, 29 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java index 0e5ec44..6aeac83 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
@@ -13,10 +13,12 @@ import com.fourisland.fourpuzzle.Game;
13import com.fourisland.fourpuzzle.Layer; 13import com.fourisland.fourpuzzle.Layer;
14import com.fourisland.fourpuzzle.PuzzleApplication; 14import com.fourisland.fourpuzzle.PuzzleApplication;
15import com.fourisland.fourpuzzle.gamestate.mapview.event.EventCallTime; 15import com.fourisland.fourpuzzle.gamestate.mapview.event.EventCallTime;
16import com.fourisland.fourpuzzle.gamestate.mapview.event.EventList;
16import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; 17import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent;
18import com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove.MoveEventThread;
19import com.fourisland.fourpuzzle.util.Functions;
17import java.awt.Graphics2D; 20import java.awt.Graphics2D;
18import java.awt.event.KeyEvent; 21import java.awt.event.KeyEvent;
19import java.util.ArrayList;
20 22
21/** 23/**
22 * 24 *
@@ -67,7 +69,7 @@ public class MapViewGameState implements GameState {
67 debugWalkthrough = false; 69 debugWalkthrough = false;
68 } 70 }
69 71
70 if (!hero.isMoving()) 72 if (!hero.isMoving() && !MoveEventThread.isHeroMoving())
71 { 73 {
72 Direction toMove = null; 74 Direction toMove = null;
73 Boolean letsMove = false; 75 Boolean letsMove = false;
@@ -104,29 +106,22 @@ public class MapViewGameState implements GameState {
104 106
105 if ((Game.getKey().getKeyCode() == KeyEvent.VK_ENTER) || (Game.getKey().getKeyCode() == KeyEvent.VK_SPACE)) 107 if ((Game.getKey().getKeyCode() == KeyEvent.VK_ENTER) || (Game.getKey().getKeyCode() == KeyEvent.VK_SPACE))
106 { 108 {
107 int i=0; 109 for (LayerEvent ev : currentMap.getEvents())
108 for (i=0;i<currentMap.getEvents().size();i++)
109 { 110 {
110 LayerEvent ev = currentMap.getEvents().get(i);
111
112 if (ev.getCalltime() == EventCallTime.PushKey) 111 if (ev.getCalltime() == EventCallTime.PushKey)
113 { 112 {
114 if ((hero.getDirection() == Direction.North) && (ev.getLocation().x == hero.getLocation().x) && (ev.getLocation().y == (hero.getLocation().y - 1))) 113 if (ev.getLayer() == Layer.Middle)
115 {
116 ev.setDirection(Direction.South);
117 ev.getCallback().run();
118 } else if ((hero.getDirection() == Direction.West) && (ev.getLocation().x == (hero.getLocation().x - 1)) && (ev.getLocation().y == hero.getLocation().y))
119 {
120 ev.setDirection(Direction.East);
121 ev.getCallback().run();
122 } else if ((hero.getDirection() == Direction.South) && (ev.getLocation().x == hero.getLocation().x) && (ev.getLocation().y == (hero.getLocation().y + 1)))
123 { 114 {
124 ev.setDirection(Direction.North); 115 if (Functions.isFacing(hero, ev))
125 ev.getCallback().run(); 116 {
126 } else if ((hero.getDirection() == Direction.East) && (ev.getLocation().x == (hero.getLocation().x + 1)) && (ev.getLocation().y == hero.getLocation().y)) 117 ev.setDirection(Functions.oppositeDirection(hero.getDirection()));
127 { 118 ev.getCallback().activate();
128 ev.setDirection(Direction.West); 119 }
129 ev.getCallback().run(); 120 } else {
121 if (ev.getLocation().equals(hero.getLocation()))
122 {
123 ev.getCallback().activate();
124 }
130 } 125 }
131 } 126 }
132 } 127 }
@@ -145,14 +140,16 @@ public class MapViewGameState implements GameState {
145 hero.processMoving(); 140 hero.processMoving();
146 } 141 }
147 142
148 int i=0; 143 for (LayerEvent ev : currentMap.getEvents())
149 for (i=0;i<currentMap.getEvents().size();i++)
150 { 144 {
151 if (!currentMap.getEvents().get(i).isMoving()) 145 if (!ev.isMoving())
152 { 146 {
153 currentMap.getEvents().get(i).startMoving(currentMap); 147 if (!MoveEventThread.isOtherMoving(ev))
148 {
149 ev.startMoving(currentMap);
150 }
154 } else { 151 } else {
155 currentMap.getEvents().get(i).processMoving(); 152 ev.processMoving();
156 } 153 }
157 } 154 }
158 } 155 }
@@ -183,10 +180,10 @@ public class MapViewGameState implements GameState {
183 mv.draw(g, true);*/ 180 mv.draw(g, true);*/
184 Game.getSaveFile().getHero().render(g); 181 Game.getSaveFile().getHero().render(g);
185 182
186 ArrayList<LayerEvent> events = currentMap.getEvents(); 183 EventList events = currentMap.getEvents();
187 for (i=0;i<events.size();i++) 184 for (LayerEvent event : events)
188 { 185 {
189 events.get(i).render(g); 186 event.render(g);
190 } 187 }
191 188
192 for (i=0;i<currentMap.getMapData().size();i++) 189 for (i=0;i<currentMap.getMapData().size();i++)