public void ShouldTranslateCoordinatesToRelativePlane() { var coords = new[] { new AxialCoordinate(0, 0), new AxialCoordinate(1, 0), new AxialCoordinate(0, 1), new AxialCoordinate(1, 1), }; var expectedCoords = new[] { new Vector2(0, 0), new Vector2(1.5f, -Mathf.Sqrt(3) / 2), new Vector2(0, -Mathf.Sqrt(3)), new Vector2(1.5f, -Mathf.Sqrt(3) * 1.5f), }; var coordSystem = new HexCoordinateSystem(1); var actualCoords = coords.Select(x => coordSystem.TileMapToRelative(x)); foreach (var pair in expectedCoords.Zip(actualCoords, (a, b) => new { expected = a, actual = b })) { Assert.AreEqual(pair.expected, pair.actual); } }
public Vector2 TileMapToReal(AxialCoordinate tileMapPosition) { return(coordinateSystem.TileMapToRelative(tileMapPosition)); }