summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java6
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java6
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java4
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java34
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java30
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java3
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java3
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java3
10 files changed, 79 insertions, 14 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java index 76582e3..55dc6d0 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java
@@ -26,7 +26,7 @@ public enum AnimationType {
26 */ 26 */
27 CommonWithStepping(true, true) 27 CommonWithStepping(true, true)
28 { 28 {
29 Interval in = Interval.createTickInterval(2); 29 transient Interval in = Interval.createTickInterval(2);
30 30
31 @Override 31 @Override
32 public void tick(PossibleEvent pe) 32 public void tick(PossibleEvent pe)
@@ -56,7 +56,7 @@ public enum AnimationType {
56 */ 56 */
57 TurnLeft(true, true) 57 TurnLeft(true, true)
58 { 58 {
59 Interval in = Interval.createTickInterval(2); 59 transient Interval in = Interval.createTickInterval(2);
60 60
61 @Override 61 @Override
62 public void tick(PossibleEvent pe) 62 public void tick(PossibleEvent pe)
@@ -73,7 +73,7 @@ public enum AnimationType {
73 */ 73 */
74 TurnRight(true, true) 74 TurnRight(true, true)
75 { 75 {
76 Interval in = Interval.createTickInterval(2); 76 transient Interval in = Interval.createTickInterval(2);
77 77
78 @Override 78 @Override
79 public void tick(PossibleEvent pe) 79 public void tick(PossibleEvent pe)
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java index edfdb8f..9c5bf14 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java
@@ -51,11 +51,13 @@ public class CommonEvent {
51 this.callback = callback; 51 this.callback = callback;
52 } 52 }
53 53
54 public EventCallTime getCalltime() { 54 public EventCallTime getCalltime()
55 {
55 return calltime; 56 return calltime;
56 } 57 }
57 58
58 public void setCalltime(EventCallTime calltime) { 59 public void setCalltime(EventCallTime calltime)
60 {
59 this.calltime = calltime; 61 this.calltime = calltime;
60 } 62 }
61 63
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java index e24b79c..9cb67ba 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java
@@ -59,10 +59,10 @@ public class EventHandler {
59 * Also reset the viewpoint in case the viewpoint was 59 * Also reset the viewpoint in case the viewpoint was
60 * fixed during the thread */ 60 * fixed during the thread */
61 61
62 SpecialEvent.mapView.setViewpoint(new AutomaticViewpoint(SpecialEvent.mapView.getCurrentMap())); 62 new SpecialEvent().ResetViewpoint();
63 } catch (ResourceNotFoundException ex) 63 } catch (ResourceNotFoundException ex)
64 { 64 {
65 PuzzleApplication.INSTANCE.reportError(ex); 65 PuzzleApplication.reportError(ex);
66 } 66 }
67 } 67 }
68 }; 68 };
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java index 7120a91..d790195 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java
@@ -14,6 +14,8 @@ import java.util.Vector;
14 */ 14 */
15public class EventList extends Vector<LayerEvent> { 15public class EventList extends Vector<LayerEvent> {
16 16
17 private static final long serialVersionUID = 765438545;
18
17 public EventList(Map parentMap) 19 public EventList(Map parentMap)
18 { 20 {
19 setParentMap(parentMap); 21 setParentMap(parentMap);
@@ -62,7 +64,7 @@ public class EventList extends Vector<LayerEvent> {
62 return super.add(o); 64 return super.add(o);
63 } 65 }
64 66
65 private Map parentMap = null; 67 private transient Map parentMap = null;
66 public Map getParentMap() 68 public Map getParentMap()
67 { 69 {
68 return parentMap; 70 return parentMap;
@@ -77,4 +79,34 @@ public class EventList extends Vector<LayerEvent> {
77 } 79 }
78 } 80 }
79 81
82 @Override
83 public int hashCode()
84 {
85 int hash = 3;
86 hash = 59 * hash + (this.parentMap != null ? this.parentMap.hashCode() : 0);
87 return hash;
88 }
89
90 @Override
91 public boolean equals(Object obj)
92 {
93 if (obj == null)
94 {
95 return false;
96 }
97
98 if (getClass() != obj.getClass())
99 {
100 return false;
101 }
102
103 final EventList other = (EventList) obj;
104 if (this.parentMap != other.parentMap && (this.parentMap == null || !this.parentMap.equals(other.parentMap)))
105 {
106 return false;
107 }
108
109 return true;
110 }
111
80} 112}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java index 5db87a0..1f5607e 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java
@@ -14,12 +14,18 @@ import com.fourisland.fourpuzzle.database.GameCharacter;
14import com.fourisland.fourpuzzle.gamestate.mapview.Map; 14import com.fourisland.fourpuzzle.gamestate.mapview.Map;
15import com.fourisland.fourpuzzle.gamestate.mapview.MapViewGameState; 15import com.fourisland.fourpuzzle.gamestate.mapview.MapViewGameState;
16import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic; 16import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic;
17import java.io.IOException;
18import java.io.ObjectInputStream;
19import java.io.ObjectOutputStream;
20import java.io.Serializable;
17 21
18/** 22/**
19 * 23 *
20 * @author hatkirby 24 * @author hatkirby
21 */ 25 */
22public class HeroEvent extends AbstractEvent implements Event { 26public class HeroEvent extends AbstractEvent implements Event, Serializable {
27
28 private static final long serialVersionUID = 402340890;
23 29
24 public HeroEvent() 30 public HeroEvent()
25 { 31 {
@@ -73,5 +79,27 @@ public class HeroEvent extends AbstractEvent implements Event {
73 { 79 {
74 return ((MapViewGameState) Game.getGameState()).getCurrentMap(); 80 return ((MapViewGameState) Game.getGameState()).getCurrentMap();
75 } 81 }
82
83 /**
84 * Serialize this HeroEvent instance
85 *
86 * When serializing a HeroEvent, the only information that is really
87 * necessary is the Hero's location and direction, because all other
88 * important information is serialized by SaveFile.
89 *
90 * @serialData The Hero's location (as a Point object) is emitted, followed
91 * by the a Direction object representing the Hero's direction.
92 */
93 private void writeObject(ObjectOutputStream s) throws IOException
94 {
95 s.writeObject(getLocation());
96 s.writeObject(getDirection());
97 }
98
99 private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
100 {
101 setLocation((Point) s.readObject());
102 setDirection((Direction) s.readObject());
103 }
76 104
77} 105}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java index b722b68..7bd0c42 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java
@@ -26,7 +26,7 @@ public final class ImmutableEvent
26 26
27 public String getLabel() 27 public String getLabel()
28 { 28 {
29 return new String(ev.getLabel()); 29 return ev.getLabel();
30 } 30 }
31 31
32 public Point getLocation() 32 public Point getLocation()
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 2db33f7..30db7a2 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java
@@ -30,7 +30,7 @@ import java.util.concurrent.CountDownLatch;
30 */ 30 */
31public class SpecialEvent { 31public class SpecialEvent {
32 32
33 protected static MapViewGameState mapView = null; 33 private static MapViewGameState mapView = null;
34 public static void setMapView(MapViewGameState mapView) 34 public static void setMapView(MapViewGameState mapView)
35 { 35 {
36 SpecialEvent.mapView = mapView; 36 SpecialEvent.mapView = mapView;
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java index 78dd991..a63feda 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java
@@ -7,6 +7,7 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event.movement;
7 7
8import com.fourisland.fourpuzzle.Direction; 8import com.fourisland.fourpuzzle.Direction;
9import com.fourisland.fourpuzzle.gamestate.mapview.event.ImmutableEvent; 9import com.fourisland.fourpuzzle.gamestate.mapview.event.ImmutableEvent;
10import java.util.Arrays;
10 11
11/** 12/**
12 * CustomMovementEvent takes an array of Directions and directions the event 13 * CustomMovementEvent takes an array of Directions and directions the event
@@ -22,7 +23,7 @@ public class CustomMovementType implements MovementType {
22 23
23 public CustomMovementType(Direction[] moves) 24 public CustomMovementType(Direction[] moves)
24 { 25 {
25 this.moves = moves; 26 this.moves = Arrays.copyOf(moves, moves.length);
26 } 27 }
27 28
28 public Direction nextMovement(ImmutableEvent ev) 29 public Direction nextMovement(ImmutableEvent ev)
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java index 02744d0..daceffd 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java
@@ -7,6 +7,7 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove;
7 7
8import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; 8import com.fourisland.fourpuzzle.gamestate.mapview.event.Event;
9import java.awt.Point; 9import java.awt.Point;
10import java.util.Arrays;
10 11
11/** 12/**
12 * LoopUntilCollisionMoveEvent takes an array of <b>MoveEvent</b>s and repeatedly 13 * LoopUntilCollisionMoveEvent takes an array of <b>MoveEvent</b>s and repeatedly
@@ -24,7 +25,7 @@ public class LoopUntilCollisionMoveEvent implements MoveEvent {
24 25
25 public LoopUntilCollisionMoveEvent(MoveEvent[] moves) 26 public LoopUntilCollisionMoveEvent(MoveEvent[] moves)
26 { 27 {
27 this.moves = moves; 28 this.moves = Arrays.copyOf(moves, moves.length);
28 } 29 }
29 30
30 public void doAction(Event ev) 31 public void doAction(Event ev)
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 d05a3d8..dae49cb 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java
@@ -9,6 +9,7 @@ import com.fourisland.fourpuzzle.Game;
9import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; 9import com.fourisland.fourpuzzle.gamestate.mapview.event.Event;
10import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; 10import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent;
11import java.util.ArrayList; 11import java.util.ArrayList;
12import java.util.Arrays;
12import java.util.List; 13import java.util.List;
13import java.util.Vector; 14import java.util.Vector;
14import java.util.concurrent.ExecutorService; 15import java.util.concurrent.ExecutorService;
@@ -34,7 +35,7 @@ public class MoveEventThread implements Runnable {
34 public MoveEventThread(Event ev, MoveEvent[] actions) 35 public MoveEventThread(Event ev, MoveEvent[] actions)
35 { 36 {
36 this.ev = ev; 37 this.ev = ev;
37 this.actions = actions; 38 this.actions = Arrays.copyOf(actions, actions.length);
38 } 39 }
39 40
40 public void start() 41 public void start()