From e50f6fe85fd19d2f91a3877ac99eca234537aac2 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sat, 14 Feb 2009 14:36:14 -0500 Subject: Engine: Restricted LayerEvent moving Now, LayerEvents can only move if their current PossibleEvent has a MoveableEventGraphic. --- .../fourpuzzle/gamestate/mapview/event/LayerEvent.java | 12 ++++++++++++ .../mapview/event/graphic/CharSetEventGraphic.java | 2 +- .../mapview/event/graphic/MoveableEventGraphic.java | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/com/fourisland/fourpuzzle/gamestate/mapview/event/graphic/MoveableEventGraphic.java (limited to 'src/com/fourisland') diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java index 5ff2ed1..1bbe3bb 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java @@ -10,6 +10,7 @@ import java.awt.Graphics; import java.util.ArrayList; import com.fourisland.fourpuzzle.Direction; import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic; +import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.MoveableEventGraphic; import com.fourisland.fourpuzzle.gamestate.mapview.event.precondition.Precondition; /** @@ -94,6 +95,17 @@ public class LayerEvent extends AbstractEvent implements Event { } } + @Override + public boolean startMoving(Direction toMove) + { + if (!(getPossibleEvent().getGraphic() instanceof MoveableEventGraphic)) + { + return false; + } + + return super.startMoving(toMove); + } + public Direction getDirection() { return getPossibleEvent().getDirection(); diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/graphic/CharSetEventGraphic.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/graphic/CharSetEventGraphic.java index 6064f24..1f2ee1a 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/graphic/CharSetEventGraphic.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/graphic/CharSetEventGraphic.java @@ -14,7 +14,7 @@ import java.awt.image.BufferedImage; * * @author hatkirby */ -public class CharSetEventGraphic implements EventGraphic { +public class CharSetEventGraphic implements MoveableEventGraphic { private Direction direction = Direction.South; private int animationStep = 1; diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/graphic/MoveableEventGraphic.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/graphic/MoveableEventGraphic.java new file mode 100644 index 0000000..3c57181 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/graphic/MoveableEventGraphic.java @@ -0,0 +1,14 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.fourisland.fourpuzzle.gamestate.mapview.event.graphic; + +/** + * + * @author hatkirby + */ +public interface MoveableEventGraphic extends EventGraphic { + +} -- cgit 1.4.1