blob: 446f79addcb5fb473ada23bea73fd5d690b34721 (
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
|
package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.RustAndDust;
import ch.asynk.rustanddust.game.Map;
import ch.asynk.rustanddust.game.Hex;
import ch.asynk.rustanddust.game.Unit;
import ch.asynk.rustanddust.game.Ctrl;
import ch.asynk.rustanddust.game.Ctrl.MsgType;
import ch.asynk.rustanddust.game.State;
import ch.asynk.rustanddust.game.Config;
public abstract class StateCommon implements State
{
protected static Config cfg;
protected static Ctrl ctrl;
protected static Map map;
protected static Hex selectedHex = null;
protected static Hex to = null;
private static Unit activeUnit;
private static Unit selectedUnit;
private void select(Unit u, boolean s)
{
if (u != null)
u.select(s);
}
public void select(Unit unit)
{
select(selectedUnit, false);
selectedUnit = unit;
select(selectedUnit, true);
}
public Unit selectedUnit() { return selectedUnit; }
public void activate(Unit unit)
{
select(activeUnit, false);
activeUnit = unit;
select(activeUnit, true);
}
public Unit activeUnit() { return activeUnit; }
public static void set(RustAndDust game)
{
ctrl = game.ctrl;
cfg = game.config;
map = game.ctrl.map;
}
@Override
public void touch(Hex hex) { }
@Override
public boolean processMsg(MsgType state, Object data)
{
return false;
}
}
|