From a69bb5652bb5228cb3718f2c4503e3490c1072fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 3 Oct 2014 10:10:48 +0200 Subject: Board: use Orientation.fromMove(...) --- core/src/ch/asynk/tankontank/engine/Board.java | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 01839e9..9f85fab 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -320,24 +320,6 @@ public abstract class Board implements Disposable return nodesToSet(paths, points); } - private Orientation getOrientation(SearchBoard.Node from, SearchBoard.Node to) - { - int dx = to.col - from .col; - int dy = to.row - from.row; - - if (dy == 0) { - if (dx > 0) return Orientation.NORTH; - return Orientation.SOUTH; - } - if (dy > 0) { - if (dx > 0) return Orientation.NORTH_WEST; - return Orientation.SOUTH_WEST; - } else { - if (dx > 0) return Orientation.NORTH_EAST; - return Orientation.SOUTH_EAST; - } - } - public int getFinalPath(Vector path) { List> paths = searchBoard.possiblePaths(); @@ -354,7 +336,8 @@ public abstract class Board implements Disposable for (int i = (nodes.size() - 2); i >= 0; i--) { SearchBoard.Node node = nodes.get(i); GridPoint3 point = gridPoint3Pool.obtain(); - point.set(node.col, node.row, (int) getOrientation(prev, node).r()); + Orientation o = Orientation.fromMove(prev.col, prev.row, node.col, node.row); + point.set(node.col, node.row, (int) o.r()); path.add(point); prev = node; } -- cgit v1.1-2-g2b99