Exemplo n.º 1
0
        private void clickfield(object sender, EventArgs e) // when clicking on a mine field
        {
            if (!gameOver)
            {
                int x = ((Square)sender).x;
                int y = ((Square)sender).y;
                game.checkField(x, y);
                if (game.getBombsNear(x, y) == 0)
                {
                    game.uncoverBFS(x, y);
                }
            }
            int height = game.getMapHeight();
            int width  = game.getMapWidth();

            if (height * width - game.getUncoveredFields() == game.getBombsCount() + 1)  // win
            {
                MessageBox.Show("You won! Your game took " + game.getElapsedSeconds().ToString() + " seconds.");
                endGame();
                b_newgame.Show();
                uncoverMap();
            }
        }