summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-01-27 15:22:34 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-01-27 15:22:34 -0500
commitbbc04275a73aec87d83f264fcf760407363d5c5b (patch)
tree9f82a1cb37c4b5e8d8bc111b51643ffcf5ec3631 /src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java
parent396c5fd662a3b0b21820383d69706d512d16370a (diff)
downloadfourpuzzle-bbc04275a73aec87d83f264fcf760407363d5c5b.tar.gz
fourpuzzle-bbc04275a73aec87d83f264fcf760407363d5c5b.tar.bz2
fourpuzzle-bbc04275a73aec87d83f264fcf760407363d5c5b.zip
Added parentMap data to Event
StepMoveEvent has an issue where an event could walk off the screen under its influence because it preformed no collision checking, due to the fact that the parent map had to be accessable to preform collision checking. Now, both event styles (unified with an AbstractEvent class that handles functions common to both styles) carries information about its parent map, provided by EventList which is in turn provided by the parent map itself.
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java index 62270bf..bc0073e 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java
@@ -6,7 +6,9 @@
6package com.fourisland.fourpuzzle.gamestate.mapview; 6package com.fourisland.fourpuzzle.gamestate.mapview;
7 7
8import com.fourisland.fourpuzzle.*; 8import com.fourisland.fourpuzzle.*;
9import com.fourisland.fourpuzzle.gamestate.mapview.event.Event;
9import com.fourisland.fourpuzzle.gamestate.mapview.event.EventList; 10import com.fourisland.fourpuzzle.gamestate.mapview.event.EventList;
11import com.fourisland.fourpuzzle.gamestate.mapview.event.HeroEvent;
10import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; 12import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent;
11import java.awt.Dimension; 13import java.awt.Dimension;
12import java.util.HashMap; 14import java.util.HashMap;
@@ -41,7 +43,7 @@ public abstract class Map {
41 } 43 }
42 } 44 }
43 45
44 private EventList events = new EventList(); 46 private EventList events = new EventList(this);
45 public EventList getEvents() 47 public EventList getEvents()
46 { 48 {
47 return events; 49 return events;
@@ -59,8 +61,11 @@ public abstract class Map {
59 return null; 61 return null;
60 } 62 }
61 63
62 public boolean checkForCollision(int x, int y, Direction toMove) 64 public boolean checkForCollision(Event ev, Direction toMove)
63 { 65 {
66 int x = ev.getLocation().x;
67 int y = ev.getLocation().y;
68
64 if ((toMove == Direction.North) && (y == 0)) 69 if ((toMove == Direction.North) && (y == 0))
65 { 70 {
66 return true; 71 return true;
@@ -75,6 +80,11 @@ public abstract class Map {
75 return true; 80 return true;
76 } 81 }
77 82
83 if ((ev instanceof HeroEvent) && (((MapViewGameState) Game.getGameState()).debugWalkthrough))
84 {
85 return false;
86 }
87
78 if ((toMove == Direction.North) && (checkForEventCollision(x, y-1))) 88 if ((toMove == Direction.North) && (checkForEventCollision(x, y-1)))
79 { 89 {
80 return true; 90 return true;