示例#1
0
        //creates a new blcok, and a grid out of blocks
        public void NewGame()
        {
            Minesweeper.Block blocky = new Minesweeper.Block(0, false, true);

            //make a grid with bombs and the numbers
            gridy = new Gridy(blocky, MyVariables.row, MyVariables.column);
            gridy.MineIt(MyVariables.mine);
            gridy.NumberIt();
            gridy.RemainingBombsCount();

            stopWatch.Start();
            dt.Start();
        }
示例#2
0
        private void FloodFill(int i, int j, Minesweeper.Block bl)
        {
            int ancho = gridy.theGrid.GetLength(0);
            int alto  = gridy.theGrid.GetLength(1);

            while (i >= 0 && i < ancho && j >= 0 && j < alto)
            {
                if (gridy.theGrid[i, j].Mine == 0 && gridy.theGrid[i, j].Hidden == true)
                {
                    gridy.theGrid[i, j].Hidden = false;
                    FloodFill(i, j, bl);
                    if (i >= 0 && i < ancho && j >= 0 && j < alto - 1)
                    {
                        FloodFill(i, j + 1, bl);
                        gridy.theGrid[i, j + 1].Hidden = false;
                    }
                    if (i >= 0 && i < ancho && j > 0 && j < alto)
                    {
                        FloodFill(i, j - 1, bl);
                        gridy.theGrid[i, j - 1].Hidden = false;
                    }
                    if (i >= 0 && i < ancho - 1 && j >= 0 && j < alto)
                    {
                        FloodFill(i + 1, j, bl);
                        gridy.theGrid[i + 1, j].Hidden = false;
                    }
                    if (i > 0 && i < ancho && j >= 0 && j < alto)
                    {
                        FloodFill(i - 1, j, bl);
                        gridy.theGrid[i - 1, j].Hidden = false;
                    }

                    if (i > 0 && i < ancho && j > 0 && j < alto)
                    {
                        FloodFill(i - 1, j - 1, bl);
                        gridy.theGrid[i - 1, j - 1].Hidden = false;
                    }
                    if (i >= 0 && i < ancho - 1 && j >= 0 && j < alto - 1)
                    {
                        FloodFill(i + 1, j + 1, bl);
                        gridy.theGrid[i + 1, j + 1].Hidden = false;
                    }

                    if (i >= 0 && i < ancho - 1 && j > 0 && j < alto)
                    {
                        FloodFill(i + 1, j - 1, bl);
                        gridy.theGrid[i + 1, j - 1].Hidden = false;
                    }

                    if (i > 0 && i < ancho && j >= 0 && j < alto - 1)
                    {
                        FloodFill(i - 1, j + 1, bl);
                        gridy.theGrid[i - 1, j + 1].Hidden = false;
                    }
                }
                else
                {
                    return;
                }
            }
        }