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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
package ch.asynk.gdx.boardgame;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import ch.asynk.gdx.boardgame.Overlays;
public class Tile implements Drawable
{
public static TextureAtlas defaultOverlay = null;
public static final Tile OffMap = new Tile(Integer.MIN_VALUE, Integer.MIN_VALUE, 0f, 0f, false);
public int x;
public int y;
public float cx;
public float cy;
public boolean blocked;
public boolean onMap;
public Tile parent;
public int acc;
public int searchCount;
public boolean roadMarch;
private Overlays overlays;
public Tile(int x, int y, float cx, float cy)
{
this(x, y, cx, cy, true);
}
public Tile(int x, int y, float cx, float cy, boolean onMap)
{
this.x = x;
this.y = y;
this.cx = cx;
this.cy = cy;
this.onMap = onMap;
this.blocked = false;
if (defaultOverlay != null) {
setOverlay(defaultOverlay);
}
}
public boolean isOnMap()
{
return onMap;
}
public boolean hasRoad(Orientation orientation)
{
return false;
}
public boolean blockLos(final Tile from, final Tile to, float d, float dt)
{
return false;
}
public boolean overlaysEnabled()
{
if (overlays != null) {
return overlays.isEnabled();
}
return false;
}
public void setOverlay(TextureAtlas textureAtlas)
{
this.overlays = new Overlays(textureAtlas);
this.overlays.centerOn(cx, cy);
}
public void disableOverlays()
{
overlays.disableAll();
}
public void enableOverlay(int i, boolean enable)
{
if (overlays != null) {
overlays.enable(i, enable);
}
}
public void enableOverlay(int i, Orientation o)
{
if (overlays != null) {
overlays.setRotation(i, o.r());
overlays.enable(i, true);
}
}
@Override public String toString()
{
return "[" + x + ", " + y + "] => [" + cx + "," + cy + "]";
}
@Override public void draw(Batch batch)
{
if (overlays != null) {
overlays.draw(batch);
}
}
@Override public void drawDebug(ShapeRenderer shapeRenderer)
{
if (overlays != null) {
overlays.drawDebug(shapeRenderer);
}
}
}
|