diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 27 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 18 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Tile.java | 13 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 5 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/screens/GameScreen.java | 7 |
5 files changed, 32 insertions, 38 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index a3eeaa0..7c77c75 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -24,6 +24,25 @@ import ch.asynk.tankontank.engine.gfx.animations.RunnableAnimation; public abstract class Board extends Image implements Disposable { + public enum Orientation + { + KEEP(0, 0), + NORTH(-90, 1), + NORTH_EAST(-150, 2), + SOUTH_EAST(150, 3), + SOUTH(90, 4), + SOUTH_WEST (30, 5), + NORTH_WEST(-30, 6); + + public static int offset = 0; + private final int r; + public final int s; + + Orientation(int r, int s) { this.r = r; this.s = s; } + + public float r() { return offset + r; } + } + public static class Config { public int cols; @@ -226,7 +245,7 @@ public abstract class Board extends Image implements Disposable return new Vector2(x, y); } - public void setPawnAt(final Pawn pawn, final int col, final int row, Pawn.Orientation o) + public void setPawnAt(final Pawn pawn, final int col, final int row, Orientation o) { Vector2 pos = getPawnPosAt(pawn, col, row); pawn.pushMove(pos.x, pos.y, o); @@ -236,15 +255,15 @@ public abstract class Board extends Image implements Disposable public void movePawnTo(Pawn pawn, Vector3 coords) { GridPoint2 hex = getHexAt(null, coords.x, coords.y); - movePawnTo(pawn, hex.x, hex.y, Pawn.Orientation.KEEP); + movePawnTo(pawn, hex.x, hex.y, Orientation.KEEP); } public void movePawnTo(Pawn pawn, GridPoint2 hex) { - movePawnTo(pawn, hex.x, hex.y, Pawn.Orientation.KEEP); + movePawnTo(pawn, hex.x, hex.y, Orientation.KEEP); } - public void movePawnTo(final Pawn pawn, final int col, final int row, Pawn.Orientation o) + public void movePawnTo(final Pawn pawn, final int col, final int row, Orientation o) { GridPoint2 prev = getHexAt(pawn.getLastPosition()); removePawnFrom(pawn, prev.x, prev.y); diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 204bc97..3061346 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -15,20 +15,6 @@ import ch.asynk.tankontank.engine.gfx.animations.AnimationSequence; public abstract class Pawn extends Image implements Disposable { - public enum Orientation - { - KEEP(0), - NORTH_WEST(30), - WEST(90), - SOUTH_WEST(150), - NORTH_EAST (-30), - EAST(-90), - SOUTH_EAST(-150); - - public final int v; - Orientation(int v) { this.v = v; } - } - private static final float MOVE_TIME = 0.3f; private ArrayDeque<Vector3> path = new ArrayDeque<Vector3>(); @@ -51,9 +37,9 @@ public abstract class Pawn extends Image implements Disposable path.push(v); } - public void pushMove(float x, float y, Pawn.Orientation o) + public void pushMove(float x, float y, Board.Orientation o) { - float r = ((o == Pawn.Orientation.KEEP) ? getRotation() : o.v); + float r = ((o == Board.Orientation.KEEP) ? getRotation() : o.r()); setPosition(x, y, r); Vector3 v = new Vector3(x, y, r); if ((path.size() == 0) || (!v.equals(path.getFirst()))) diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java index 94f3435..96c6d60 100644 --- a/core/src/ch/asynk/tankontank/engine/Tile.java +++ b/core/src/ch/asynk/tankontank/engine/Tile.java @@ -12,19 +12,6 @@ import ch.asynk.tankontank.engine.gfx.StackedImages; public abstract class Tile implements BasicDrawable { - public enum Side - { - WEST(1), - NORTH_WEST(2), - NORTH_EAST (4), - EAST(8), - SOUTH_EAST(16), - SOUTH_WEST(32); - - public final int v; - Side(int v) { this.v = v; } - } - private StackedImages overlays; private ArrayDeque<Pawn> stack; diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java index ae6499e..c2b9be6 100644 --- a/core/src/ch/asynk/tankontank/game/Hex.java +++ b/core/src/ch/asynk/tankontank/game/Hex.java @@ -3,6 +3,7 @@ package ch.asynk.tankontank.game; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import ch.asynk.tankontank.engine.Tile; +import ch.asynk.tankontank.engine.Board; public class Hex extends Tile { @@ -31,9 +32,9 @@ public class Hex extends Tile this.roads = roads; } - public int costFrom(Side side) + public int costFrom(Board.Orientation side) { - if (side.v == (roads & side.v)) return 1; + if (side.s == (roads & side.s)) return 1; int c = 0; switch(terrain) { diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java index 6204446..3d82ab9 100644 --- a/core/src/ch/asynk/tankontank/screens/GameScreen.java +++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java @@ -32,6 +32,7 @@ import ch.asynk.tankontank.game.GameFactory; import ch.asynk.tankontank.game.GameFactory.UnitType; import ch.asynk.tankontank.game.Map; +import ch.asynk.tankontank.engine.Board; import ch.asynk.tankontank.engine.Pawn; public class GameScreen implements Screen @@ -79,7 +80,7 @@ public class GameScreen implements Screen debugShapes = new ShapeRenderer(); - Pawn.Orientation o = Pawn.Orientation.EAST; + Board.Orientation o = Board.Orientation.NORTH; addUnit(1, 7, o, UnitType.GE_AT_GUN); addUnit(1, 6, o, UnitType.GE_INFANTRY); addUnit(1, 5, o, UnitType.GE_KINGTIGER); @@ -88,7 +89,7 @@ public class GameScreen implements Screen addUnit(1, 2, o, UnitType.GE_TIGER); addUnit(1, 1, o, UnitType.GE_WESPE); - o = Pawn.Orientation.WEST; + o = Board.Orientation.SOUTH; addUnit(9, 7, o, UnitType.US_AT_GUN); addUnit(9, 6, o, UnitType.US_INFANTRY); addUnit(9, 5, o, UnitType.US_PERSHING); @@ -104,7 +105,7 @@ public class GameScreen implements Screen Gdx.input.setInputProcessor(getMultiplexer()); } - private void addUnit(int col, int row, Pawn.Orientation o, UnitType t) + private void addUnit(int col, int row, Board.Orientation o, UnitType t) { Pawn p = GameFactory.getUnit(t); map.setPawnAt(p, col, row, o); |