From d5d77c2e64d70c3b6e6228d9b4079e258ad29ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 7 Oct 2014 16:35:44 +0200 Subject: Board: add GridPoint2 setNeighbour(GridPoint2, Orientation, GridPoint2); --- core/src/ch/asynk/tankontank/engine/Board.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 0ef2a6e..b74dc87 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -151,6 +151,19 @@ public abstract class Board implements Disposable tiles[5] = getTileSafe((hex.x - 1), (hex.y - 1)); } + public GridPoint2 setNeighbour(GridPoint2 hex, Orientation o, GridPoint2 n) + { + if (o == Orientation.NORTH) n.set((hex.x + 1), hex.y); + else if (o == Orientation.NORTH_EAST) n.set(hex.x, (hex.y - 1)); + else if (o == Orientation.SOUTH_EAST) n.set((hex.x - 1), (hex.y - 1)); + else if (o == Orientation.SOUTH) n.set((hex.x - 1), hex.y); + else if (o == Orientation.SOUTH_WEST) n.set(hex.x, (hex.y + 1)); + else if (o == Orientation.NORTH_WEST) n.set((hex.x + 1), (hex.y + 1)); + else n.set(hex.x, hex.y); + + return n; + } + public float getWidth() { return image.getWidth(); -- cgit v1.1-2-g2b99