diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-05 12:54:43 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-05 12:54:43 +0200 |
commit | 289d5150711e8b89be5caedeacb779ef277301c3 (patch) | |
tree | 9e0ccb4cee46a03e89492c4331b6877651680d02 /core/src/ch/asynk | |
parent | 7ca4aa7b91179c635195ec0e3d749ced31e206be (diff) | |
download | RustAndDust-289d5150711e8b89be5caedeacb779ef277301c3.zip RustAndDust-289d5150711e8b89be5caedeacb779ef277301c3.tar.gz |
Board,Map: dispose clears all paths, and sets
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 17 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 16 |
2 files changed, 23 insertions, 10 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 9a0ac32..0a8a47b 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -241,7 +241,7 @@ public abstract class Board implements Disposable debugShapes.setTransformMatrix(prevTransform); } - public void clearNodesVector(Vector<GridPoint2> points) + public void clearPointVector(Vector<GridPoint2> points) { for (GridPoint2 point : points) gridPoint2Pool.free(point); @@ -294,7 +294,7 @@ public abstract class Board implements Disposable nodesToPoints(nodes, targets); } - public void clearNodesSet(Set<GridPoint2> points) + public void clearPointSet(Set<GridPoint2> points) { for (GridPoint2 point : points) gridPoint2Pool.free(point); @@ -331,13 +331,18 @@ public abstract class Board implements Disposable return nodesToSet(paths, points); } - public int getFinalPath(Pawn pawn, Vector<Vector3> path, Orientation finalOrientation) + public void clearCoordinateVector(Vector<Vector3> points) + { + for (Vector3 point : points) + vector3Pool.free(point); + points.clear(); + } + + public int getCoordinatePath(Pawn pawn, Vector<Vector3> path, Orientation finalOrientation) { List<Vector<SearchBoard.Node>> paths = searchBoard.possiblePaths(); - for (Vector3 v : path) - vector3Pool.free(v); - path.clear(); + clearCoordinateVector(path); if (paths.size() != 1) return 0; diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index eaa83df..0627e47 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -29,6 +29,14 @@ public abstract class Map extends Board setup(); } + @Override + public void dispose() + { + super.dispose(); + resetPaths(); + clearCoordinateVector(finalPath); + } + protected Hex getHex(int col, int row) { return (Hex) getTile(col, row); @@ -104,7 +112,7 @@ public abstract class Map extends Board public void movePawn(Pawn pawn, Orientation o) { - int s = getFinalPath(pawn, finalPath, o); + int s = getCoordinatePath(pawn, finalPath, o); if (s > 0) { movePawn(pawn, finalPath); } @@ -119,9 +127,9 @@ public abstract class Map extends Board public void resetPaths() { - clearNodesSet(possiblePaths); - clearNodesVector(possibleMoves); - clearNodesVector(possibleTargets); + clearPointSet(possiblePaths); + clearPointVector(possibleMoves); + clearPointVector(possibleTargets); } public void toggleDotOverlay(GridPoint2 hex) |