Ejemplo n.º 1
0
        //Event handle for gameover in multiplayer game mode
        public void OnMultiplayerGameover(object sender, GameboardEventArgs e)
        {
            //if the event type is not gameover, return from this function
            if (e.GameboardEvent != GAME_EVENT.GAMEOVER)
            {
                return;
            }
            //cast the object that fire the event to multiplayer gameboard object
            MP_GameBoard gameBoard = sender as MP_GameBoard;

            //Show message of the player and id that has found the more mines
            MessageBox.Show("Player" + (gameBoard.Turn + 1).ToString() + " wins!", "Congratulations!");
            //Return to menu
            InitializeMenu();
        }
Ejemplo n.º 2
0
        //Event handler for gameover in single player game mode
        public void OnSinglePlayerGameover(object sender, GameboardEventArgs e)
        {
            //return from this function if the the event is not gameover
            if (e.GameboardEvent != GAME_EVENT.GAMEOVER)
            {
                return;
            }

            //Cast the object that fire event to single player gameboard object
            SP_GameBoard game = sender as SP_GameBoard;

            //if player has flagged all the flag, print congratulations message
            if (game.Mine == 0)
            {
                MessageBox.Show("Congratulations!");
            }
            //else print gameover message and return to menu
            else
            {
                MessageBox.Show("Gameover");
            }
            InitializeMenu();
        }