/** * This method displays a message box asking the user if he wants to replay */ private void askGameReplay() { string[] gameDetails = r_GameManager.GetEndGameDetails(r_Col, r_Row); string message = ""; if (gameDetails[2].Equals(gameDetails[3])) { message = string.Format("{0} and {1} tied! with {2} points{3}{3}Would you like to play another game?", gameDetails[0], gameDetails[1], gameDetails[2], Environment.NewLine); } else { message = string.Format("The winner is {0} with {1} points!{4}The loser is {2} with {3} points{4}{4}Would you like to play another game?", gameDetails[0], gameDetails[2], gameDetails[1], gameDetails[3], Environment.NewLine); } if (MessageBox.Show(message, "Game Over!", MessageBoxButtons.YesNo) == DialogResult.Yes) { MemoryGameForm newGameForm = new MemoryGameForm(r_FirstPlayerName, r_SecondPlayerName, string.Format("{0} x {1}", r_Col, r_Row), r_IsHuman); this.Hide(); newGameForm.ShowDialog(); } this.Close(); Application.Exit(); }
/** * This method handles the start button events * Starts the game when used */ private void buttonStart_Click(object sender, EventArgs e) { this.Hide(); bool isHuman = textBoxSecondPlayer.Enabled; MemoryGameForm memoryGameForm = new MemoryGameForm(FirstPlayerName, SecondPlayerName, BoardSize, isHuman); memoryGameForm.ShowDialog(); this.Close(); }