summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-29 02:11:21 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-29 02:11:21 +0100
commiteae09d2d420e226795b08085afe2cc3c28cd6120 (patch)
tree31372ca093f56327785698be4edcacc513a66f9c
parent0af95b0519a78e4959c3645b55b2de7a19d27f59 (diff)
downloadRustAndDust-eae09d2d420e226795b08085afe2cc3c28cd6120.zip
RustAndDust-eae09d2d420e226795b08085afe2cc3c28cd6120.tar.gz
StatePromote,Map: set promote animation
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java27
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StatePromote.java11
2 files changed, 31 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index d0828ba..b059aab 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -17,9 +17,11 @@ import ch.asynk.tankontank.engine.PossiblePaths;
import ch.asynk.tankontank.engine.gfx.Animation;
import ch.asynk.tankontank.engine.gfx.animations.AnimationSequence;
import ch.asynk.tankontank.engine.gfx.animations.ShotAnimation;
+import ch.asynk.tankontank.engine.gfx.animations.PromoteAnimation;
import ch.asynk.tankontank.engine.gfx.animations.SoundAnimation;
import ch.asynk.tankontank.engine.gfx.animations.RunnableAnimation;
+import ch.asynk.tankontank.game.hud.Position;
public abstract class Map extends Board
{
@@ -86,6 +88,7 @@ public abstract class Map extends Board
super(game.factory, cfg, game.manager.get(textureName, Texture.class));
this.ctrl = game.ctrl;
this.moveSound = game.manager.get("sounds/move.mp3", Sound.class);
+ PromoteAnimation.init(game.manager.get("data/hud.atlas", TextureAtlas.class), game.manager.get("sounds/promote.mp3", Sound.class));
ShotAnimation.init(
game.manager.get("data/shots.png", Texture.class), 1, 7,
game.manager.get("data/explosions.png", Texture.class), 16, 8,
@@ -118,6 +121,7 @@ public abstract class Map extends Board
super.dispose();
clearAll();
moveSound.dispose();
+ PromoteAnimation.free();
ShotAnimation.free();
}
@@ -265,6 +269,29 @@ public abstract class Map extends Board
activatedUnits.add(unit);
}
+ public void promoteUnit(final Player player, final Unit unit, Position position)
+ {
+ activatedUnits.add(unit);
+
+ // FIXME
+ float x = 60f;
+ float y = 60f;
+ if (position == Position.TOP_RIGHT)
+ x = getWidth() - 60f;
+
+ Hex hex = unit.getHex();
+ AnimationSequence seq = AnimationSequence.get(2);
+ seq.addAnimation(PromoteAnimation.get(x, y, hex.getX(), hex.getY(), ctrl.cfg.fxVolume));
+ seq.addAnimation ( RunnableAnimation.get(unit, new Runnable() {
+ @Override
+ public void run() {
+ player.promote(unit);
+ animationDone();
+ }
+ }));
+ addAnimation(seq);
+ }
+
public int moveUnit(Unit unit, Orientation o)
{
possiblePaths.orientation = o;
diff --git a/core/src/ch/asynk/tankontank/game/states/StatePromote.java b/core/src/ch/asynk/tankontank/game/states/StatePromote.java
index c6302f4..8cf557a 100644
--- a/core/src/ch/asynk/tankontank/game/states/StatePromote.java
+++ b/core/src/ch/asynk/tankontank/game/states/StatePromote.java
@@ -7,13 +7,10 @@ public class StatePromote extends StateCommon
@Override
public void enter(StateType prevState)
{
- ctrl.hud.actionButtons.hide();
- String str = selectedUnit.toString();
- if (ctrl.player.promote(selectedUnit)) {
- map.activatedUnits.add(selectedUnit);
- // ctrl.hud.notify(str+ " has been promoted");
- }
- ctrl.setState(StateType.DONE);
+ map.promoteUnit(ctrl.player, selectedUnit, ctrl.battle.getHudPosition(ctrl.player));
+ ctrl.setAnimationCount(1);
+ ctrl.setAfterAnimationState(StateType.SELECT);
+ ctrl.setState(StateType.ANIMATION);
}
@Override