Added MapData.cs

This commit is contained in:
misabiko 2020-06-14 16:40:55 -04:00
parent 857e50842d
commit dcd81c7b83
2 changed files with 43 additions and 0 deletions

40
Assets/Scripts/MapData.cs Normal file
View File

@ -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];
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d8cf68d353cd464eb80c3158efd44450
timeCreated: 1592164640