summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateAttack.java24
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateCommon.java26
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateMove.java32
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StatePromote.java6
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateRotate.java10
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateSelect.java24
6 files changed, 61 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 e3b1cf9..359e9dd 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java
@@ -1,7 +1,7 @@
package ch.asynk.tankontank.game.states;
-import ch.asynk.tankontank.engine.Pawn;
import ch.asynk.tankontank.game.Hex;
+import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.State.StateType;
public class StateAttack extends StateCommon
@@ -14,11 +14,11 @@ public class StateAttack extends StateCommon
ctrl.hud.attackBtn.setOn();
if (fromSelect) {
- activePawn = null;
- // use selectedHex and selectedPawn
+ activeUnit = null;
+ // use selectedHex and selectedUnit
from = selectedHex;
map.possibleTargets.hide();
- map.buildPossibleTargets(selectedPawn, ctrl.opponent.unitIterator());
+ map.buildPossibleTargets(selectedUnit, ctrl.opponent.unitIterator());
map.possibleTargets.show();
if (to != null) {
// quick fire -> replay touchUp
@@ -48,19 +48,19 @@ public class StateAttack extends StateCommon
@Override
public void touchUp()
{
- // activePawn is the target
- if ((activePawn == null) && map.possibleTargets.contains(upHex)) {
+ // activeUnit is the target
+ if ((activeUnit == null) && map.possibleTargets.contains(upHex)) {
map.possibleTargets.hide();
to = upHex;
- activePawn = to.getTopPawn();
+ activeUnit = to.getUnit();
map.showTarget(to, true);
- map.buildAttackAssists(selectedPawn, activePawn, ctrl.player.unitIterator());
+ map.buildAttackAssists(selectedUnit, activeUnit, ctrl.player.unitIterator());
map.attackAssists.show();
ctrl.hud.show(false, false, false, true, true, ctrl.cfg.canCancel);
}
- if ((activePawn != null) && map.attackAssists.contains(upHex)) {
- if (map.toggleAttackAssist(upHex.getTopPawn())) {
+ if ((activeUnit != null) && map.attackAssists.contains(upHex)) {
+ if (map.toggleAttackAssist(upHex.getUnit())) {
map.showAssist(upHex, false);
map.showTarget(upHex, true);
} else {
@@ -83,8 +83,8 @@ public class StateAttack extends StateCommon
int d1 = ctrl.player.d6();
int d2 = ctrl.player.d6();
System.err.print(" attack (" + from.getCol() + ";" + from.getRow() + ") -> (" + to.getCol() + ";" + to.getRow() + ") : 2D6 -> (" + d1 + " + " + d2 + ")");
- if (map.attackPawn(selectedPawn, activePawn, d1 + d2))
- ctrl.player.casualty(activePawn);
+ if (map.attackPawn(selectedUnit, activeUnit, d1 + d2))
+ ctrl.player.casualty(activeUnit);
map.showTarget(to, false);
ctrl.setState(StateType.ANIMATION);
diff --git a/core/src/ch/asynk/tankontank/game/states/StateCommon.java b/core/src/ch/asynk/tankontank/game/states/StateCommon.java
index 03a4ede..0ff9ba1 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateCommon.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateCommon.java
@@ -1,8 +1,8 @@
package ch.asynk.tankontank.game.states;
-import ch.asynk.tankontank.engine.Pawn;
import ch.asynk.tankontank.game.Map;
import ch.asynk.tankontank.game.Hex;
+import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Ctrl;
import ch.asynk.tankontank.game.State;
import ch.asynk.tankontank.game.State.StateType;
@@ -19,8 +19,8 @@ public abstract class StateCommon implements State
protected static Hex to = null;
protected boolean isEnemy;
- protected static Pawn activePawn;
- protected static Pawn selectedPawn;
+ protected static Unit activeUnit;
+ protected static Unit selectedUnit;
protected static StateType nextState = StateType.SELECT;
@@ -63,8 +63,8 @@ public abstract class StateCommon implements State
from = null;
to = null;
selectedHex = null;
- selectedPawn = null;
- activePawn = null;
+ selectedUnit = null;
+ activeUnit = null;
}
private void goToNextState()
@@ -91,24 +91,24 @@ public abstract class StateCommon implements State
return !upHex.isOffMap();
}
- protected boolean hasPawn()
+ protected boolean hasUnit()
{
- return (selectedPawn != null);
+ return (selectedUnit != null);
}
- protected void selectHexAndPawn(Hex hex)
+ protected void selectHexAndUnit(Hex hex)
{
selectedHex = hex;
- selectedPawn = selectedHex.getTopPawn();
+ selectedUnit = selectedHex.getUnit();
map.selectHex(selectedHex, true);
- if (selectedPawn != null)
- isEnemy = ctrl.player.isEnemy(selectedPawn);
+ if (selectedUnit != null)
+ isEnemy = ctrl.player.isEnemy(selectedUnit);
else
isEnemy = false;
- System.err.println(" select " + selectedHex + selectedPawn + (isEnemy ? " enemy " : " friend "));
+ System.err.println(" select " + selectedHex + selectedUnit + (isEnemy ? " enemy " : " friend "));
}
- protected void showPossibleTargetsMovesAssists(Pawn pawn)
+ protected void showPossibleTargetsMovesAssists(Unit pawn)
{
if (ctrl.cfg.showMoves && pawn.canMove()) map.possibleMoves.show();
if (ctrl.cfg.showTargets && pawn.canAttack()) map.possibleTargets.show();
diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java
index eb462db..73d5606 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateMove.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java
@@ -13,24 +13,24 @@ public class StateMove extends StateCommon
ctrl.hud.moveBtn.setOn();
if (fromSelect) {
- // use selectedHex and selectedPawn
+ // use selectedHex and selectedUnit
from = selectedHex;
- activePawn = selectedPawn;
- map.buildAndShowMovesAndAssits(activePawn);
+ activeUnit = selectedUnit;
+ map.buildAndShowMovesAndAssits(activeUnit);
if (to != null) {
// quick move -> replay touchUp
upHex = to;
touchUp();
}
} else {
- // back from rotation -> use the above and unmodified activePawn
- if ((activePawn == selectedPawn) || !selectedPawn.canMove()) {
+ // back from rotation -> use the above and unmodified activeUnit
+ if ((activeUnit == selectedUnit) || !selectedUnit.canMove()) {
upHex = (Hex) map.moveAssists.first();
- activePawn = upHex.getTopPawn();
+ activeUnit = upHex.getUnit();
} else {
upHex = selectedHex;
}
- changePawn(upHex);
+ changeUnit(upHex);
}
}
@@ -61,9 +61,9 @@ public class StateMove extends StateCommon
{
int s = map.possiblePaths.size();
- if (map.moveAssists.contains(upHex) || (selectedPawn.canMove() && (selectedHex == upHex))) {
+ if (map.moveAssists.contains(upHex) || (selectedUnit.canMove() && (selectedHex == upHex))) {
if(upHex != from)
- changePawn(upHex);
+ changeUnit(upHex);
} else if ((s == 0) && map.possibleMoves.contains(upHex)) {
s = buildPaths();
} else if (map.possiblePaths.contains(upHex)) {
@@ -71,7 +71,7 @@ public class StateMove extends StateCommon
}
if (s == 1) {
- // prevent changePawn
+ // prevent changeUnit
if (from == selectedHex)
selectedHex = to;
ctrl.setState(StateType.ROTATE, false);
@@ -91,8 +91,8 @@ public class StateMove extends StateCommon
public void done()
{
hideAssists();
- if (selectedPawn.canMove() && (map.activatedPawns.size() > 0))
- selectedPawn.move(0);
+ if (selectedUnit.canMove() && (map.activatedPawns.size() > 0))
+ selectedUnit.move(0);
super.done();
}
@@ -102,7 +102,7 @@ public class StateMove extends StateCommon
map.moveAssists.hide();
}
- private void changePawn(Hex next)
+ private void changeUnit(Hex next)
{
if (from != null) {
// toggle selected to assist
@@ -110,18 +110,18 @@ public class StateMove extends StateCommon
map.showAssist(from, true);
}
from = next;
- activePawn = from.getTopPawn();
+ activeUnit = from.getUnit();
map.selectHex(from, true);
map.showAssist(from, false);
map.possibleMoves.hide();
- map.buildPossibleMoves(activePawn);
+ map.buildPossibleMoves(activeUnit);
map.possibleMoves.show();
}
private int buildPaths()
{
to = upHex;
- int s = map.buildPossiblePaths(activePawn, to);
+ int s = map.buildPossiblePaths(activeUnit, to);
map.selectHex(to, true);
map.possibleMoves.hide();
map.showPossiblePaths(true, true);
diff --git a/core/src/ch/asynk/tankontank/game/states/StatePromote.java b/core/src/ch/asynk/tankontank/game/states/StatePromote.java
index f998fba..fc4b852 100644
--- a/core/src/ch/asynk/tankontank/game/states/StatePromote.java
+++ b/core/src/ch/asynk/tankontank/game/states/StatePromote.java
@@ -1,6 +1,6 @@
package ch.asynk.tankontank.game.states;
-import ch.asynk.tankontank.engine.Pawn;
+import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.State.StateType;
public class StatePromote extends StateCommon
@@ -9,9 +9,9 @@ public class StatePromote extends StateCommon
public void enter(boolean flag)
{
ctrl.hud.hide();
- Pawn p = ctrl.player.promote(selectedPawn);
+ Unit p = ctrl.player.promote(selectedUnit);
if (p != null) {
- map.promote(selectedPawn, p);
+ map.promote(selectedUnit, p);
}
done();
}
diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
index 86858a7..610ba08 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
@@ -21,7 +21,7 @@ public class StateRotate extends StateCommon
if (from == null) {
// rotateBtn from Select state
from = selectedHex;
- activePawn = selectedPawn;
+ activeUnit = selectedUnit;
}
to = from;
} else {
@@ -86,8 +86,8 @@ public class StateRotate extends StateCommon
public void done()
{
doRotation(o);
- if (selectedPawn.canMove() && (map.activatedPawns.size() > 0))
- selectedPawn.move(0);
+ if (selectedUnit.canMove() && (map.activatedPawns.size() > 0))
+ selectedUnit.move(0);
super.done();
}
@@ -103,12 +103,12 @@ public class StateRotate extends StateCommon
if (rotateOnly) {
ctrl.setAnimationCount(1);
- if (map.rotatePawn(activePawn, o) > 0)
+ if (map.rotatePawn(activeUnit, o) > 0)
setNextState(StateType.MOVE);
ctrl.setState(StateType.ANIMATION);
} else {
ctrl.setAnimationCount(1);
- if (map.movePawn(activePawn, o) > 0)
+ if (map.movePawn(activeUnit, o) > 0)
setNextState(StateType.MOVE);
ctrl.setState(StateType.ANIMATION);
}
diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
index 0829d73..500f90d 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
@@ -48,23 +48,23 @@ public class StateSelect extends StateCommon
}
}
- selectHexAndPawn(upHex);
+ selectHexAndUnit(upHex);
hidePossibleTargetsMovesAssists();
- if (hasPawn() && (!isEnemy || ctrl.cfg.showEnemyPossibilities)) {
- int moves = map.buildPossibleMoves(selectedPawn);
+ if (hasUnit() && (!isEnemy || ctrl.cfg.showEnemyPossibilities)) {
+ int moves = map.buildPossibleMoves(selectedUnit);
int targets = 0;
if (isEnemy)
- targets = map.buildPossibleTargets(selectedPawn, ctrl.player.unitIterator());
+ targets = map.buildPossibleTargets(selectedUnit, ctrl.player.unitIterator());
else
- targets = map.buildPossibleTargets(selectedPawn, ctrl.opponent.unitIterator());
- int assists = map.buildMoveAssists(selectedPawn);
- showPossibleTargetsMovesAssists(selectedPawn);
+ targets = map.buildPossibleTargets(selectedUnit, ctrl.opponent.unitIterator());
+ int assists = map.buildMoveAssists(selectedUnit);
+ showPossibleTargetsMovesAssists(selectedUnit);
ctrl.hud.show(
- ctrl.player.canPromote(selectedPawn),
- selectedPawn.canMove(),
- (selectedPawn.canMove() && (moves > 0)),
- (selectedPawn.canAttack() && (targets > 0)),
+ ctrl.player.canPromote(selectedUnit),
+ selectedUnit.canMove(),
+ (selectedUnit.canMove() && (moves > 0)),
+ (selectedUnit.canAttack() && (targets > 0)),
false,
false
);
@@ -72,7 +72,7 @@ public class StateSelect extends StateCommon
ctrl.hud.hide();
map.clearAll();
}
- if (selectedPawn != null) ctrl.hud.notify(selectedPawn.toString());
+ if (selectedUnit != null) ctrl.hud.notify(selectedUnit.toString());
}
@Override