summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game/Hex.java
blob: 0fa0587e811d6d6b2f50917fb0cc61159cf65027 (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
package ch.asynk.tankontank.game;

import com.badlogic.gdx.graphics.g2d.TextureAtlas;

import ch.asynk.tankontank.engine.Tile;
import ch.asynk.tankontank.engine.Board;

public class Hex extends Tile
{
    public enum Terrain
    {
        CLEAR,
        HILLS,
        WOODS,
        TOWN
    }

    public Terrain terrain;
    public int roads;

    public Hex(Terrain terrain, TextureAtlas atlas)
    {
        super(atlas);
        this.terrain = terrain;
        this.roads = 0;
    }

    public Hex(Terrain terrain, int roads, TextureAtlas atlas)
    {
        super(atlas);
        this.terrain = terrain;
        this.roads = roads;
    }

    public int costFrom(Board.Orientation side)
    {
        if (side.s == (roads & side.s)) return 1;

        int c = 0;
        switch(terrain) {
            case CLEAR:
            case HILLS:
                c = 1;
                break;
            case WOODS:
            case TOWN:
                c = 2;
                break;
        }

        return c;
    }
}