Example #1
0
 public static void ClearTiles(this Tilemap tilemap, Vector3Int[] positions)
 {
     for (int i = 0; i < positions.Length; i++)
     {
         tilemap.ClearTile(positions[i]);
     }
 }
Example #2
0
        public int this[int col, int row]
        {
            get { return(_grid[col + row * Columns]); }
            set
            {
                if (value < 0 || value > Phases)
                {
                    throw new ArgumentOutOfRangeException();
                }

                int index = col + row * Columns;
                if (_grid[index] == value)
                {
                    return;
                }

                _grid[index] = value;

                if (value > 0)
                {
                    _tiles.SetTile(col, row, _blockImage, _blockSwatches[value - 1]);
                }
                else
                {
                    _tiles.ClearTile(col, row);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Set a single tile in a tilemap based on a collision grid.
        /// </summary>
        /// <param name="map">The tilemap to set tiles in.</param>
        /// <param name="grid">The grid to get tile data from.</param>
        /// <param name="x">The column of the tile to set.</param>
        /// <param name="y">The row of the tile to set.</param>
        public static void SetTile(Tilemap map, IGrid <bool> grid, int x, int y)
        {
            if (!grid[x, y])
            {
                map.ClearTile(x, y);
                return;
            }

            int index = 0;

            if (grid.CheckCellSafely(x, y - 1))
            {
                index += 1;
            }
            if (grid.CheckCellSafely(x + 1, y))
            {
                index += 2;
            }
            if (grid.CheckCellSafely(x, y + 1))
            {
                index += 4;
            }
            if (grid.CheckCellSafely(x - 1, y))
            {
                index += 8;
            }

            map.SetTile(x, y, index);
        }
Example #4
0
 /// <summary>
 /// Disable a fruit. Collision doesn't need to be cleared as it's overridden by worm.
 /// </summary>
 /// <param name="x">Horizontal position</param>
 /// <param name="y">Vertical position</param>
 public void Disable(int x, int y)
 {
     tilemap.ClearTile(x, y);
 }