protected override void OnClosed(EventArgs e) { base.OnClosed(e); if (!m_AgainstFriend) { m_TextboxSecondPlayer.Text = "Computer"; } this.Visible = false; int rows = m_ButtonBoardSize.Text[0] - '0'; int columns = m_ButtonBoardSize.Text[2] - '0'; MainGame mainGame = new MainGame(columns, rows, m_TextboxFirstPlayer.Text, m_TextboxSecondPlayer.Text); mainGame.ShowDialog(); }
private void m_ButtonCard_Click(object sender, EventArgs e) { CardButton card = sender as CardButton; if (m_ButtonEnable == true && card.Text == string.Empty && m_CurrentPlayer != "Computer") { OpenCard(card); gameManager.Move(card.ButtonIndex); this.Refresh(); } if (m_CurrentPlayer == "Computer") { System.Threading.Thread.Sleep(500); OpenCard(card); gameManager.Move(card.ButtonIndex); this.Refresh(); System.Threading.Thread.Sleep(500); } if (gameManager.FirstMove) { m_FirstCard = card; if (m_CurrentPlayer == "Computer") { System.Threading.Thread.Sleep(1000); ComputerTurn(); } } else { m_ButtonEnable = false; m_SecondCard = card; if (gameManager.WonRound) { UpdatePoints(m_CurrentPlayer); if (m_CurrentPlayer == "Computer" && !gameManager.GameFinished) { ComputerTurn(); } } else { System.Threading.Thread.Sleep(2000); SwitchPlayers(); CloseCards(); if (m_CurrentPlayer == "Computer") { ComputerTurn(); } } } if (gameManager.GameFinished) { result = MessageBox.Show(string.Format("{0}\n\n Would you like to play again?", GetResultLine()), "Game Result", MessageBoxButtons.YesNo); if (result == DialogResult.No) { this.Close(); } else if (result == DialogResult.Yes) { this.Visible = false; MainGame newGame = new MainGame(m_Columns, m_Rows, m_FirstPlayerName, m_SecondPlayerName); newGame.ShowDialog(); } } }