diff --git a/Assets/Scripts/MapData.cs b/Assets/Scripts/MapData.cs new file mode 100644 index 0000000..3103489 --- /dev/null +++ b/Assets/Scripts/MapData.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +[CreateAssetMenu] +public class MapData : ScriptableObject { + static readonly Vector2[] AxialDirections = { + new Vector2(1, 0), + new Vector2(1, -1), + new Vector2(0, -1), + new Vector2(-1, 0), + new Vector2(-1, 1), + new Vector2(0, 1) + }; + + //With flat hexes + public enum Direction { + DownRight = 0, + UpRight = 1, + Up = 2, + UpLeft = 3, + DownLeft = 4, + Down = 6 + } + + /* With pointy hexes + enum Direction { + Right, + UpRight, + UpLeft, + Left, + DownLeft, + DownRight + }*/ + + /*public static Vector3 AxialToWorld(int q, int s) { + + }*/ + + public static Vector2 GetNeighbor(Vector2 axial, Direction direction) + => axial + AxialDirections[(int)direction]; +} \ No newline at end of file diff --git a/Assets/Scripts/MapData.cs.meta b/Assets/Scripts/MapData.cs.meta new file mode 100644 index 0000000..482d4a0 --- /dev/null +++ b/Assets/Scripts/MapData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d8cf68d353cd464eb80c3158efd44450 +timeCreated: 1592164640 \ No newline at end of file