summary refs log tree commit diff stats
path: root/src/com/fourisland
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-02 18:24:44 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-02 18:24:44 -0500
commitb0a76c38cdffbf8813a5e326edb02d97ae2a8188 (patch)
treefabfa1ba94d5d470c37fbb513a12cc8a255b2157 /src/com/fourisland
parentd3fce19421fa2db6aece07aa396a1a9c48c61fd9 (diff)
downloadfourpuzzle-b0a76c38cdffbf8813a5e326edb02d97ae2a8188.tar.gz
fourpuzzle-b0a76c38cdffbf8813a5e326edb02d97ae2a8188.tar.bz2
fourpuzzle-b0a76c38cdffbf8813a5e326edb02d97ae2a8188.zip
Added LoopUntilCollisionMoveEvent
LoopUntilCollisionMoveEvent repeats an array of MoveEvents until the event in question collides with something. This is done by comparing the location of the event before and after the actions. It is a replacement for the deprecated CycleUpDownMovementType and CycleLeftRightMovementType.
Diffstat (limited to 'src/com/fourisland')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/MovementType.java9
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java40
2 files changed, 41 insertions, 8 deletions
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 78309ae..7beba85 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/MovementType.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/MovementType.java
@@ -15,11 +15,4 @@ public interface MovementType {
15 15
16 public Direction nextMovement(); 16 public Direction nextMovement();
17 17
18} 18} \ No newline at end of file
19
20/*
21 CycleUpDown
22 CycleLeftRight
23 StepTowardHero
24 StepAwayFromHero
25*/ \ No newline at end of file
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java new file mode 100644 index 0000000..4c9eb6e --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java
@@ -0,0 +1,40 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove;
7
8import com.fourisland.fourpuzzle.gamestate.mapview.event.Event;
9import java.awt.Point;
10
11/**
12 *
13 * @author hatkirby
14 */
15public class LoopUntilCollisionMoveEvent implements MoveEvent {
16
17 private Point loc;
18 private MoveEvent[] moves;
19
20 public LoopUntilCollisionMoveEvent(MoveEvent[] moves)
21 {
22 this.moves = moves;
23 }
24
25 public void doAction(Event ev)
26 {
27 loc = new Point();
28
29 while ((loc == null) || (!loc.equals(ev.getLocation())))
30 {
31 loc.setLocation(ev.getLocation());
32
33 for (MoveEvent move : moves)
34 {
35 move.doAction(ev);
36 }
37 }
38 }
39
40}