summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java21
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java5
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateAttack.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateSelect.java2
4 files changed, 26 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index 8ad214b..91a88f5 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -329,6 +329,27 @@ public abstract class Board implements Disposable
return targets.size();
}
+ protected int buildPossibleTargetsFrom(Pawn pawn, GridPoint2 coords, Iterator<Pawn> units, ArrayList<GridPoint2> targets)
+ {
+ clearPointVector(targets);
+
+ GridPoint2 to = gridPoint2Pool.obtain();
+ while (units.hasNext()) {
+ Pawn target = units.next();
+ getHexUnder(target, to);
+ if (searchBoard.buildAttack(pawn, target, coords.x, coords.y, to.x, to.y)) {
+ targets.add(to);
+ to = gridPoint2Pool.obtain();
+ }
+ }
+
+ int s = targets.size();
+ if ((s > 0) && (to != targets.get(s - 1)))
+ gridPoint2Pool.free(to);
+
+ return s;
+ }
+
protected int buildMoveAssists(Pawn pawn, GridPoint2 coords, List<GridPoint2> assists)
{
assists.clear();
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index d1dfcb4..fdf7e8b 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -208,9 +208,10 @@ public abstract class Map extends Board
return buildPossibleMovesFrom(pawn, hex, possibleMoves);
}
- public int buildPossibleTargets(Pawn pawn, GridPoint2 hex)
+ public int buildPossibleTargets(Pawn pawn, GridPoint2 hex, Iterator<Pawn> foes)
{
- return buildPossibleTargetsFrom(pawn, hex, possibleTargets);
+ // return buildPossibleTargetsFrom(pawn, hex, possibleTargets);
+ return buildPossibleTargetsFrom(pawn, hex, foes, possibleTargets);
}
public int buildMoveAssists(Pawn pawn, GridPoint2 hex)
diff --git a/core/src/ch/asynk/tankontank/game/states/StateAttack.java b/core/src/ch/asynk/tankontank/game/states/StateAttack.java
index 7c4d6b2..bbf54d1 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java
@@ -19,7 +19,7 @@ public class StateAttack extends StateCommon
// use selectedHex and selectedPawn
from.set(selectedHex);
map.showPossibleTargets(false);
- map.buildPossibleTargets(selectedPawn, from);
+ map.buildPossibleTargets(selectedPawn, from, ctrl.otherPlayer().unitIterator());
map.showPossibleTargets(true);
if (to.x != -1) {
// quick fire -> replay touchUp
diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
index 0ae3465..5dc5e68 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
@@ -53,7 +53,7 @@ public class StateSelect extends StateCommon
if (hasPawn() && (!isEnemy || ctrl.cfg.showEnemyPossibilities)) {
int moves = map.buildPossibleMoves(selectedPawn, selectedHex);
- int targets = map.buildPossibleTargets(selectedPawn, selectedHex);
+ int targets = map.buildPossibleTargets(selectedPawn, selectedHex, ctrl.otherPlayer().unitIterator());
int assists = map.buildMoveAssists(selectedPawn, selectedHex);
showPossibleTargetsMovesAssists(selectedPawn);
ctrl.hud.show(