Beispiel #1
0
        /// <summary>
        /// Returns if all sub layers do not contain a PlacedObject.
        /// </summary>
        /// <returns></returns>
        public bool IsCompletelyEmpty()
        {
            bool occupied = false;

            for (int i = 0; i < TileHelper.GetSubLayerSize(layer); i++)
            {
                occupied |= !IsEmpty(i);
            }

            return(!occupied);
        }
Beispiel #2
0
 /// <summary>
 /// Sets all gameobjects for a given layer to either enabled or disabled.
 /// </summary>
 /// <param name="layer"></param>
 /// <param name="enabled"></param>
 public void SetEnabled(TileLayer layer, bool enabled)
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             for (int i = 0; i < TileHelper.GetSubLayerSize(layer); i++)
             {
                 GetTileObject(layer, x, y).GetPlacedObject(i)?.gameObject.SetActive(enabled);
             }
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Create a new empty grid for a given layer.
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        private TileGrid CreateGrid(TileLayer layer)
        {
            TileGrid grid = new TileGrid {
                layer = layer
            };

            int gridSize = width * height;

            grid.tileObjectsGrid = new TileObject[gridSize];

            int subLayerSize = TileHelper.GetSubLayerSize(layer);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    grid.tileObjectsGrid[y * width + x] = new TileObject(this, layer, x, y, subLayerSize);
                }
            }

            return(grid);
        }