summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-03 11:45:40 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-03 11:45:40 +0200
commitc4fd1a79b9cc2a27448c7631cbd46f701115c8e5 (patch)
tree4c955eb6daf9e630786abb53403ddf555ced7a77
parent59d71e6080a82aeeba1f07f86fd4d3f42dfa8e9d (diff)
downloadRustAndDust-c4fd1a79b9cc2a27448c7631cbd46f701115c8e5.zip
RustAndDust-c4fd1a79b9cc2a27448c7631cbd46f701115c8e5.tar.gz
Map: add movePawn(Pawn pawn, Orientation o)
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 2c2e775..d8458f1 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -6,14 +6,17 @@ import java.util.HashSet;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
-import ch.asynk.tankontank.engine.Board;
import ch.asynk.tankontank.engine.Pawn;
+import ch.asynk.tankontank.engine.Board;
+import ch.asynk.tankontank.engine.Orientation;
public abstract class Map extends Board
{
+ private final Vector<Vector3> finalPath = new Vector<Vector3>(10);
private final Vector<GridPoint2> possibleMoves = new Vector<GridPoint2>(20);
private final Vector<GridPoint2> possibleTargets = new Vector<GridPoint2>(10);
private final HashSet<GridPoint2> possiblePaths = new HashSet<GridPoint2>(10);
@@ -99,6 +102,14 @@ public abstract class Map extends Board
return possiblePathsFilterToggle(hex, possiblePaths);
}
+ public void movePawn(Pawn pawn, Orientation o)
+ {
+ int s = getFinalPath(pawn, finalPath, o);
+ if (s > 0) {
+ movePawn(pawn, finalPath);
+ }
+ }
+
public void clearPossibles()
{
enablePossibleMoves(false);