예제 #1
0
        private void MultiplayerButtonClick(object sender, EventArgs e)
        {
            // Set game to a multiplayer.
            Game.gameMode = false;
            Game.Initialize();

            // Initialize players.
            Game.player1 = new Player();
            Game.player2 = new Player();

            // Temporarily hide MainMenuForm and store its pointer.
            MultiplayerSettingsForm multiplayerSettingsForm = new MultiplayerSettingsForm();

            multiplayerSettingsForm.Location = Location;
            multiplayerSettingsForm.Show();
            Hide();
        }
        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();
                }
            }
        }