-
Notifications
You must be signed in to change notification settings - Fork 0
/
MazeDirection.cs
52 lines (42 loc) · 1.03 KB
/
MazeDirection.cs
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
using UnityEngine;
public enum MazeDirection {
North,
East,
South,
West
}
public static class MazeDirections {
public const int Count = 4;
public static MazeDirection RandomValue {
get {
return (MazeDirection)Random.Range(0, Count);
}
}
private static MazeDirection[] opposites = {
MazeDirection.South,
MazeDirection.West,
MazeDirection.North,
MazeDirection.East
};
public static MazeDirection GetOpposite (this MazeDirection direction) {
return opposites[(int)direction];
}
private static IntVector2[] vectors = {
new IntVector2(0, 1),
new IntVector2(1, 0),
new IntVector2(0, -1),
new IntVector2(-1, 0)
};
public static IntVector2 ToIntVector2 (this MazeDirection direction) {
return vectors[(int)direction];
}
private static Quaternion[] rotations = {
Quaternion.identity,
Quaternion.Euler(0f, 90f, 0f),
Quaternion.Euler(0f, 180f, 0f),
Quaternion.Euler(0f, 270f, 0f)
};
public static Quaternion ToRotation (this MazeDirection direction) {
return rotations[(int)direction];
}
}