From cacc139f864fa8232fa6ed98de7c3c49bb94344f Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Tue, 17 Mar 2009 16:40:21 -0400 Subject: Engine: Redesigned move frequency Removed frequency from the Event API as LayerEvents are the only type of events that require a move frequency, as move frequency decides how many ticks to wait between each movement. HeroEvent does nothing with it, because the user input decides how often it moves. Also changed frequency to be an integer rather than a bounded enumeration, which is clearer and lets an much larger (but probably unnecessary) range of wait values. --- .../gamestate/mapview/event/AbstractEvent.java | 11 ------- .../fourpuzzle/gamestate/mapview/event/Event.java | 3 -- .../gamestate/mapview/event/HeroEvent.java | 1 - .../gamestate/mapview/event/LayerEvent.java | 8 ++--- .../gamestate/mapview/event/MoveFrequency.java | 34 -------------------- .../gamestate/mapview/event/PossibleEvent.java | 36 +++++++++++++++++----- 6 files changed, 32 insertions(+), 61 deletions(-) delete mode 100644 src/com/fourisland/fourpuzzle/gamestate/mapview/event/MoveFrequency.java (limited to 'src/com') diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java index aa2c3b3..e9482f9 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java @@ -218,15 +218,4 @@ public abstract class AbstractEvent implements Event { { return moveSpeed; } - - private MoveFrequency freq; - public void setFrequency(MoveFrequency freq) - { - this.freq = freq; - } - - public MoveFrequency getFrequency() - { - return freq; - } } diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java index 936394b..0cda403 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/Event.java @@ -51,7 +51,4 @@ public interface Event { public void setMoveSpeed(MoveSpeed moveSpeed); public MoveSpeed getMoveSpeed(); - - public void setFrequency(MoveFrequency freq); - public MoveFrequency getFrequency(); } diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java index 1df6c1d..5db87a0 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java @@ -25,7 +25,6 @@ public class HeroEvent extends AbstractEvent implements Event { { setLocation(new Point()); setMoveSpeed(MoveSpeed.Faster); - setFrequency(MoveFrequency.EIGHT); } public String getLabel() diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java index afaf923..49721a7 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java @@ -103,7 +103,7 @@ public class LayerEvent extends AbstractEvent implements Event { { if (pt.isElapsed()) { - pt.setTimer(getFrequency().getFrequency()-1); + pt.setTimer(getFrequency()-1); Direction toMove = getPossibleEvent().getMovement().nextMovement(new ImmutableEvent(this)); @@ -176,14 +176,12 @@ public class LayerEvent extends AbstractEvent implements Event { return getPossibleEvent().getMoveSpeed(); } - @Override - public void setFrequency(MoveFrequency freq) + public void setFrequency(int freq) { getPossibleEvent().setFrequency(freq); } - @Override - public MoveFrequency getFrequency() + public int getFrequency() { return getPossibleEvent().getFrequency(); } diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/MoveFrequency.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/MoveFrequency.java deleted file mode 100644 index 3e3cc0e..0000000 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/MoveFrequency.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.fourisland.fourpuzzle.gamestate.mapview.event; - -/** - * - * @author hatkirby - */ -public enum MoveFrequency { - - EIGHT(1), - SEVEN(2), - SIX(3), - FIVE(4), - FOUR(5), - THREE(6), - TWO(7), - ONE(8); - - private int freq; - private MoveFrequency(int freq) - { - this.freq = freq; - } - - public int getFrequency() - { - return freq; - } - -} diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java index 3f35943..2d8a141 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java @@ -25,7 +25,7 @@ public class PossibleEvent { private AnimationType animation; private MovementType movement; private MoveSpeed moveSpeed; - private MoveFrequency freq; + private int freq; private EventCallTime calltime; private EventCall callback; @@ -45,16 +45,26 @@ public class PossibleEvent { private AnimationType animation = AnimationType.CommonWithoutStepping; private MovementType movement = new StayStillMovementType(); private MoveSpeed moveSpeed = MoveSpeed.Normal; - private MoveFrequency freq = MoveFrequency.EIGHT; + private int freq = 1; private EventCallTime calltime = EventCallTime.PushKey; private EventCall callback = EventCall.getEmptyEventCall(); + /** + * Set the graphic that this event will display + * + * @param graphic The graphic this event will display + */ public Builder graphic(EventGraphic graphic) { this.graphic = graphic; return this; } + /** + * Set the layer that this event will be on + * + * @param layer The layer (Above, Middle, Below) this event will be on + */ public Builder layer(Layer layer) { this.layer = layer; @@ -79,7 +89,14 @@ public class PossibleEvent { return this; } - public Builder freq(MoveFrequency freq) + /** + * Set how often this event will initiate movement + * + * @param freq How many ticks, minus one, that the event must wait + * before it can start moving. This number must be greater than or equal + * to one. For no pause, use 1. + */ + public Builder freq(int freq) { this.freq = freq; return this; @@ -109,8 +126,8 @@ public class PossibleEvent { layer = builder.layer; animation = builder.animation; movement = builder.movement; - moveSpeed = builder.moveSpeed; - freq = builder.freq; + setMoveSpeed(builder.moveSpeed); + setFrequency(builder.freq); calltime = builder.calltime; callback = builder.callback; } @@ -165,12 +182,17 @@ public class PossibleEvent { return moveSpeed; } - void setFrequency(MoveFrequency freq) + void setFrequency(int freq) { + if (freq < 1) + { + throw new IllegalArgumentException("Frequency must be greater than or equal to one"); + } + this.freq = freq; } - public MoveFrequency getFrequency() + public int getFrequency() { return freq; } -- cgit 1.4.1