Example #1
0
        private void AddBombsToGrid()
        {
            //customならボムは入力された値を参照する
            if (SceneManager.GetActiveScene().name == "Game Custom")
            {
                bombCount = bombValue;
            }
            else
            {
                bombCount = Mathf.Min(bombCount, grid.Width * grid.Height);
            }

            for (int i = 0; i < bombCount; i++)
            {
                int x = UnityEngine.Random.Range(0, grid.Width);
                int y = UnityEngine.Random.Range(0, grid.Height);
                if (grid.TryGetTile(x, y, out _) == false)
                {
                    AddTileToGrid(x, y, bombTilePrefab);
                }
                else
                {
                    i--;
                    continue;
                }
            }
        }
        public static List <Tile> GetNeighbors(this TileGrid grid, int x, int y)
        {
            var result = new List <Tile>();

            foreach (var offset in neighborOffsets)
            {
                if (grid.TryGetTile(new Vector2Int(x, y) + offset, out var neighbor))
                {
                    result.Add(neighbor);
                }
            }

            return(result);
        }