mirror of
https://github.com/Steffo99/octogem.git
synced 2024-10-16 20:17:26 +00:00
24 lines
No EOL
453 B
C#
24 lines
No EOL
453 B
C#
using UnityEngine;
|
|
|
|
[System.Serializable]
|
|
public class MapPosition : System.Object
|
|
{
|
|
public readonly int x;
|
|
public readonly int y;
|
|
|
|
public MapPosition(int x, int y)
|
|
{
|
|
this.x = x;
|
|
this.y = y;
|
|
}
|
|
|
|
public int Distance(MapPosition other)
|
|
{
|
|
return (Mathf.Abs(x - other.x) + Mathf.Abs(y - other.y));
|
|
}
|
|
|
|
public bool IsAdjacent(MapPosition other)
|
|
{
|
|
return (Distance(other) == 1);
|
|
}
|
|
} |