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

import ch.asynk.tankontank.engine.Orientation;

public class GameStateDirection extends GameStateCommon
{
    @Override
    public void touchDown()
    {
    }

    @Override
    public void touchUp()
    {
        Orientation o = Orientation.KEEP;;
        if (downHex.y == hex.y) {
            if (downHex.x == (hex.x - 1)) {
                o = Orientation.SOUTH;
            } else if (downHex.x == (hex.x + 1)) {
                o = Orientation.NORTH;
            }
        } else if (downHex.y == (hex.y - 1)) {
            if (downHex.x == (hex.x - 1)) {
                o = Orientation.SOUTH_EAST;
            } else if (downHex.x == hex.x) {
                o = Orientation.NORTH_EAST;
            }

        } else if (downHex.y == (hex.y + 1)) {
            if (downHex.x == hex.x) {
                o = Orientation.SOUTH_WEST;
            } else if (downHex.x == (hex.x + 1)) {
                o = Orientation.NORTH_WEST;
            }
        }

        if (o != Orientation.KEEP)
            map.movePawn(pawn, o);
        map.enableFinalPath(hex, false);
        map.resetPaths();
        ctrl.setState(State.NONE, false);
    }
}