예제 #1
0
파일: TileGrid.cs 프로젝트: Creator13/BPW2
//		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]);
        }
예제 #2
0
파일: TileGrid.cs 프로젝트: Creator13/BPW2
        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;
            }
        }
예제 #3
0
파일: TileGrid.cs 프로젝트: Creator13/BPW2
 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));
 }
예제 #4
0
파일: TileGrid.cs 프로젝트: Creator13/BPW2
 public IEnumerable <BaseTile> GetSurroundingTiles(BaseTile tile)
 {
     // Shorthand that uses an existing tile to get the x and y.
     return(GetSurroundingTiles(tile.X, tile.Z));
 }