summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-03-31 19:54:56 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-03-31 19:54:56 +0200
commitbd48aec74bfaae670ec0bb9eae6d9d1b537ef10a (patch)
tree98c22802e8ad49f80fc7b8f89229989d9aa392ad
parent1a658958d658a5e308b30c2e89aaa3aae223bbad (diff)
downloadRustAndDust-bd48aec74bfaae670ec0bb9eae6d9d1b537ef10a.zip
RustAndDust-bd48aec74bfaae670ec0bb9eae6d9d1b537ef10a.tar.gz
Ctrl: add Event.Type.ANIMATIONS_DONE and use it
-rw-r--r--core/src/ch/asynk/rustanddust/game/Ctrl.java39
-rw-r--r--core/src/ch/asynk/rustanddust/game/Hud.java2
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map3Animations.java5
3 files changed, 27 insertions, 19 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java
index 01a3748..65155c6 100644
--- a/core/src/ch/asynk/rustanddust/game/Ctrl.java
+++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java
@@ -33,7 +33,8 @@ class Event
public enum Type
{
STATE_CHANGE,
- HUD_ANSWER;
+ HUD_ANSWER,
+ ANIMATIONS_DONE;
}
public Type type;
@@ -192,6 +193,13 @@ public abstract class Ctrl implements Disposable
events.enqueue(evt);
}
+ public void postAnimationsDone()
+ {
+ Event evt = getEvent();
+ evt.type = Event.Type.ANIMATIONS_DONE;
+ events.enqueue(evt);
+ }
+
public void processEvent()
{
if (events.size() <= 0)
@@ -205,6 +213,9 @@ public abstract class Ctrl implements Disposable
case HUD_ANSWER:
handleHudAnswer(evt);
break;
+ case ANIMATIONS_DONE:
+ animationsDone();
+ break;
default:
RustAndDust.error(String.format("Unhandled Event Type : %s %s", evt.type, evt.data));
}
@@ -259,19 +270,6 @@ public abstract class Ctrl implements Disposable
state.touch(touchedHex);
}
- // Map callbacks
-
- public void animationsOver()
- {
- if (hud.dialogActive())
- hud.notifyAnimationsEnd();
- if (stateType == StateType.ANIMATION) {
- StateType tmp = stateAfterAnimation;
- stateAfterAnimation = StateType.DONE;
- setState(tmp);
- }
- }
-
// State callbacks
public void setAfterAnimationState(StateType after)
@@ -279,7 +277,7 @@ public abstract class Ctrl implements Disposable
stateAfterAnimation = after;
}
- // Hud callbacks
+ // Event handlers
private void handleHudAnswer(Event evt)
{
@@ -308,6 +306,17 @@ public abstract class Ctrl implements Disposable
}
}
+ private void animationsDone()
+ {
+ if (hud.dialogActive())
+ hud.notifyAnimationsDone();
+ if (stateType == StateType.ANIMATION) {
+ StateType tmp = stateAfterAnimation;
+ stateAfterAnimation = StateType.DONE;
+ setState(tmp);
+ }
+ }
+
public void showEntryZone()
{
if ((stateType == StateType.DEPLOYMENT) || (stateType == StateType.REINFORCEMENT))
diff --git a/core/src/ch/asynk/rustanddust/game/Hud.java b/core/src/ch/asynk/rustanddust/game/Hud.java
index ec58233..1262a80 100644
--- a/core/src/ch/asynk/rustanddust/game/Hud.java
+++ b/core/src/ch/asynk/rustanddust/game/Hud.java
@@ -233,7 +233,7 @@ public class Hud implements Disposable, Animation
ctrl.blockMap = false;
}
- public void notifyAnimationsEnd()
+ public void notifyAnimationsDone()
{
delay = CLOSE_DELAY;
delayOn = true;
diff --git a/core/src/ch/asynk/rustanddust/game/map/Map3Animations.java b/core/src/ch/asynk/rustanddust/game/map/Map3Animations.java
index c97d332..d6614f1 100644
--- a/core/src/ch/asynk/rustanddust/game/map/Map3Animations.java
+++ b/core/src/ch/asynk/rustanddust/game/map/Map3Animations.java
@@ -140,8 +140,7 @@ public abstract class Map3Animations extends Map2Moves implements MoveToAnimatio
if (soundId >= 0) {
addAnimation( SoundAnimation.get(SoundAnimation.Action.FADE_OUT, sound, soundId, game.config.fxVolume, 0.5f));
soundId = -1;
- return;
- }
- game.ctrl.animationsOver();
+ } else
+ game.ctrl.postAnimationsDone();
}
}