private void ResetButtonMP_Click(object sender, EventArgs e)
        {
            Close();
            MemoryGameMultiplayer newMDIChild = new MemoryGameMultiplayer(); //opent het Memory spel in de mdi

            newMDIChild.MdiParent = Form.ActiveForm;                         // "MemoryGame" moet veranderd worden naar de uiteindelijke memorygame class
            newMDIChild.Show();
        }
示例#2
0
        /// <summary>
        /// Nadat de naam ingevuld is kan de speler door gaan naar het memory spel, Dit wordt hier opgestart wanneer er op de knop gedrukt wordt.
        /// </summary>
        private void ContinueToMPButton_Click(object sender, EventArgs e)
        {
            Player2Name = NamePlayer2TextBox.Text;
            Close();
            MemoryGameMultiplayer newMDIChild = new MemoryGameMultiplayer();

            newMDIChild.MdiParent = Form.ActiveForm;
            newMDIChild.Show();
        }
        /// <summary>
        /// Deze method controleerd of het spel gewonnen is.
        /// Indien dit het geval is dan wordt het spel beeindigt en de score opgeslagen.
        /// </summary>

        public void CheckForWinner()
        {
            foreach (string control in checkForWinner)
            {
                string[] checkForWinner_Array = checkForWinner.ToArray();
                if (checkForWinner_Array.Length == 8)
                {
                    if (player1score == player2score) // gelijkspel senario
                    {
                        MessageBox.Show("It's a tie! Clicking OK will automatically start a rematch.");
                        Close();
                        MemoryGameMultiplayer newMDIChild = new MemoryGameMultiplayer(); //Start de MemoryGameMultiplayer  op.
                        newMDIChild.MdiParent = Form.ActiveForm;                         // Set the Parent Form of the Child window
                        newMDIChild.Show();                                              // Display the new form.
                        player1score = 0;
                        player2score = 1;
                        goto Stap1;
                    }


                    if (player1score >= player2score)
                    {
                        string winningplayer = "";

                        string youwon = WhoWon(winningplayer);

                        MessageBox.Show("Congratulations, " + youwon + ", you won with " + player1score + " matches! Click OK to return to main menu.");
                        SavingClass.varNewScoreMP = Convert.ToString(player1score) + "                    " + SavingClass.varplayername + " (win)";
                        SavingClass.SaveleaderboardMP();
                        SavingClass.varNewScoreMP = Convert.ToString(player2score) + "                    " + Player2.Player2Name + " (loss)";
                        SavingClass.SaveleaderboardMP();
                        Close();
                        Menu newMDIChild = new Menu(); //Start de menu  op.
                                                       // Set the Parent Form of the Child window.
                        newMDIChild.MdiParent = Form.ActiveForm;
                        // Display the new form.
                        newMDIChild.Show();
                        goto Stap1;
                    }
                    if (player1score <= player2score)
                    {
                        string winningplayer = "";

                        string youwon = WhoWon(winningplayer); //String met de naam van winnende player

                        MessageBox.Show("Congratulations, " + youwon + ", you won with " + player2score + " matches! Click OK to return to main menu.");
                        SavingClass.varNewScoreMP = Convert.ToString(player2score) + "                    " + Player2.Player2Name + " (win)";
                        SavingClass.SaveleaderboardMP();
                        SavingClass.varNewScoreMP = Convert.ToString(player1score) + "                    " + SavingClass.varplayername + " (loss)";
                        SavingClass.SaveleaderboardMP();
                        Close();
                        Menu newMDIChild = new Menu();           //Start de menu  op.
                        newMDIChild.MdiParent = Form.ActiveForm; // Set the Parent Form of the Child window.
                        newMDIChild.Show();                      // Display the new form.
                        goto Stap1;
                    }
                }
            }


            Stap1 :;
        }