// private IEnumerator TickWaterSpread() { // while (true) { // yield return GameManager.Instance.Paused ? null : new WaitForSeconds(waterSpreadTickTime); // if (GameManager.Instance.Paused) continue; // // Debug.Log("tick"); // // foreach (BaseTile tile in grid) { // if (tile is GroundTile gTile) { // gTile.TickWaterLevel(); // } // } // } // } private BaseTile CreateTile(int x, int z, BaseTile prefab) { // Generate new tile at current grid point grid[x, z] = Instantiate(prefab); // Make tile child of grid root grid[x, z].transform.parent = transform; // Initialize the object at its correct position grid[x, z].Initialize(x, z, this); return(grid[x, z]); }
public BaseTile ReplaceTile(BaseTile tile, BaseTile newTile) { try { // Create the requested new tile at the place of the old tile. BaseTile bt = CreateTile(tile.X, tile.Z, newTile); // Destroy the old tile Destroy(tile.gameObject); return(bt); } catch (IndexOutOfRangeException e) { Debug.LogError("Tile to be replaced was out of range: x:" + newTile.X + " z: " + newTile.Z); throw; } }
public IEnumerable <T> GetSurroundingTiles <T>(BaseTile tile) where T : BaseTile { // Shorthand that uses an existing tile to get the x and y. return(GetSurroundingTiles <T>(tile.X, tile.Z)); }
public IEnumerable <BaseTile> GetSurroundingTiles(BaseTile tile) { // Shorthand that uses an existing tile to get the x and y. return(GetSurroundingTiles(tile.X, tile.Z)); }