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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
package ch.asynk.tankontank.game;
import com.badlogic.gdx.math.GridPoint2;
import ch.asynk.tankontank.engine.Pawn;
import ch.asynk.tankontank.engine.Tile;
public abstract class GameStateCommon implements GameState
{
protected static GameCtrl ctrl;
protected static Map map;
protected static Pawn pawn;
protected static Tile tile;
protected static GridPoint2 hex = new GridPoint2(0, 0);
protected static GridPoint2 downHex = new GridPoint2(-1, -1);
protected static GridPoint2 upHex = new GridPoint2(-1, -1);
protected GameStateCommon()
{
}
public GameStateCommon(GameCtrl ctrl, Map map)
{
this.ctrl = ctrl;
this.map = map;
}
// downHex
protected static boolean downHexInMap()
{
if (downHex.x == -1) return false;
return !map.isOffMap(downHex);
}
protected static boolean down(float x, float y)
{
map.getHexAt(downHex, x, y);
return downHexInMap();
}
protected static boolean up(float x, float y)
{
map.getHexAt(upHex, x, y);
return downHexInMap();
}
// pawn
protected void setPawn()
{
pawn = map.getTopPawnAt(hex);
}
// hex
protected void setHex()
{
hex.set(downHex.x, downHex.y);
}
protected boolean hexHasUnit()
{
return map.hasUnits(hex);
}
protected void unselectHex()
{
map.enableOverlayOn(hex, Hex.BLUE, false);
}
protected void selectHex()
{
map.enableOverlayOn(hex, Hex.BLUE, true);
}
// protected Hex getHex(int col, int row)
// {
// return (Hex) map.getTile(col, row);
// }
}
|