summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-07 21:34:37 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-07 21:34:37 -0500
commitb2b180730ad252b4a8d15d9bc59895b56c552c29 (patch)
treea378bccac2108b075ae136d035d6b1445b5ea069 /src/com/fourisland/fourpuzzle/gamestate/mapview/event
parent3c297e080145cac7be4badd3b1cd89928da73d9a (diff)
downloadfourpuzzle-b2b180730ad252b4a8d15d9bc59895b56c552c29.tar.gz
fourpuzzle-b2b180730ad252b4a8d15d9bc59895b56c552c29.tar.bz2
fourpuzzle-b2b180730ad252b4a8d15d9bc59895b56c552c29.zip
Added tick-processing to AnimationType
AnimationType is designed to assert some control over a PossibleEvent's Direction and AnimationStep. Previously, it could only allow or disallow the changing of one or both of those fields. Now, certain AnimationTypes (specifically CommonWithStepping, TurnLeft and TurnRight) can modify those fields as well every tick.
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java43
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java19
2 files changed, 29 insertions, 33 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java index 20d6bfc..7824470 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java
@@ -5,6 +5,8 @@
5 5
6package com.fourisland.fourpuzzle.gamestate.mapview.event; 6package com.fourisland.fourpuzzle.gamestate.mapview.event;
7 7
8import com.fourisland.fourpuzzle.util.Interval;
9
8/** 10/**
9 * 11 *
10 * @author hatkirby 12 * @author hatkirby
@@ -14,35 +16,44 @@ public enum AnimationType {
14 * The default AnimationType, it allows the Event to turn and to animate 16 * The default AnimationType, it allows the Event to turn and to animate
15 * while it walks, but it only animates while it moves. 17 * while it walks, but it only animates while it moves.
16 */ 18 */
17 CommonWithoutStepping(true, true, false), 19 CommonWithoutStepping(true, true),
18 /** 20 /**
19 * An AnimationType which allows the Event to turn and to animate. It will 21 * An AnimationType which allows the Event to turn and to animate. It will
20 * animate at all times, even while stationary. 22 * animate at all times, even while stationary.
21 */ 23 */
22 CommonWithStepping(true, true, true), 24 CommonWithStepping(true, true)
25 {
26 Interval in = Interval.createTickInterval(2);
27
28 @Override
29 public void tick(PossibleEvent pe)
30 {
31 if (in.isElapsed())
32 {
33 if (pe.getAnimationStep() == 0)
34 {
35 pe.setAnimationStep(2);
36 } else {
37 pe.setAnimationStep(pe.getAnimationStep()-1);
38 }
39 }
40 }
41 },
23 /** 42 /**
24 * An AnimationType that allows the Event to turn, but not to animate. 43 * An AnimationType that allows the Event to turn, but not to animate.
25 */ 44 */
26 WithoutStepping(true, false, false), 45 WithoutStepping(true, false),
27 /** 46 /**
28 * An AnimationType that does not allow the Event to turn or animate. 47 * An AnimationType that does not allow the Event to turn or animate.
29 */ 48 */
30 FixedGraphic(false, false, false); 49 FixedGraphic(false, false);
31 50
32 private boolean canTurn; 51 private boolean canTurn;
33 private boolean canStep; 52 private boolean canStep;
34 private boolean alwaysStepping; 53 private AnimationType(boolean canTurn, boolean canStep)
35 private AnimationType(boolean canTurn, boolean canStep, boolean alwaysStepping)
36 { 54 {
37 this.canTurn = canTurn; 55 this.canTurn = canTurn;
38 this.canStep = canStep; 56 this.canStep = canStep;
39
40 if (!canStep)
41 {
42 this.alwaysStepping = false;
43 } else {
44 this.alwaysStepping = alwaysStepping;
45 }
46 } 57 }
47 58
48 public boolean canTurn() 59 public boolean canTurn()
@@ -55,9 +66,9 @@ public enum AnimationType {
55 return canStep; 66 return canStep;
56 } 67 }
57 68
58 public boolean isAlwaysStepping() 69 public void tick(PossibleEvent pe)
59 { 70 {
60 return alwaysStepping; 71 // Do nothing
61 } 72 }
62 73
63} 74} \ No newline at end of file
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java index 931c6ca..f31dcaf 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java
@@ -97,25 +97,10 @@ public class PossibleEvent {
97 callback = builder.callback; 97 callback = builder.callback;
98 } 98 }
99 99
100 private boolean aSLC = false;
101 public EventGraphic getGraphic() 100 public EventGraphic getGraphic()
102 { 101 {
103 if (animation.isAlwaysStepping()) 102 animation.tick(this);
104 { 103
105 if (aSLC)
106 {
107 aSLC = false;
108
109 if (animationStep == 0)
110 {
111 setAnimationStep(2);
112 } else {
113 setAnimationStep(animationStep-1);
114 }
115 } else {
116 aSLC = true;
117 }
118 }
119 return graphic; 104 return graphic;
120 } 105 }
121 106