summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-08 11:18:02 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-08 11:18:02 +0200
commit88af47e269674b53a54a25313639ed76b57896e6 (patch)
tree3932223e2ac7a5705f3813e886b8977079a2a884 /core/src/ch/asynk/tankontank
parent7c62dcba243717da017db7b3558263536cf2d4be (diff)
downloadRustAndDust-88af47e269674b53a54a25313639ed76b57896e6.zip
RustAndDust-88af47e269674b53a54a25313639ed76b57896e6.tar.gz
Map: improve possible API
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java80
1 files changed, 40 insertions, 40 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 1e0a654..8048576 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -38,7 +38,10 @@ public abstract class Map extends Board
public void dispose()
{
super.dispose();
- clearPossibles();
+ moveAssists.clear();
+ clearPointSet(possiblePaths);
+ clearPointVector(possibleMoves);
+ clearPointVector(possibleTargets);
clearCoordinateVector(finalPath);
}
@@ -85,9 +88,9 @@ public abstract class Map extends Board
enableOverlayOn(hex, Hex.TARGET, enable);
}
- public void enablePossiblePaths(boolean enable, boolean keepMoves)
+ public void enablePossiblePaths(boolean enable, boolean keepFinal)
{
- if (keepMoves) {
+ if (keepFinal) {
for(GridPoint2 hex : possiblePaths)
enableOverlayOn(hex, Hex.MOVE1, enable);
} else {
@@ -98,22 +101,26 @@ public abstract class Map extends Board
}
}
- public void buildPossibleMoves(Pawn pawn, GridPoint2 hex)
+ public int buildPossibleMoves(Pawn pawn, GridPoint2 hex)
{
buildPossibleMovesFrom(pawn, hex, possibleMoves);
+ return possibleMoves.size();
}
- public void buildPossibleTargets(Pawn pawn, GridPoint2 hex)
+ public int buildPossibleTargets(Pawn pawn, GridPoint2 hex)
{
buildPossibleTargetsFrom(pawn, hex, possibleTargets);
+ return possibleTargets.size();
}
- public void buildMoveAssists(Pawn pawn, GridPoint2 hex)
+ public int buildMoveAssists(Pawn pawn, GridPoint2 hex)
{
if (pawn.isHq()) {
buildMoveAssists(pawn, hex, moveAssists);
- } else
+ } else {
moveAssists.clear();
+ }
+ return moveAssists.size();
}
public int possiblePathsSize()
@@ -131,48 +138,18 @@ public abstract class Map extends Board
return possiblePathsFilterToggle(hex, possiblePaths);
}
- public void movePawn(Pawn pawn, Orientation o)
- {
- int s = getCoordinatePath(pawn, finalPath, o);
- if (s > 0) {
- movePawn(pawn, finalPath, RunnableAnimation.get(pawn, new Runnable() {
- @Override
- public void run() {
- ctrl.animationDone();
- }
- }));
- }
- }
-
- public void rotatePawn(Pawn pawn, Orientation o)
- {
- rotatePawn(pawn, o, RunnableAnimation.get(pawn, new Runnable() {
- @Override
- public void run() {
- ctrl.animationDone();
- }
- }));
- }
-
- public void hidePossibles()
+ public void clearPossiblePaths()
{
- enablePossibleTargets(false);
- enablePossibleMoves(false);
- enablePossiblePaths(false, false);
+ clearPointSet(possiblePaths);
}
- public void clearPossibles()
+ public void clearPossibleTargetsMovesAssists()
{
clearPointSet(possiblePaths);
clearPointVector(possibleMoves);
clearPointVector(possibleTargets);
}
- public void clearPossiblePaths()
- {
- clearPointSet(possiblePaths);
- }
-
public void togglePathOverlay(GridPoint2 hex)
{
boolean enable= !isOverlayEnabledOn(hex, Hex.MOVE2);
@@ -188,6 +165,29 @@ public abstract class Map extends Board
enableDirections(dst, enable);
}
+ public void movePawn(Pawn pawn, Orientation o)
+ {
+ int s = getCoordinatePath(pawn, finalPath, o);
+ if (s > 0) {
+ movePawn(pawn, finalPath, RunnableAnimation.get(pawn, new Runnable() {
+ @Override
+ public void run() {
+ ctrl.animationDone();
+ }
+ }));
+ }
+ }
+
+ public void rotatePawn(Pawn pawn, Orientation o)
+ {
+ rotatePawn(pawn, o, RunnableAnimation.get(pawn, new Runnable() {
+ @Override
+ public void run() {
+ ctrl.animationDone();
+ }
+ }));
+ }
+
public void enableDirections(GridPoint2 hex, boolean enable)
{
enableOverlayOn(hex, Hex.DIRECTIONS, enable);