diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-06-04 23:18:15 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-06-04 23:18:15 +0200 |
commit | e553e2a22eac25bc7f3c0f61a8db3377be66e8e8 (patch) | |
tree | be4c907f1c4e668c3c06d65dc588822814911a8e /test/src/ch/asynk | |
parent | f7167d18cadb0cbe7798f524d5dd348d86bc5ec5 (diff) | |
download | gdx-boardgame-e553e2a22eac25bc7f3c0f61a8db3377be66e8e8.zip gdx-boardgame-e553e2a22eac25bc7f3c0f61a8db3377be66e8e8.tar.gz |
HexScreen : drop units where mouse pointer is
Diffstat (limited to 'test/src/ch/asynk')
-rw-r--r-- | test/src/ch/asynk/gdx/boardgame/test/HexScreen.java | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java b/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java index b6c7f28..67fa80e 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java @@ -168,13 +168,13 @@ public class HexScreen extends AbstractScreen public void reset() { + board.centerOf(0, 0, v); tilesToDraw.clear(); v.set(0, 0); h0 = getHex(0, 0); - setUnitOn(panzer, 0, 0, Orientation.DEFAULT); + setUnitOn(panzer, h0.x, h0.y, Orientation.DEFAULT); h1 = getHex(8, 5); - setUnitOn(engineer, 8, 5, Orientation.SW); - board.centerOf(0, 0, v); + setUnitOn(engineer, h1.x, h1.y, Orientation.SW); updateLine(); } @@ -201,17 +201,9 @@ public class HexScreen extends AbstractScreen } } else { if (panzer.dragging) { - touchInfo(hex); - board.dropInPlace(panzer, v); - panzer.dragging = false; - h0 = hex; - updateLine(); + updateUnit(hex, panzer); } else if (engineer.dragging) { - touchInfo(hex); - engineer.dropOnBoard(board, v); - engineer.dragging = false; - h1 = hex; - updateLine(); + updateUnit(hex, engineer); } } return true; @@ -222,6 +214,18 @@ public class HexScreen extends AbstractScreen GdxBoardTest.debug("BoardScreen", String.format("touchDown [%d;%d] => %s[%d]", (int)v.x, (int)v.y, hex, board.genKey((int)v.x, (int)v.y))); } + private void updateUnit(Hex hex, Unit u) + { + touchInfo(hex); + u.centerOn(hex.cx, hex.cy); + u.dragging = false; + if (u == panzer) + h0 = hex; + else + h1 = hex; + updateLine(); + } + private void updateLine() { float x0 = panzer.getCX(); @@ -237,7 +241,7 @@ public class HexScreen extends AbstractScreen tile.enableOverlay(0, false); tile.enableOverlay(2, false); } - board.lineOfSight(h0.x, h0.y, h1.x, h1.y, tilesToDraw); + board.lineOfSight(h0, h1, tilesToDraw); for (Tile tile: tilesToDraw) { if (tile.blocked) tile.enableOverlay(0, Orientation.N); else tile.enableOverlay(2, Orientation.N); |