Exemplo n.º 1
0
//		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]);
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
 public IEnumerable <BaseTile> GetSurroundingTiles(BaseTile tile)
 {
     // Shorthand that uses an existing tile to get the x and y.
     return(GetSurroundingTiles(tile.X, tile.Z));
 }