summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game/states
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-29 12:25:22 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-29 12:25:22 +0100
commitb4e5f726ca304b0c00021d7a108542a135666df4 (patch)
treeab4fff5a7d2ee6e77b50a0a69706d347f6437a80 /core/src/ch/asynk/tankontank/game/states
parent1415dfab3ed8126cf0ffa2061bcd61cf3196c6d7 (diff)
downloadRustAndDust-b4e5f726ca304b0c00021d7a108542a135666df4.zip
RustAndDust-b4e5f726ca304b0c00021d7a108542a135666df4.tar.gz
Map,Unit: simplify show/hide functions
Diffstat (limited to 'core/src/ch/asynk/tankontank/game/states')
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateAttack.java35
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateCommon.java14
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateMove.java38
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateRotate.java26
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateSelect.java6
5 files changed, 57 insertions, 62 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateAttack.java b/core/src/ch/asynk/tankontank/game/states/StateAttack.java
index 0e637fd..1e46c9c 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java
@@ -17,16 +17,16 @@ public class StateAttack extends StateCommon
if (fromSelect) {
activeUnit = null;
// use selectedHex and selectedUnit
- map.possibleTargets.hide();
+ map.hidePossibleTargets();
map.buildPossibleTargets(selectedUnit, ctrl.opponent.unitIterator());
- map.possibleTargets.show();
+ map.showPossibleTargets();
if (to != null) {
// quick fire -> replay touchUp
upHex = to;
touchUp();
}
- selectedUnit.showAttack(true);
- map.selectHex(selectedHex, true);
+ selectedUnit.showAttack();
+ map.selectHex(selectedHex);
} else
System.err.println("should not happen");
}
@@ -34,13 +34,12 @@ public class StateAttack extends StateCommon
@Override
public void leave(StateType nextState)
{
- selectedUnit.showAttack(false);
- map.attackAssists.enable(Unit.ATTACK, false);
- map.attackAssists.enable(Unit.ATTACK_ASSIST, false);
- map.possibleTargets.hide();
- map.selectHex(selectedHex, false);
+ selectedUnit.hideAttack();
+ map.hideAttackAssists();
+ map.hidePossibleTargets();
+ map.unselectHex(selectedHex);
if (to != null)
- map.selectHex(to, false);
+ map.unselectHex(to);
}
@Override
@@ -55,23 +54,17 @@ public class StateAttack extends StateCommon
// activeUnit is the target
if ((activeUnit == null) && map.possibleTargets.contains(unit)) {
- map.possibleTargets.hide();
+ map.hidePossibleTargets();
to = upHex;
activeUnit = unit;
- activeUnit.showTarget(true);
+ activeUnit.showTarget();
map.buildAttackAssists(selectedUnit, activeUnit, ctrl.player.unitIterator());
- map.attackAssists.show();
+ map.showAttackAssists();
ctrl.hud.show(false, false, false, true, true, ctrl.cfg.canCancel);
}
if ((activeUnit != null) && map.attackAssists.contains(unit)) {
- if (map.toggleAttackAssist(unit)) {
- unit.showAttack(true);
- unit.showAttackAssist(false);
- } else {
- unit.showAttack(false);
- unit.showAttackAssist(true);
- }
+ map.toggleAttackAssist(unit);
}
}
@@ -90,7 +83,7 @@ public class StateAttack extends StateCommon
System.err.print(" attack (" + selectedHex.getCol() + ";" + selectedHex.getRow() + ") -> (" + to.getCol() + ";" + to.getRow() + ") : 2D6 -> (" + d1 + " + " + d2 + ")");
if (map.attackPawn(selectedUnit, activeUnit, d1 + d2))
ctrl.player.casualty(activeUnit);
- activeUnit.showTarget(true);
+ activeUnit.showTarget();
ctrl.setState(StateType.ANIMATION);
super.done();
diff --git a/core/src/ch/asynk/tankontank/game/states/StateCommon.java b/core/src/ch/asynk/tankontank/game/states/StateCommon.java
index 4ab9ec6..9c229b2 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateCommon.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateCommon.java
@@ -96,7 +96,7 @@ public abstract class StateCommon implements State
{
selectedHex = hex;
selectedUnit = selectedHex.getUnit();
- map.selectHex(selectedHex, true);
+ map.selectHex(selectedHex);
if (selectedUnit != null)
isEnemy = ctrl.player.isEnemy(selectedUnit);
else
@@ -106,15 +106,15 @@ public abstract class StateCommon implements State
protected void showPossibleTargetsMovesAssists(Unit pawn)
{
- if (ctrl.cfg.showMoves && pawn.canMove()) map.possibleMoves.show();
- if (ctrl.cfg.showTargets && pawn.canAttack()) map.possibleTargets.show();
- if (ctrl.cfg.showMoveAssists && pawn.canMove()) map.moveablePawns.show();
+ if (ctrl.cfg.showMoves && pawn.canMove()) map.showPossibleMoves();
+ if (ctrl.cfg.showTargets && pawn.canAttack()) map.showPossibleTargets();
+ if (ctrl.cfg.showMoveAssists && pawn.canMove()) map.showMoveablePawns();
}
protected void hidePossibleTargetsMovesAssists()
{
- map.possibleMoves.hide();
- map.possibleTargets.hide();
- map.moveablePawns.hide();
+ map.hidePossibleMoves();
+ map.hidePossibleTargets();
+ map.hideMoveablePawns();
}
}
diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java
index f976b31..6caf096 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateMove.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java
@@ -17,7 +17,7 @@ public class StateMove extends StateCommon
if (fromSelect) {
// use selectedHex and selectedUnit
activeUnit = selectedUnit;
- activeUnit.showMoveable(true);
+ activeUnit.showMoveable();
map.buildAndShowMovesAndAssits(activeUnit);
if (to != null) {
// quick move -> replay touchUp
@@ -38,12 +38,12 @@ public class StateMove extends StateCommon
public void leave(StateType nextState)
{
// hide all but assists : want them when in rotation
- activeUnit.showMoveable(false);
- map.possibleMoves.hide();
- map.selectHex(activeUnit.getHex(), false);
+ activeUnit.hideMoveable();
+ map.hidePossibleMoves();
+ map.unselectHex(activeUnit.getHex());
if (to != null) {
- map.selectHex(to, false);
- map.showFinalPath(to, false);
+ map.unselectHex(to);
+ map.hideFinalPath(to);
}
if (nextState != StateType.SELECT) {
@@ -99,31 +99,31 @@ public class StateMove extends StateCommon
private void hideAssists()
{
- map.showAssist(selectedHex, false);
- map.moveablePawns.hide();
+ map.hideAssist(selectedHex);
+ map.hideMoveablePawns();
}
private void changeUnit(Unit unit)
{
if (activeUnit != null )
- map.selectHex(activeUnit.getHex(), false);
+ map.unselectHex(activeUnit.getHex());
activeUnit = unit;
Hex hex = activeUnit.getHex();
- map.selectHex(hex, true);
- map.showAssist(hex, false);
- activeUnit.showMoveable(true);
- map.possibleMoves.hide();
+ map.selectHex(hex);
+ map.hideAssist(hex);
+ activeUnit.showMoveable();
+ map.hidePossibleMoves();
map.buildPossibleMoves(activeUnit);
- map.possibleMoves.show();
+ map.showPossibleMoves();
}
private int buildPaths()
{
to = upHex;
int s = map.buildPossiblePaths(activeUnit, to);
- map.selectHex(to, true);
- map.possibleMoves.hide();
- map.showPossiblePaths(true, true);
+ map.selectHex(to);
+ map.hidePossibleMoves();
+ map.showPossiblePaths();
return s;
}
@@ -134,10 +134,10 @@ public class StateMove extends StateCommon
} else if (downHex == to) {
//
} else {
- map.showPossiblePaths(false, true);
+ map.hidePossiblePaths();
map.togglePathOverlay(downHex);
s = map.possiblePathsPointToggle(downHex);
- map.showPossiblePaths(true, true);
+ map.showPossiblePaths();
}
return s;
diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
index e13923e..e9d6b65 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
@@ -26,12 +26,12 @@ public class StateRotate extends StateCommon
if (to == null)
System.err.println("to is null but should not be");
// show final path
- map.selectHex(to, true);
- map.showFinalPath(to, true);
+ map.selectHex(to);
+ map.showFinalPath(to);
}
- map.selectHex(activeUnit.getHex(), true);
- map.showDirections(to, true);
+ map.selectHex(activeUnit.getHex());
+ map.showDirections(to);
rotationSet = false;
}
@@ -39,11 +39,11 @@ public class StateRotate extends StateCommon
@Override
public void leave(StateType nextState)
{
- map.selectHex(to, false);
- map.selectHex(activeUnit.getHex(), false);
- map.showFinalPath(to, false);
- map.showDirections(to, false);
- map.showOrientation(to, false, o);
+ map.unselectHex(to);
+ map.unselectHex(activeUnit.getHex());
+ map.hideFinalPath(to);
+ map.hideDirections(to);
+ map.hideOrientation(to);
}
@Override
@@ -65,8 +65,8 @@ public class StateRotate extends StateCommon
if (ctrl.cfg.mustValidate) {
- map.showDirections(to, false);
- map.showOrientation(to, true, o);
+ map.hideDirections(to);
+ map.showOrientation(to, o);
ctrl.hud.show(false, true, false, false, true, ctrl.cfg.canCancel);
} else
doRotation(o);
@@ -95,8 +95,8 @@ public class StateRotate extends StateCommon
private void hideAssists()
{
- map.showAssist(selectedHex, false);
- map.moveablePawns.hide();
+ map.hideMoveablePawns();
+ map.hideAssist(selectedHex);
}
private void doRotation(Orientation o)
diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
index d4d010c..0fa45de 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
@@ -27,7 +27,8 @@ public class StateSelect extends StateCommon
@Override
public void touchDown()
{
- if (selectedHex != null) map.selectHex(selectedHex, false);
+ if (selectedHex != null)
+ map.unselectHex(selectedHex);
}
@Override
@@ -80,7 +81,8 @@ public class StateSelect extends StateCommon
@Override
public void abort()
{
- if (selectedHex != null) map.selectHex(selectedHex, false);
+ if (selectedHex != null)
+ map.unselectHex(selectedHex);
hidePossibleTargetsMovesAssists();
clearAll();
map.clearAll();