summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-09 14:03:37 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-09 14:03:37 +0200
commitbe380f190b0fc73256dda71444021e51b0f61de9 (patch)
tree343335b05f2282057c4c63a5e4a53311d93d790f /core/src
parentd456031068b7fb6df8f1ee1d262b26c9ab42c8d1 (diff)
downloadRustAndDust-be380f190b0fc73256dda71444021e51b0f61de9.zip
RustAndDust-be380f190b0fc73256dda71444021e51b0f61de9.tar.gz
GameState: use canAttack, canRotate, canMove and simplify
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateCommon.java15
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateSelect.java10
2 files changed, 16 insertions, 9 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
index b3d7f58..d7e17d4 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
@@ -93,10 +93,17 @@ public abstract class GameStateCommon implements GameState
return ((a.x == b.x) && (a.y == b.y));
}
- protected void showPossibleTargetsMovesAssists(boolean enable)
+ protected void hidePossibleTargetsMovesAssists()
{
- if (ctrl.cfg.showMoves) map.showPossibleMoves(enable);
- if (ctrl.cfg.showTargets) map.showPossibleTargets(enable);
- if (ctrl.cfg.showMoveAssists) map.showMoveAssists(enable);
+ map.showPossibleMoves(false);
+ map.showPossibleTargets(false);
+ map.showMoveAssists(false);
+ }
+
+ protected void showPossibleTargetsMovesAssists(Pawn pawn)
+ {
+ if (ctrl.cfg.showMoves && pawn.canMove()) map.showPossibleMoves(true);
+ if (ctrl.cfg.showTargets && pawn.canAttack()) map.showPossibleTargets(true);
+ if (ctrl.cfg.showMoveAssists && pawn.canMove()) map.showMoveAssists(true);
}
}
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java b/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java
index 5ec9240..49c15fc 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java
@@ -18,7 +18,7 @@ public class GameStateSelect extends GameStateCommon
@Override
public void leave()
{
- showPossibleTargetsMovesAssists(false);
+ hidePossibleTargetsMovesAssists();
}
@Override
@@ -30,14 +30,14 @@ public class GameStateSelect extends GameStateCommon
@Override
public void touchUp()
{
- showPossibleTargetsMovesAssists(false);
+ hidePossibleTargetsMovesAssists();
if (hasPawn()) {
int moves = map.buildPossibleMoves(pawn, hex);
int targets = map.buildPossibleTargets(pawn, hex);
int assists = map.buildMoveAssists(pawn, hex);
- showPossibleTargetsMovesAssists(true);
+ showPossibleTargetsMovesAssists(pawn);
ctrl.hud.show(
- pawn.canMove(),
+ pawn.canRotate(),
(pawn.canMove() && (moves > 0)),
(pawn.canAttack() && (targets > 0)),
false,
@@ -52,7 +52,7 @@ public class GameStateSelect extends GameStateCommon
@Override
public void abort()
{
- showPossibleTargetsMovesAssists(false);
+ hidePossibleTargetsMovesAssists();
super.abort();
}
}