diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-28 11:35:57 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-28 11:35:57 +0100 |
commit | dad7249b074500d717941e9daf0d52f60ac5395f (patch) | |
tree | d6404a447483919f70dddcc24fa3ec30277babef | |
parent | 91a42e7e08b8aba942d6c306dbabd6db9543e83f (diff) | |
download | RustAndDust-dad7249b074500d717941e9daf0d52f60ac5395f.zip RustAndDust-dad7249b074500d717941e9daf0d52f60ac5395f.tar.gz |
TileList: extends ArrayList<Tile>, has a default overlay index, has methods hide()/show()
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/TileList.java | 47 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/HexList.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 10 |
3 files changed, 21 insertions, 40 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/TileList.java b/core/src/ch/asynk/tankontank/engine/TileList.java index d8b4e7f..4f27057 100644 --- a/core/src/ch/asynk/tankontank/engine/TileList.java +++ b/core/src/ch/asynk/tankontank/engine/TileList.java @@ -3,68 +3,49 @@ package ch.asynk.tankontank.engine; import java.util.List; import java.util.ArrayList; -public class TileList +public class TileList extends ArrayList<Tile> { private final Board board; - private final List<Tile> tiles; + private int overlay; - public TileList(Board board, int n) + public TileList(Board board, int overlay, int n) { + super(n); this.board = board; - this.tiles = new ArrayList<Tile>(n); + this.overlay = overlay; } public int fromNodes(List<SearchBoard.Node> nodes) { - tiles.clear(); + clear(); for (SearchBoard.Node node : nodes) { Tile tile = board.getTile(node.col, node.row); - tiles.add(tile); + add(tile); } - return tiles.size(); + return size(); } - public int size() + public void show() { - return tiles.size(); + enable(overlay, true); } - public void clear() + public void hide() { - tiles.clear(); - } - - public Tile get(int i) - { - return tiles.get(i); - } - - public void add(Tile tile) - { - tiles.add(tile); - } - - public boolean remove(Tile tile) - { - return tiles.remove(tile); - } - - public boolean contains(Tile tile) - { - return tiles.contains(tile); + enable(overlay, false); } public void enable(int i, boolean enable) { - for (Tile tile : tiles) + for (Tile tile : this) board.enableOverlayOn(tile, i, enable); } public void getPawns(List<Pawn> pawns) { pawns.clear(); - for (Tile tile : tiles) + for (Tile tile : this) pawns.add(tile.getTopPawn()); } } diff --git a/core/src/ch/asynk/tankontank/game/HexList.java b/core/src/ch/asynk/tankontank/game/HexList.java index 0be4a7d..9ed95fe 100644 --- a/core/src/ch/asynk/tankontank/game/HexList.java +++ b/core/src/ch/asynk/tankontank/game/HexList.java @@ -4,8 +4,8 @@ import ch.asynk.tankontank.engine.TileList; public class HexList extends TileList { - public HexList(Map map, int n) + public HexList(Map map, int overlay, int n) { - super(map, n); + super(map, overlay, n); } } diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index 8ff031a..4d66c1b 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -41,11 +41,11 @@ public abstract class Map extends Board this.explosion = new SpriteAnimation(game.manager.get("data/explosion.png", Texture.class), 10, 4, 40); this.explosions = new SpriteAnimation(game.manager.get("data/explosions.png", Texture.class), 16, 8, 15); setup(); - possibleMoves = new HexList(this, 40); - possiblePaths = new HexList(this, 10); - possibleTargets = new HexList(this, 10); - moveAssists = new HexList(this, 6); - attackAssists = new HexList(this, 6); + possibleMoves = new HexList(this, Hex.MOVE1, 40); + possiblePaths = new HexList(this, Hex.MOVE1, 10); // Hex.MOVE2 + possibleTargets = new HexList(this, Hex.TARGET, 10); + moveAssists = new HexList(this, Hex.ASSIST, 6); + attackAssists = new HexList(this, Hex.ASSIST, 6); } @Override |