public static PatchCoordinates FromTile(TileCoordinates tileCoordinates) { var coordinates = new PatchCoordinates() { X = tileCoordinates.X / PatchWidth, Y = tileCoordinates.Y / PatchHeight }; if (tileCoordinates.X < 0) { coordinates.X--; } if (tileCoordinates.Y < 0) { coordinates.Y--; } return(coordinates); }
/// <summary> /// Distance from another tile in manhattan distance. /// </summary> /// <param name="other">The other tile.</param> /// <returns>Returns the distance from the other tile.</returns> public int DistanceFrom(TileCoordinates other) { return(Mathf.Abs(this.X - other.X) + Mathf.Abs(this.Y - other.Y)); }