diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-28 18:38:37 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-28 18:38:37 +0100 |
commit | ec8d22ee6a21b8aaf56b051600e7d9bb94a1d788 (patch) | |
tree | fed0f439885aeb333ffe5dfddf491248d206dd49 /core/src/ch/asynk/rustanddust/game | |
parent | d76dd1fa80df0f89e33c3d3c5ab40e48c4f82d77 (diff) | |
download | RustAndDust-ec8d22ee6a21b8aaf56b051600e7d9bb94a1d788.zip RustAndDust-ec8d22ee6a21b8aaf56b051600e7d9bb94a1d788.tar.gz |
Objective: Tile swallows Objective, ObjectiveSet is destroyed, Board does the trick
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game')
6 files changed, 13 insertions, 47 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Factory.java b/core/src/ch/asynk/rustanddust/game/Factory.java index 6f5b731..d65edd9 100644 --- a/core/src/ch/asynk/rustanddust/game/Factory.java +++ b/core/src/ch/asynk/rustanddust/game/Factory.java @@ -187,7 +187,7 @@ public class Factory implements Board.TileBuilder, Disposable public Hex getNewTile(float x, float y, int col, int row, boolean offmap) { - Hex hex = new Hex(x, y, col, row, hexOverlaysAtlas); + Hex hex = new Hex(x, y, col, row, hexOverlaysAtlas, Army.NONE); if (offmap) hex.terrain = Hex.Terrain.OFFMAP; return hex; } diff --git a/core/src/ch/asynk/rustanddust/game/Hex.java b/core/src/ch/asynk/rustanddust/game/Hex.java index 5f970ba..2bfbc94 100644 --- a/core/src/ch/asynk/rustanddust/game/Hex.java +++ b/core/src/ch/asynk/rustanddust/game/Hex.java @@ -43,9 +43,9 @@ public class Hex extends Tile return String.format("(%d;%d)", col, row); } - public Hex(float x, float y, int col, int row, TextureAtlas atlas) + public Hex(float x, float y, int col, int row, TextureAtlas atlas, Army defaultArmy) { - super(x, y, col, row, atlas); + super(x, y, col, row, atlas, defaultArmy); this.terrain = Terrain.CLEAR; this.roads = 0; } diff --git a/core/src/ch/asynk/rustanddust/game/Map.java b/core/src/ch/asynk/rustanddust/game/Map.java index 99f1011..d3daf1c 100644 --- a/core/src/ch/asynk/rustanddust/game/Map.java +++ b/core/src/ch/asynk/rustanddust/game/Map.java @@ -32,16 +32,12 @@ public abstract class Map extends Map4Commands public void actionDone() { - objectives.forget(); } public void turnDone() { RustAndDust.debug("TurnDone", String.format(" Processed Commands : %d", commandsSize())); - if (objectives.modifiedCount() > 0) - throw new RuntimeException("objectives not cleared"); - // FIXME do something with these Commands commandsClear(); } diff --git a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java index 77780cd..1472d6b 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java @@ -8,21 +8,18 @@ import ch.asynk.rustanddust.engine.Pawn; import ch.asynk.rustanddust.engine.Board; import ch.asynk.rustanddust.engine.Faction; import ch.asynk.rustanddust.engine.SelectedTile; -import ch.asynk.rustanddust.engine.ObjectiveSet; import ch.asynk.rustanddust.game.Hex; import ch.asynk.rustanddust.game.Army; -public abstract class Map0Hex extends Board implements ObjectiveSet.ObjectiveCb +public abstract class Map0Hex extends Board { protected final RustAndDust game; - protected final ObjectiveSet objectives; public Map0Hex(final RustAndDust game, Texture map, SelectedTile hex) { super(game.factory, map, hex); this.game = game; - objectives = new ObjectiveSet(this, 4); } public Hex getHexAt(float x, float y) @@ -48,25 +45,10 @@ public abstract class Map0Hex extends Board implements ObjectiveSet.ObjectiveCb private void addObjective(int col, int row, Army army, boolean persistent) { Hex hex = getHex(col, row); - objectives.add(hex, army, persistent); + hex.setObjective(army, (persistent ? Tile.Objective.PERSISTENT : Tile.Objective.VERSATILE)); showObjective(hex, army, !persistent); } - protected void claim(Hex hex, Army army) - { - showObjective(hex, objectives.claim(hex, army)); - } - - protected void unclaim(Hex hex) - { - showObjective(hex, objectives.unclaim(hex)); - } - - public int objectivesCount(Army army) - { - return objectives.count(army); - } - public void hexSelect(Hex hex) { selectedTile.set(hex); } public void hexUnselect(Hex hex) { selectedTile.hide(); } public void hexMoveShow(Hex hex) { enableOverlayOn(hex, Hex.MOVE, true); } @@ -76,18 +58,6 @@ public abstract class Map0Hex extends Board implements ObjectiveSet.ObjectiveCb public void hexExitShow(Hex hex) { enableOverlayOn(hex, Hex.EXIT, true); } public void hexExitHide(Hex hex) { enableOverlayOn(hex, Hex.EXIT, false); } - @Override - public boolean isObjectiveFor(Tile tile, Pawn pawn) - { - return objectives.isObjectiveFor(tile, pawn); - } - - @Override - public void showObjective(Tile tile, Faction faction) - { - showObjective((Hex) tile, (Army) faction); - } - private void showObjective(Hex hex, Army army, boolean hold) { if (hold) diff --git a/core/src/ch/asynk/rustanddust/game/map/Map3Animations.java b/core/src/ch/asynk/rustanddust/game/map/Map3Animations.java index ee114f7..68bb441 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map3Animations.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map3Animations.java @@ -74,13 +74,13 @@ public abstract class Map3Animations extends Map2Moves implements MoveToAnimatio @Override public void moveToAnimationEnter(Moveable moveable, float x, float y, float r) { - claim(getHexAt(x, y), (Army) moveable.getFaction()); + claim(moveable, getHexAt(x, y)); } @Override public void moveToAnimationLeave(Moveable moveable, float x, float y, float r) { - unclaim(getHexAt(x, y)); + unclaim(moveable, getHexAt(x, y)); } @Override diff --git a/core/src/ch/asynk/rustanddust/game/map/Map4Commands.java b/core/src/ch/asynk/rustanddust/game/map/Map4Commands.java index 7bb6293..8cde4fc 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map4Commands.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map4Commands.java @@ -78,18 +78,18 @@ public abstract class Map4Commands extends Map3Animations { for (Unit unit: activatedUnits) { RustAndDust.debug(" revertMove() " + unit); - revertLastPawnMove(unit); + revertLastPawnMove(unit, ((Command) commands.get(unit, Command.CommandType.MOVE)).move); commands.dispose(unit, Command.CommandType.MOVE); } activatedUnits.clear(); - objectives.revert(this); } public void revertEnter(final Unit unit) { RustAndDust.debug(" revertEnter() "+ unit); + + revertclaim(unit, unit.getHex()); removePawn(unit); - objectives.revert(this); battle.getPlayer().revertUnitEntry(unit); commands.dispose(unit); unit.reset(); @@ -188,12 +188,12 @@ public abstract class Map4Commands extends Map3Animations case SET: setPawnOnto(unit, move); battle.getPlayer().unitEntry(unit); - claim((Hex) move.to, unit.getArmy()); + claim(unit, move.to); break; case ENTER: enterPawn(unit, move); battle.getPlayer().unitEntry(unit); - claim((Hex) move.to, unit.getArmy()); + claim(unit, move.to); break; default: System.err.println(String.format("process wrong Move type %s", move.type)); @@ -222,7 +222,7 @@ public abstract class Map4Commands extends Map3Animations } if (e.success) { - unclaim(e.defender.getHex()); + unclaim(e.defender, e.defender.getHex()); removePawn(e.defender); addDestroyAnimation(e.defender); } |