From dacf116e1bbeb1bec86993cd145f8f9a201e9551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 7 Jul 2020 14:10:47 +0200 Subject: HexBoard : distance cleanup --- core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java index 18aba17..21277d8 100644 --- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java +++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java @@ -254,14 +254,11 @@ public class HexBoard implements Board if (dx > dy) { if (dx > dz) return dx; - else - return dz; } else { if (dy > dz) return dy; - else - return dz; } + return dz; } } @@ -314,7 +311,7 @@ public class HexBoard implements Board Tile from = getTile(x0, y0); Tile to = getTile(x1, y1); - float d = distance(x0, y0, x1, y1); + float d = distance(x0, y0, x1, y1, Board.Geometry.EUCLIDEAN); tiles.add(from); from.blocked = false; boolean contact = false; @@ -355,7 +352,7 @@ public class HexBoard implements Board } tiles.add(t); t.blocked = losBlocked; - losBlocked = (losBlocked || t.blockLos(from, to, d, distance(x0, y0, x, y))); + losBlocked = (losBlocked || t.blockLos(from, to, d, distance(x0, y0, x, y, Board.Geometry.EUCLIDEAN))); } return tiles.get(tiles.size() - 1).blocked; @@ -371,7 +368,7 @@ public class HexBoard implements Board Tile from = getTile(x0, y0); Tile to = getTile(x1, y1); - float d = distance(x0, y0, x1, y1); + float d = distance(x0, y0, x1, y1, Board.Geometry.EUCLIDEAN); tiles.add(from); from.blocked = false; int blocked = 0; @@ -387,7 +384,7 @@ public class HexBoard implements Board if (t.isOnBoard()) { tiles.add(t); t.blocked = losBlocked; - if (t.blockLos(from, to, d, distance(x0, y0, x, y))) + if (t.blockLos(from, to, d, distance(x0, y0, x, y, Board.Geometry.EUCLIDEAN))) blocked |= 0x01; } @@ -401,7 +398,7 @@ public class HexBoard implements Board if (t.isOnBoard()) { tiles.add(t); t.blocked = losBlocked; - if (t.blockLos(from, to, d, distance(x0, y0, x, y))) + if (t.blockLos(from, to, d, distance(x0, y0, x, y, Board.Geometry.EUCLIDEAN))) blocked |= 0x02; } @@ -421,7 +418,7 @@ public class HexBoard implements Board computeContact(from, to, o.opposite(), tiles.get(tiles.size() - 4), v, false); contact = true; } - losBlocked = (t.blocked || t.blockLos(from, to, d, distance(x0, y0, x, y))); + losBlocked = (t.blocked || t.blockLos(from, to, d, distance(x0, y0, x, y, Board.Geometry.EUCLIDEAN))); } } -- cgit v1.1-2-g2b99