summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateCommon.java21
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateMove.java16
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateRotate.java10
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateSelect.java14
4 files changed, 31 insertions, 30 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
index 369b10c..e4365e5 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
@@ -12,10 +12,10 @@ public abstract class GameStateCommon implements GameState
{
protected static GameCtrl ctrl;
protected static Map map;
- protected static Pawn pawn;
protected static Pawn activePawn;
+ protected static Pawn selectedPawn;
- protected static GridPoint2 hex = new GridPoint2(-1, -1);
+ protected static GridPoint2 selectedHex = new GridPoint2(-1, -1);
protected static GridPoint2 downHex = new GridPoint2(-1, -1);
protected static GridPoint2 upHex = new GridPoint2(-1, -1);
protected static GridPoint2 from = new GridPoint2(-1, -1);
@@ -59,9 +59,9 @@ public abstract class GameStateCommon implements GameState
private void clearAndGoToSelect()
{
- unselectHex(hex);
- hex.set(-1, -1);
- pawn = null;
+ unselectHex(selectedHex);
+ selectedHex.set(-1, -1);
+ selectedPawn = null;
ctrl.hud.hide();
ctrl.setState(State.SELECT);
}
@@ -86,14 +86,15 @@ public abstract class GameStateCommon implements GameState
protected void setHexAndPawn(GridPoint2 point)
{
- hex.set(point.x, point.y);
+ selectedHex.set(point);
// TODO : is an enemy or not ?
- pawn = map.getTopPawnAt(hex);
+ selectedPawn = map.getTopPawnAt(selectedHex);
+ System.err.println("setHexAndPawn : " + selectedHex.x + ";" + selectedHex.y + " " + selectedPawn);
}
protected boolean hasPawn()
{
- return (pawn != null);
+ return (selectedPawn != null);
}
protected void unselectHex(GridPoint2 hex)
@@ -113,9 +114,9 @@ public abstract class GameStateCommon implements GameState
protected void reselectHex()
{
- if (hex.x != -1) unselectHex(hex);
+ if (selectedHex.x != -1) unselectHex(selectedHex);
setHexAndPawn(downHex);
- selectHex(hex);
+ selectHex(selectedHex);
}
protected boolean sameHexes(GridPoint2 a, GridPoint2 b)
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateMove.java b/core/src/ch/asynk/tankontank/game/states/GameStateMove.java
index 8c76484..bd767e9 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateMove.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateMove.java
@@ -10,19 +10,19 @@ public class GameStateMove extends GameStateCommon
map.clearPossiblePaths();
if (fromSelect) {
- from.set(hex);
- activePawn = pawn;
+ from.set(selectedHex);
+ activePawn = selectedPawn;
map.buildAndShowMovesAndAssits(activePawn, from);
if (to.x != -1) {
upHex.set(to);
touchUp();
}
} else {
- if ((activePawn == pawn) || !pawn.canMove()) {
+ if ((activePawn == selectedPawn) || !selectedPawn.canMove()) {
upHex.set(map.getFirstMoveAssist());
activePawn = map.getTopPawnAt(upHex);
} else {
- upHex.set(hex);
+ upHex.set(selectedHex);
}
from.set(-1, -1);
changePawn(upHex);
@@ -55,7 +55,7 @@ public class GameStateMove extends GameStateCommon
{
int s = map.possiblePathsSize();
- if (sameHexes(hex, upHex) || map.isInPossibleMoveAssists(upHex)) {
+ if (sameHexes(selectedHex, upHex) || map.isInPossibleMoveAssists(upHex)) {
if(!sameHexes(upHex, from))
changePawn(upHex);
} else if ((s == 0) && map.isInPossibleMoves(upHex)) {
@@ -80,15 +80,15 @@ public class GameStateMove extends GameStateCommon
@Override
public void done()
{
- if (pawn.canMove() && (map.activatedPawnsCount() > 0))
- pawn.move(0);
+ if (selectedPawn.canMove() && (map.activatedPawnsCount() > 0))
+ selectedPawn.move(0);
hideAssists();
super.done();
}
private void hideAssists()
{
- showAssist(hex, false);
+ showAssist(selectedHex, false);
map.showMoveAssists(false);
}
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java b/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java
index 356b73b..6048ce4 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java
@@ -15,8 +15,8 @@ public class GameStateRotate extends GameStateCommon
if (!hasFinalMove) {
to.set(-1, -1);
if (from.x == -1) {
- from.set(hex);
- activePawn = pawn;
+ from.set(selectedHex);
+ activePawn = selectedPawn;
}
}
@@ -86,13 +86,13 @@ public class GameStateRotate extends GameStateCommon
{
// hideAssists();
doRotation(o);
- if (pawn.canMove() && (map.activatedPawnsCount() > 0))
- pawn.move(0);
+ if (selectedPawn.canMove() && (map.activatedPawnsCount() > 0))
+ selectedPawn.move(0);
}
private void hideAssists()
{
- showAssist(hex, false);
+ showAssist(selectedHex, false);
map.showMoveAssists(false);
}
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java b/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java
index b4df8c0..ede55cb 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java
@@ -45,14 +45,14 @@ public class GameStateSelect extends GameStateCommon
hidePossibleTargetsMovesAssists();
if (hasPawn()) {
- int moves = map.buildPossibleMoves(pawn, hex);
- int targets = map.buildPossibleTargets(pawn, hex);
- int assists = map.buildMoveAssists(pawn, hex);
- showPossibleTargetsMovesAssists(pawn);
+ int moves = map.buildPossibleMoves(selectedPawn, selectedHex);
+ int targets = map.buildPossibleTargets(selectedPawn, selectedHex);
+ int assists = map.buildMoveAssists(selectedPawn, selectedHex);
+ showPossibleTargetsMovesAssists(selectedPawn);
ctrl.hud.show(
- pawn.canMove(),
- (pawn.canMove() && (moves > 0)),
- (pawn.canAttack() && (targets > 0)),
+ selectedPawn.canMove(),
+ (selectedPawn.canMove() && (moves > 0)),
+ (selectedPawn.canAttack() && (targets > 0)),
false,
false
);