EOS 2  1.1.0
Einfache Objektbasierte Sprache
Direction.java
gehe zur Dokumentation dieser Datei
1 package de.lathanda.eos.base.util;
8 public enum Direction {
9  SOUTH( 0,-1, 0),
10  WEST(-1, 0, 1),
11  NORTH( 0, 1, 2),
12  EAST( 1, 0, 3);
13  static {
14  WEST.left = SOUTH;
15  WEST.right = NORTH;
16  EAST.left = NORTH;
17  EAST.right = SOUTH;
18  NORTH.left = WEST;
19  NORTH.right = EAST;
20  SOUTH.left = EAST;
21  SOUTH.right = WEST;
22  }
23  public final int dx;
24  public final int dy;
25  public final int index;
26  private Direction left;
27  private Direction right;
28  private Direction(int dx, int dy, int index) {
29  this.dx = dx;
30  this.dy = dy;
31  this.index = index;
32  }
33  public final Direction getLeft() {
34  return left;
35  }
36  public final Direction getRight() {
37  return right;
38  }
39  public Direction getBack() {
40  return left.left;
41  }
42  public static Direction getDirection(int index) {
43  switch(index) {
44  case 0: return SOUTH;
45  case 1: return WEST;
46  case 2: return NORTH;
47  case 3: return EAST;
48  default:
49  return EAST;
50  }
51  }
52  public float getAngle() {
53  switch(index) {
54  case 0: return 180f;
55  case 1: return 90f;
56  case 2: return 0f;
57  case 3: return 270f;
58  default:
59  return 270;
60  }
61  }
62  @Override
63  public String toString() {
64  switch (this) {
65  case EAST:
66  return "E";
67  case SOUTH:
68  return "S";
69  case NORTH:
70  return "N";
71  case WEST:
72  return "W";
73  }
74  return "";
75  }
76 
77 }
static Direction getDirection(int index)
Definition: Direction.java:42
Impressum