From b0a76c38cdffbf8813a5e326edb02d97ae2a8188 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Mon, 2 Feb 2009 18:24:44 -0500 Subject: 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. --- .../mapview/event/movement/MovementType.java | 9 +---- .../specialmove/LoopUntilCollisionMoveEvent.java | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java (limited to 'src') 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 { public Direction nextMovement(); -} - -/* - CycleUpDown - CycleLeftRight - StepTowardHero - StepAwayFromHero -*/ \ No newline at end of file +} \ 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 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove; + +import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; +import java.awt.Point; + +/** + * + * @author hatkirby + */ +public class LoopUntilCollisionMoveEvent implements MoveEvent { + + private Point loc; + private MoveEvent[] moves; + + public LoopUntilCollisionMoveEvent(MoveEvent[] moves) + { + this.moves = moves; + } + + public void doAction(Event ev) + { + loc = new Point(); + + while ((loc == null) || (!loc.equals(ev.getLocation()))) + { + loc.setLocation(ev.getLocation()); + + for (MoveEvent move : moves) + { + move.doAction(ev); + } + } + } + +} -- cgit 1.4.1