diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank/game/states')
5 files changed, 33 insertions, 61 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateAttack.java b/core/src/ch/asynk/tankontank/game/states/StateAttack.java index 14ade37..c8b104c 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java +++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java @@ -26,7 +26,7 @@ public class StateAttack extends StateCommon upHex.set(to); touchUp(); } - selectHex(from); + map.selectHex(from); } } @@ -35,9 +35,9 @@ public class StateAttack extends StateCommon { map.showAttackAssists(false); map.showPossibleTargets(false); - unselectHex(from); + map.unselectHex(from); if (to.x != -1) - unselectHex(to); + map.unselectHex(to); } @Override @@ -53,7 +53,7 @@ public class StateAttack extends StateCommon map.showPossibleTargets(false); to.set(upHex); activePawn = map.getTopPawnAt(to); - showTarget(to, true); + map.showTarget(to, true); map.buildAttack(selectedPawn, activePawn, to, ctrl.currentPlayer.unitIterator()); map.showAttackAssists(true); ctrl.hud.show(false, false, true, true, ctrl.cfg.canCancel); @@ -61,11 +61,11 @@ public class StateAttack extends StateCommon if ((activePawn != null) && map.isInPossibleAttackAssists(upHex)) { if (map.toggleAttackAssist(map.getTopPawnAt(upHex))) { - showAssist(upHex, false); - showTarget(upHex, true); + map.showAssist(upHex, false); + map.showTarget(upHex, true); } else { - showAssist(upHex, true); - showTarget(upHex, false); + map.showAssist(upHex, true); + map.showTarget(upHex, false); } } } diff --git a/core/src/ch/asynk/tankontank/game/states/StateCommon.java b/core/src/ch/asynk/tankontank/game/states/StateCommon.java index c8bf73c..86b8838 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateCommon.java +++ b/core/src/ch/asynk/tankontank/game/states/StateCommon.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.math.GridPoint2; import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.game.Map; -import ch.asynk.tankontank.game.Hex; import ch.asynk.tankontank.game.Ctrl; import ch.asynk.tankontank.game.State; import ch.asynk.tankontank.game.State.StateType; @@ -95,53 +94,26 @@ public abstract class StateCommon implements State return hexInMap(upHex); } - protected void selectHexAndPawn(GridPoint2 point) - { - selectedHex.set(point); - selectedPawn = map.getTopPawnAt(selectedHex); - selectHex(selectedHex); - if (selectedPawn != null) - isEnemy = ctrl.currentPlayer.isEnemy(selectedPawn); - else - isEnemy = false; - System.err.println(" select (" + selectedHex.x + ";" + selectedHex.y + ") " + selectedPawn + (isEnemy ? " enemy " : " friend ")); - } - protected boolean hasPawn() { return (selectedPawn != null); } - protected void unselectHex(GridPoint2 hex) - { - map.enableOverlayOn(hex, Hex.SELECT, false); - } - - protected void selectHex(GridPoint2 hex) - { - map.enableOverlayOn(hex, Hex.SELECT, true); - } - - protected void showAssist(GridPoint2 hex, boolean enable) - { - map.enableOverlayOn(hex, Hex.ASSIST, enable); - } - - protected void showTarget(GridPoint2 hex, boolean enable) - { - map.enableOverlayOn(hex, Hex.TARGET, enable); - } - protected boolean sameHexes(GridPoint2 a, GridPoint2 b) { return ((a.x == b.x) && (a.y == b.y)); } - protected void hidePossibleTargetsMovesAssists() + protected void selectHexAndPawn(GridPoint2 point) { - map.showPossibleMoves(false); - map.showPossibleTargets(false); - map.showMoveAssists(false); + selectedHex.set(point); + selectedPawn = map.getTopPawnAt(selectedHex); + map.selectHex(selectedHex); + if (selectedPawn != null) + isEnemy = ctrl.currentPlayer.isEnemy(selectedPawn); + else + isEnemy = false; + System.err.println(" select (" + selectedHex.x + ";" + selectedHex.y + ") " + selectedPawn + (isEnemy ? " enemy " : " friend ")); } protected void showPossibleTargetsMovesAssists(Pawn pawn) diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java index 2038855..43a8d7f 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateMove.java +++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java @@ -40,9 +40,9 @@ public class StateMove extends StateCommon { // hide all but assists : want them when in rotation map.showPossibleMoves(false); - unselectHex(from); + map.unselectHex(from); if (to.x != -1) { - unselectHex(to); + map.unselectHex(to); map.showFinalPath(to, false); } @@ -99,7 +99,7 @@ public class StateMove extends StateCommon private void hideAssists() { - showAssist(selectedHex, false); + map.showAssist(selectedHex, false); map.showMoveAssists(false); } @@ -107,13 +107,13 @@ public class StateMove extends StateCommon { if (from.x != -1) { // toggle selected to assist - unselectHex(from); - showAssist(from, true); + map.unselectHex(from); + map.showAssist(from, true); } from.set(next); activePawn = map.getTopPawnAt(from); - selectHex(from); - showAssist(from, false); + map.selectHex(from); + map.showAssist(from, false); map.showPossibleMoves(false); map.buildPossibleMoves(activePawn, from); map.showPossibleMoves(true); @@ -123,7 +123,7 @@ public class StateMove extends StateCommon { to.set(upHex.x, upHex.y); int s = map.buildPossiblePaths(activePawn, from, to); - selectHex(to); + map.selectHex(to); map.showPossibleMoves(false); map.showPossiblePaths(true, true); 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 431c5a1..9b26288 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java +++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java @@ -27,11 +27,11 @@ public class StateRotate extends StateCommon to.set(from); } else { // show final path - selectHex(to); + map.selectHex(to); map.showFinalPath(to, true); } - selectHex(from); + map.selectHex(from); map.showDirections(to, true); rotationSet = false; @@ -40,8 +40,8 @@ public class StateRotate extends StateCommon @Override public void leave(StateType nextState) { - unselectHex(to); - unselectHex(from); + map.unselectHex(to); + map.unselectHex(from); map.showFinalPath(to, false); map.showDirections(to, false); map.showOrientation(to, false, o); @@ -93,7 +93,7 @@ public class StateRotate extends StateCommon private void hideAssists() { - showAssist(selectedHex, false); + map.showAssist(selectedHex, false); map.showMoveAssists(false); } diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java index c02c0c7..0ae3465 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java +++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java @@ -21,13 +21,13 @@ public class StateSelect extends StateCommon @Override public void leave(StateType nextState) { - hidePossibleTargetsMovesAssists(); + map.hidePossibleTargetsMovesAssists(); } @Override public void touchDown() { - if (selectedHex.x != -1) unselectHex(selectedHex); + if (selectedHex.x != -1) map.unselectHex(selectedHex); } @Override @@ -49,7 +49,7 @@ public class StateSelect extends StateCommon } selectHexAndPawn(upHex); - hidePossibleTargetsMovesAssists(); + map.hidePossibleTargetsMovesAssists(); if (hasPawn() && (!isEnemy || ctrl.cfg.showEnemyPossibilities)) { int moves = map.buildPossibleMoves(selectedPawn, selectedHex); |