private void buttonClicked(object sender, EventArgs e) { m_CurrentButtonClickedByPlayer = sender as MemoryGameButton; if (m_HasInternetConnection) { m_CurrentButtonClickedByPlayer.BackgroundImage = m_CurrentButtonClickedByPlayer.ButtonImage; } else { m_CurrentButtonClickedByPlayer.Text = m_CurrentButtonClickedByPlayer.Square.letter.ToString(); } m_CurrentButtonClickedByPlayer.FlatStyle = FlatStyle.Flat; m_CurrentButtonClickedByPlayer.FlatAppearance.BorderColor = m_IsFirstPlayerTurn ? m_FirstPlayerScore.BackColor : m_SecondPlayerScore.BackColor; m_CurrentButtonClickedByPlayer.FlatAppearance.BorderSize = 3; m_CurrentButtonClickedByPlayer.Refresh(); m_CurrentButtonClickedByPlayer.Click -= buttonClicked; changeKnownLettersForComputer(m_CurrentButtonClickedByPlayer); m_CurrentButtonClickedByPlayer.Refresh(); if (m_IsGuessNumberOne) { m_FirstButtonGeuss = m_CurrentButtonClickedByPlayer; m_IsGuessNumberOne = !m_IsGuessNumberOne; } else { m_SecondButtonGeuss = m_CurrentButtonClickedByPlayer; checkIfCurrectGuess(); } }
private void computerClick(MemoryGameButton i_ClickedButton) { if (m_HasInternetConnection) { i_ClickedButton.BackgroundImage = i_ClickedButton.ButtonImage; } else { i_ClickedButton.Text = i_ClickedButton.Square.letter.ToString(); } i_ClickedButton.FlatStyle = FlatStyle.Flat; i_ClickedButton.FlatAppearance.BorderColor = m_SecondPlayerScore.BackColor; i_ClickedButton.FlatAppearance.BorderSize = 3; i_ClickedButton.Refresh(); changeKnownLettersForComputer(i_ClickedButton); i_ClickedButton.Refresh(); }
private void checkIfCurrectGuess() { Player currentPlayer = m_IsFirstPlayerTurn ? GameManager.m_FirstPlayer : GameManager.m_SecondPlayer; if (GameManager.IsCorrectGuess(m_BoardGame.BoardGameWithSquares, m_FirstButtonGeuss.Name, m_SecondButtonGeuss.Name, currentPlayer)) { m_FirstButtonGeuss.BackColor = m_IsFirstPlayerTurn ? m_FirstPlayerScore.BackColor : m_SecondPlayerScore.BackColor; m_SecondButtonGeuss.BackColor = m_FirstButtonGeuss.BackColor; changeScoreText(); if (!m_IsFirstPlayerTurn && !GameManager.m_SecondPlayer.IsHumanPlayer) { Thread.Sleep(1000); } } else { Thread.Sleep(1500); m_IsFirstPlayerTurn = !m_IsFirstPlayerTurn; changeCurrentPlayerLabel(); doWhenIncorrectGuess(); } if (!m_IsComputerTurn) { m_IsGuessNumberOne = !m_IsGuessNumberOne; } if (GameManager.s_AvailbleMoves.Count == k_EmptyList) { gameFinishedDialog(); } else { m_FirstButtonGeuss.Refresh(); m_SecondButtonGeuss.Refresh(); m_CurrentPlayersTurn.Refresh(); checkForComputerTurn(); } }