-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapDirection.java
61 lines (57 loc) · 1.89 KB
/
MapDirection.java
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 logic;
enum MapDirection{
NORTH, SOUTH, WEST, EAST,NORTHEAST,NORTHWEST,SOUTHEAST,SOUTHWEST;
@Override
public String toString(){
switch (this){
case EAST:return "Wschod";
case SOUTH:return "Poludnie";
case WEST:return "Zachod";
case NORTH:return "Polnoc";
case NORTHEAST: return "Polnocny-wschod";
case NORTHWEST: return "Polnocny-zachod";
case SOUTHEAST: return "Poludniowy-wschod";
case SOUTHWEST: return "Poludniowy-zachod";
}
return null;
}
public MapDirection next(){
switch (this){
case EAST:return SOUTHEAST;
case SOUTHEAST:return SOUTH;
case SOUTH:return SOUTHWEST;
case SOUTHWEST:return WEST;
case WEST:return NORTHWEST;
case NORTHWEST:return NORTH;
case NORTH:return NORTHEAST;
case NORTHEAST:return EAST;
}
return null;
}
public MapDirection previous(){
switch (this){
case EAST:return NORTHEAST;
case SOUTHEAST:return EAST;
case SOUTH:return SOUTHEAST;
case SOUTHWEST:return SOUTH;
case WEST:return SOUTHWEST;
case NORTHWEST:return WEST;
case NORTH:return NORTHWEST;
case NORTHEAST:return NORTH;
}
return null;
}
public Vector2d toUnitVector(){
switch(this){
case NORTH:return new Vector2d(0,1);
case NORTHEAST: return new Vector2d(1,1);
case EAST:return new Vector2d(1,0);
case SOUTHEAST:return new Vector2d(1,-1);
case SOUTH:return new Vector2d(0,-1);
case SOUTHWEST:return new Vector2d(-1,-1);
case WEST:return new Vector2d(-1,0);
case NORTHWEST:return new Vector2d(-1,1);
}
return null;
}
}