public int DistanceTo(TerrainTile t) { return(Mathf.RoundToInt(Vector2.Distance(new Vector2(X, Y), new Vector2(t.X, t.Y)))); }
private void ComputeTileNeighbours(TerrainTile tile, int x = 0, int y = 0) { if (!_worldGenerated) { if (x > 0) { tile.SetNeighbour(NeighbourDirection.Left, _grid[x - 1, y]); } if (y > 0) { tile.SetNeighbour(NeighbourDirection.Bottom, _grid[x, y - 1]); if (x + 1 < _gridSizeX) { tile.SetNeighbour(NeighbourDirection.BottomRight, _grid[x + 1, y - 1]); } if (x > 0) { tile.SetNeighbour(NeighbourDirection.BottomLeft, _grid[x - 1, y - 1]); } } } else { if (tile.X > 0) { tile.SetNeighbour(NeighbourDirection.Left, _grid[tile.X - 1, tile.Y]); if (tile.X + 1 < _gridSizeX) { tile.SetNeighbour(NeighbourDirection.Right, _grid[tile.X + 1, tile.Y]); } } if (tile.Y > 0) { tile.SetNeighbour(NeighbourDirection.Bottom, _grid[tile.X, tile.Y - 1]); if (tile.X + 1 < _gridSizeX) { tile.SetNeighbour(NeighbourDirection.BottomRight, _grid[tile.X + 1, tile.Y - 1]); } if (tile.X > 0) { tile.SetNeighbour(NeighbourDirection.BottomLeft, _grid[tile.X - 1, tile.Y - 1]); } } if (tile.Y + 1 < _gridSizeY) { tile.SetNeighbour(NeighbourDirection.Top, _grid[tile.X, tile.Y + 1]); if (tile.X + 1 > _gridSizeX) { tile.SetNeighbour(NeighbourDirection.TopRight, _grid[tile.X + 1, tile.Y + 1]); } if (tile.X > 0) { tile.SetNeighbour(NeighbourDirection.TopLeft, _grid[tile.X - 1, tile.Y + 1]); } } } }
public void SetNeighbour(NeighbourDirection direction, TerrainTile tile) { Neighbours[(int)direction] = tile; tile.Neighbours[(int)direction.Opposite()] = this; }
void Triangulate(NeighbourDirection direction, TerrainTile tile) { Vector3 center = tile.TileTopCenter; }