summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/game/map
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-28 18:38:37 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-28 18:38:37 +0100
commitec8d22ee6a21b8aaf56b051600e7d9bb94a1d788 (patch)
treefed0f439885aeb333ffe5dfddf491248d206dd49 /core/src/ch/asynk/rustanddust/game/map
parentd76dd1fa80df0f89e33c3d3c5ab40e48c4f82d77 (diff)
downloadRustAndDust-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/map')
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map0Hex.java34
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map3Animations.java4
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map4Commands.java12
3 files changed, 10 insertions, 40 deletions
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);
}