Exemple #1
0
        private void DoneButtonClick(object sender, EventArgs e)
        {
            Game.AIDeployShips();
            MainGameForm mainGame = new MainGameForm();

            mainGame.Location = Location;
            mainGame.Show();
            Dispose();
        }
 private void OkButtonClick(object sender, EventArgs e)
 {
     // Check if the password matches.
     if ((Game.playerSwitch && Game.player1.Password == passwordTextBox.Text) ||
         (!Game.playerSwitch && Game.player2.Password == passwordTextBox.Text))
     {
         // Continue with the game.
         MainGameForm mainGameForm = new MainGameForm();
         mainGameForm.Location = Location;
         mainGameForm.Show();
         Dispose();
     }
     else
     {
         // Show a warning message box.
         MessageBox.Show("Try again, please.", "Battleships: Wrong password!");
         passwordTextBox.Text = "";
     }
 }
        private void DoneButtonClick(object sender, EventArgs e)
        {
            if (Game.gameMode)
            {
                Game.AIDeployShips();
                MainGameForm mainGame = new MainGameForm();
                mainGame.Location = Location;
                mainGame.Show();

                // Dispose does not trigger FormClosing event.
                Dispose();
            }
            else
            {
                if (Game.playerSwitch)
                {
                    Game.playerSwitch = !Game.playerSwitch;
                    MultiplayerSettingsForm multiplayerSettingsForm = new MultiplayerSettingsForm();
                    multiplayerSettingsForm.Location = Location;
                    multiplayerSettingsForm.Show();

                    // Dispose does not trigger FormClosing event.
                    Dispose();
                }
                else
                {
                    Game.playerSwitch = !Game.playerSwitch;
                    PasswordCheckForm passwordCheckForm = new PasswordCheckForm();
                    passwordCheckForm.Location = Location;
                    passwordCheckForm.Show();

                    // Dispose does not trigger FormClosing event.
                    Dispose();
                }
            }
        }