Esempio n. 1
0
        /**
         * Clear all adjacent blank tiles. Recursive has limitations and cannot reveal mines for a huge board, queue system works.
         */
        private void RevealBlankTiles(Tile tile)
        {
            Stack <Tile> revealQueue = new Stack <Tile>();

            revealQueue.AddRange(tile.GetAdjacentTiles());

            Tile[] adjacentTiles;

            while (revealQueue.Count > 0)
            {
                tile = revealQueue.Pop();
                if (tile != null)
                {
                    if (!tile.Mine && !tile.Revealed && !tile.Flagged)
                    {
                        if (tile.AdjacentMines == 0)
                        {
                            adjacentTiles = tile.GetAdjacentTiles();
                            if (adjacentTiles != null)
                            {
                                revealQueue.AddRange(adjacentTiles);
                            }
                        }
                        tile.Revealed = true;
                    }
                }
            }
        }