summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-20 13:38:51 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-20 13:38:51 +0100
commit4afc2ac7c837ae645733109a161305c804a1b45a (patch)
tree223875875e27031fc796192b4ab6c9a9b03aeafa /core/src/ch/asynk/tankontank/game
parent661409680c14f8999b5bb2c32e616a42be361fa2 (diff)
downloadRustAndDust-4afc2ac7c837ae645733109a161305c804a1b45a.zip
RustAndDust-4afc2ac7c837ae645733109a161305c804a1b45a.tar.gz
engine.TileSet/Zone are dead: welcome game.HexSet/Zone
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/Battle.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/HexSet.java29
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java7
-rw-r--r--core/src/ch/asynk/tankontank/game/Zone.java14
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleCommon.java6
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java10
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java16
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java16
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java16
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleNightAction.java10
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java16
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateCommon.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateDeployment.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateEscape.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateReinforcement.java2
15 files changed, 89 insertions, 61 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Battle.java b/core/src/ch/asynk/tankontank/game/Battle.java
index 9b1e502..0c2c3e3 100644
--- a/core/src/ch/asynk/tankontank/game/Battle.java
+++ b/core/src/ch/asynk/tankontank/game/Battle.java
@@ -1,6 +1,6 @@
package ch.asynk.tankontank.game;
-import ch.asynk.tankontank.engine.Zone;
+import ch.asynk.tankontank.game.Zone;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.hud.Position;
diff --git a/core/src/ch/asynk/tankontank/game/HexSet.java b/core/src/ch/asynk/tankontank/game/HexSet.java
new file mode 100644
index 0000000..436c727
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/game/HexSet.java
@@ -0,0 +1,29 @@
+package ch.asynk.tankontank.game;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+
+import ch.asynk.tankontank.engine.Tile;
+
+public class HexSet extends LinkedHashSet<Hex>
+{
+ private final Map map;
+
+ public HexSet(Map map, int n)
+ {
+ super(n);
+ this.map = map;
+ }
+
+ public void enable(int i, boolean enable)
+ {
+ for (Hex hex : this)
+ map.enableOverlayOn(hex, i, enable);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<Tile> hexAsTiles()
+ {
+ return (Collection) this;
+ }
+}
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index e02073d..2a5ff2f 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -12,7 +12,6 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import ch.asynk.tankontank.TankOnTank;
import ch.asynk.tankontank.engine.Pawn;
import ch.asynk.tankontank.engine.PawnSet;
-import ch.asynk.tankontank.engine.TileSet;
import ch.asynk.tankontank.engine.Board;
import ch.asynk.tankontank.engine.Orientation;
import ch.asynk.tankontank.engine.Meteorology;
@@ -29,7 +28,7 @@ public abstract class Map extends Board
private Random rand = new Random();
- public final Board.TileCollection possibleMoves;
+ public final HexSet possibleMoves;
public final PossiblePaths possiblePaths;
public final Board.PawnCollection moveablePawns;
@@ -65,7 +64,7 @@ public abstract class Map extends Board
setup();
- possibleMoves = new TileSet(this, 40);
+ possibleMoves = new HexSet(this, 40);
possiblePaths = new PossiblePaths(this, 10, 20, 5, 10);
moveablePawns = new PawnSet(this, 6);
@@ -115,7 +114,7 @@ public abstract class Map extends Board
possibleMoves.clear();
return 0;
}
- return collectPossibleMoves(unit, possibleMoves);
+ return collectPossibleMoves(unit, possibleMoves.hexAsTiles());
}
public int togglePossiblePathHex(Hex hex)
diff --git a/core/src/ch/asynk/tankontank/game/Zone.java b/core/src/ch/asynk/tankontank/game/Zone.java
new file mode 100644
index 0000000..de3a0d9
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/game/Zone.java
@@ -0,0 +1,14 @@
+package ch.asynk.tankontank.game;
+
+import ch.asynk.tankontank.engine.Orientation;
+
+public class Zone extends HexSet
+{
+ public int allowedMoves;
+ public Orientation orientation;
+
+ public Zone(Map map, int n)
+ {
+ super(map, n);
+ }
+}
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java b/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
index 4b536f1..a816799 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
@@ -4,13 +4,13 @@ import java.util.Random;
import java.util.HashMap;
import java.util.ArrayList;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.game.Army;
import ch.asynk.tankontank.game.Battle;
import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.Ctrl;
import ch.asynk.tankontank.game.Map;
+import ch.asynk.tankontank.game.Zone;
+import ch.asynk.tankontank.game.HexSet;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
import ch.asynk.tankontank.game.State.StateType;
@@ -28,7 +28,7 @@ public abstract class BattleCommon implements Battle
protected ArrayList<Zone> exitZone = new ArrayList<Zone>();
protected HashMap<Unit, Zone> unitEntry = new HashMap<Unit, Zone>();
protected HashMap<Unit, Zone> unitExit = new HashMap<Unit, Zone>();
- protected TileSet objectives;
+ protected HexSet objectives;
public BattleCommon(Factory factory)
{
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java b/core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java
index 6b93f9e..324f187 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java
@@ -1,17 +1,13 @@
package ch.asynk.tankontank.game.battles;
-import ch.asynk.tankontank.game.Ctrl;
-import ch.asynk.tankontank.game.Map;
-import ch.asynk.tankontank.game.Hex;
import ch.asynk.tankontank.game.Army;
import ch.asynk.tankontank.game.Player;
-import ch.asynk.tankontank.game.State.StateType;
+import ch.asynk.tankontank.game.Ctrl;
+import ch.asynk.tankontank.game.Map;
+import ch.asynk.tankontank.game.Zone;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
import ch.asynk.tankontank.game.hud.Position;
-import ch.asynk.tankontank.engine.Tile;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.engine.Orientation;
public class BattleCounterAttack extends BattleCommon
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java b/core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java
index be5d820..173e719 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java
@@ -1,17 +1,15 @@
package ch.asynk.tankontank.game.battles;
+import ch.asynk.tankontank.game.Army;
+import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.Ctrl;
import ch.asynk.tankontank.game.Map;
import ch.asynk.tankontank.game.Hex;
-import ch.asynk.tankontank.game.Army;
-import ch.asynk.tankontank.game.Player;
-import ch.asynk.tankontank.game.State.StateType;
+import ch.asynk.tankontank.game.HexSet;
+import ch.asynk.tankontank.game.Zone;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
import ch.asynk.tankontank.game.hud.Position;
-import ch.asynk.tankontank.engine.Tile;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.engine.Orientation;
public class BattleFrontalAssault extends BattleCommon
@@ -71,8 +69,8 @@ public class BattleFrontalAssault extends BattleCommon
return null;
int count = 0;
- for (Tile tile : objectives) {
- Unit unit = ((Hex) tile).getUnit();
+ for (Hex hex : objectives) {
+ Unit unit = hex.getUnit();
if ((unit != null) && unit.is(Army.US))
count =+ 1;
}
@@ -87,7 +85,7 @@ public class BattleFrontalAssault extends BattleCommon
public void setup(Ctrl ctrl, Map map)
{
// G9, E6, H4
- objectives = new TileSet(map, 3);
+ objectives = new HexSet(map, 3);
objectives.add(map.getHex(2, 2));
objectives.add(map.getHex(6, 4));
objectives.add(map.getHex(6, 1));
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java b/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
index fd5c0d8..e3e9c80 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
@@ -1,17 +1,15 @@
package ch.asynk.tankontank.game.battles;
+import ch.asynk.tankontank.game.Zone;
+import ch.asynk.tankontank.game.Army;
+import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.Ctrl;
import ch.asynk.tankontank.game.Map;
import ch.asynk.tankontank.game.Hex;
-import ch.asynk.tankontank.game.Army;
-import ch.asynk.tankontank.game.Player;
-import ch.asynk.tankontank.game.State.StateType;
+import ch.asynk.tankontank.game.HexSet;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
import ch.asynk.tankontank.game.hud.Position;
-import ch.asynk.tankontank.engine.Tile;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.engine.Orientation;
public class BattleHeadToHead extends BattleCommon
@@ -58,8 +56,8 @@ public class BattleHeadToHead extends BattleCommon
int player = 0;
int opponent = 0;
- for (Tile tile : objectives) {
- Unit unit = ((Hex) tile).getUnit();
+ for (Hex hex : objectives) {
+ Unit unit = hex.getUnit();
if (unit != null) {
if (ctrl.player.isEnemy(unit))
opponent += 1;
@@ -83,7 +81,7 @@ public class BattleHeadToHead extends BattleCommon
gePlayer.turnEnd();
// B6, E6, H4
- objectives = new TileSet(map, 3);
+ objectives = new HexSet(map, 3);
objectives.add(map.getHex(7, 7));
objectives.add(map.getHex(6, 4));
objectives.add(map.getHex(6, 1));
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java b/core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java
index 38be856..3430d88 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java
@@ -1,17 +1,15 @@
package ch.asynk.tankontank.game.battles;
+import ch.asynk.tankontank.game.Zone;
+import ch.asynk.tankontank.game.Army;
+import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.Ctrl;
import ch.asynk.tankontank.game.Map;
import ch.asynk.tankontank.game.Hex;
-import ch.asynk.tankontank.game.Army;
-import ch.asynk.tankontank.game.Player;
-import ch.asynk.tankontank.game.State.StateType;
+import ch.asynk.tankontank.game.HexSet;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
import ch.asynk.tankontank.game.hud.Position;
-import ch.asynk.tankontank.engine.Tile;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.engine.Orientation;
public class BattleLastStand extends BattleCommon
@@ -60,8 +58,8 @@ public class BattleLastStand extends BattleCommon
if (unit.isAce())
usPoints += 1;
}
- for (Tile tile : objectives) {
- Unit unit = ((Hex) tile).getUnit();
+ for (Hex hex: objectives) {
+ Unit unit = hex.getUnit();
if ((unit != null) && unit.is(Army.US))
usPoints += 1;
}
@@ -76,7 +74,7 @@ public class BattleLastStand extends BattleCommon
public void setup(Ctrl ctrl, Map map)
{
// A7, E6, F6, G10
- objectives = new TileSet(map, 4);
+ objectives = new HexSet(map, 4);
objectives.add(map.getHex(7, 8));
objectives.add(map.getHex(6, 4));
objectives.add(map.getHex(5, 3));
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleNightAction.java b/core/src/ch/asynk/tankontank/game/battles/BattleNightAction.java
index 800c884..e712e65 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleNightAction.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleNightAction.java
@@ -1,17 +1,15 @@
package ch.asynk.tankontank.game.battles;
+import ch.asynk.tankontank.game.Zone;
+import ch.asynk.tankontank.game.Army;
+import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.Ctrl;
import ch.asynk.tankontank.game.Map;
import ch.asynk.tankontank.game.Hex;
-import ch.asynk.tankontank.game.Army;
-import ch.asynk.tankontank.game.Player;
-import ch.asynk.tankontank.game.State.StateType;
+import ch.asynk.tankontank.game.HexSet;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
import ch.asynk.tankontank.game.hud.Position;
-import ch.asynk.tankontank.engine.Tile;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.engine.Orientation;
import ch.asynk.tankontank.engine.Meteorology;
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java b/core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java
index 079b69c..9e8a61e 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java
@@ -1,17 +1,15 @@
package ch.asynk.tankontank.game.battles;
+import ch.asynk.tankontank.game.Zone;
+import ch.asynk.tankontank.game.Army;
+import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.Ctrl;
import ch.asynk.tankontank.game.Map;
import ch.asynk.tankontank.game.Hex;
-import ch.asynk.tankontank.game.Army;
-import ch.asynk.tankontank.game.Player;
-import ch.asynk.tankontank.game.State.StateType;
+import ch.asynk.tankontank.game.HexSet;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
import ch.asynk.tankontank.game.hud.Position;
-import ch.asynk.tankontank.engine.Tile;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.engine.Orientation;
public class BattleStabToTheFlank extends BattleCommon
@@ -61,8 +59,8 @@ public class BattleStabToTheFlank extends BattleCommon
else
usPoints += escaped;
- for (Tile tile : objectives) {
- Unit unit = ((Hex) tile).getUnit();
+ for (Hex hex : objectives) {
+ Unit unit = hex.getUnit();
if ((unit != null) && unit.is(Army.US))
usPoints += 1;
}
@@ -97,7 +95,7 @@ public class BattleStabToTheFlank extends BattleCommon
public void setup(Ctrl ctrl, Map map)
{
// F6, E6
- objectives = new TileSet(map, 2);
+ objectives = new HexSet(map, 2);
objectives.add(map.getHex(5, 3));
objectives.add(map.getHex(6, 4));
objectives.enable(Hex.OBJECTIVE, true);
diff --git a/core/src/ch/asynk/tankontank/game/states/StateCommon.java b/core/src/ch/asynk/tankontank/game/states/StateCommon.java
index e702ce4..2da80ae 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateCommon.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateCommon.java
@@ -1,6 +1,6 @@
package ch.asynk.tankontank.game.states;
-import ch.asynk.tankontank.engine.Zone;
+import ch.asynk.tankontank.game.Zone;
import ch.asynk.tankontank.game.Map;
import ch.asynk.tankontank.game.Hex;
import ch.asynk.tankontank.game.Unit;
diff --git a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java
index c3944bc..89e97aa 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java
@@ -1,9 +1,9 @@
package ch.asynk.tankontank.game.states;
import ch.asynk.tankontank.engine.Orientation;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.engine.PawnSet;
import ch.asynk.tankontank.game.Hex;
+import ch.asynk.tankontank.game.Zone;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.hud.ActionButtons.Buttons;
diff --git a/core/src/ch/asynk/tankontank/game/states/StateEscape.java b/core/src/ch/asynk/tankontank/game/states/StateEscape.java
index 7ff9fa8..30af8e5 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateEscape.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateEscape.java
@@ -1,6 +1,6 @@
package ch.asynk.tankontank.game.states;
-import ch.asynk.tankontank.engine.Zone;
+import ch.asynk.tankontank.game.Zone;
import ch.asynk.tankontank.game.Unit;
public class StateEscape extends StateCommon
diff --git a/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java b/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
index 634ee00..686a388 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
@@ -1,7 +1,7 @@
package ch.asynk.tankontank.game.states;
-import ch.asynk.tankontank.engine.Zone;
import ch.asynk.tankontank.game.Hex;
+import ch.asynk.tankontank.game.Zone;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.hud.ActionButtons.Buttons;