summaryrefslogtreecommitdiffstats
path: root/test/src/ch/asynk/gdx/boardgame
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/ch/asynk/gdx/boardgame')
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java14
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/HexScreen.java11
2 files changed, 14 insertions, 11 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
index d20e52a..de70ce4 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
@@ -73,10 +73,10 @@ public class BoardScreen extends AbstractScreen
public boolean touch(float x, float y, boolean down)
{
board.toBoard(x, y, v);
- if (!board.isOnMap((int)v.x, (int)v.y))
+ Tile tile = board.getTile((int)v.x, (int)v.y);
+ if (!tile.isOnMap())
return false;
if (down) {
- Tile tile = getTile((int)v.x, (int)v.y);
if (!dragging && panzer.isOn(tile)) {
dragging = true;
clearAdjacents();
@@ -122,7 +122,7 @@ public class BoardScreen extends AbstractScreen
private void clearAdjacents()
{
for (Tile tile : board.getAdjacents()) {
- if (tile != null) {
+ if (tile.isOnMap()) {
tilesToDraw.remove(tile);
tile.enableOverlay(12, false);
}
@@ -134,16 +134,18 @@ public class BoardScreen extends AbstractScreen
clearAdjacents();
board.buildAdjacents((int)v.x, (int)v.y);
for (Tile tile : board.getAdjacents()) {
- if (tile != null) {
+ if (tile.isOnMap()) {
tilesToDraw.add(tile);
tile.enableOverlay(12, true);
}
}
}
- private Tile getTile(int x, int y)
+ private Tile getTile(int x, int y, boolean isOnMap)
{
- return tileStorage.getTile(x, y, board::genKey, this::buildTile);
+ if (isOnMap)
+ return tileStorage.getTile(x, y, board::genKey, this::buildTile);
+ return Tile.OffMap;
}
private Tile buildTile(int x, int y)
diff --git a/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java b/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java
index 2335d4e..ceb601f 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java
@@ -149,10 +149,9 @@ public class HexScreen extends AbstractScreen
public boolean touch(float x, float y, boolean down)
{
board.toBoard(x, y, v);
- if (!board.isOnMap((int)v.x, (int)v.y)) {
- return false;
- }
Hex hex = getHex((int)v.x, (int)v.y);
+ if (!hex.isOnMap())
+ return false;
if (down) {
if (!panzer.dragging && panzer.isOn(hex)) {
panzer.dragging = true;
@@ -223,9 +222,11 @@ public class HexScreen extends AbstractScreen
return (Hex) board.getTile(x, y);
}
- private Tile getTile(int x, int y)
+ private Tile getTile(int x, int y, boolean isOnMap)
{
- return tileStorage.getTile(x, y, board::genKey, this::buildTile);
+ if (isOnMap)
+ return tileStorage.getTile(x, y, board::genKey, this::buildTile);
+ return Tile.OffMap;
}
private Tile buildTile(int x, int y)