blob: 7feee8886e5faf21c326cdd96fc2de30d67d3a42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.game.Hex;
import ch.asynk.rustanddust.game.Zone;
import ch.asynk.rustanddust.game.Unit;
import ch.asynk.rustanddust.game.Ctrl.MsgType;
public class StateReinforcement extends StateCommon
{
private Zone entryZone;
@Override
public void enterFrom(StateType prevState)
{
map.clearMoves();
map.clearUnits();
entryZone = null;
activate(null);
selectedHex = null;
select(null);
ctrl.hud.playerInfo.unitDock.show();
}
@Override
public boolean processMsg(MsgType msg, Object data)
{
switch(msg)
{
case UNIT_DOCK_SELECT:
showEntryZone((Unit) data);
return true;
}
return false;
}
@Override
public void touch(Hex hex)
{
if ((entryZone != null) && hex.isEmpty() && entryZone.contains(hex))
unitEnter(selectedUnit(), hex);
}
private void showEntryZone(Unit unit)
{
select(unit);
if (entryZone != null)
entryZone.enable(Hex.AREA, false);
entryZone = unit.entryZone;
entryZone.enable(Hex.AREA, true);
}
private void unitEnter(Unit unit, Hex hex)
{
activate(unit);
selectedHex = hex;
map.enterBoard(unit, hex, entryZone);
entryZone.enable(Hex.AREA, false);
ctrl.battle.getPlayer().reinforcement.remove(unit);
ctrl.hud.playerInfo.unitDock.hide();
ctrl.hud.update();
ctrl.post(StateType.MOVE);
entryZone = null;
}
}
|