private void resetBoardForRematch() { hideAllImages(); m_FirstPlayer.ClearPoints(); m_SecondPlayer.ClearPoints(); m_CurrentPlayer = m_SecondPlayer; m_CurrentPlayer = m_CurrentPlayer.ChangePlayer(m_FirstPlayer, m_SecondPlayer); if (m_ComputerMemory != null) { m_ComputerMemory = new ComputerAI(); } m_GameBoard = new MemoryGameBoard(m_NumberOfRows, m_NumberOfColumns); m_GameBoard.FillBoard(); for (int i = 0; i < m_NumberOfRows; i++) { for (int j = 0; j < m_NumberOfColumns; j++) { m_GameBoard.BoardMatrix[i, j].CardVisabilityChanged += card_CardVisabilityChanged; m_CardsButtons[i, j].LogicMemoryGameCardReference = m_GameBoard.BoardMatrix[i, j]; m_CardsButtons[i, j].RowNumber = i; m_CardsButtons[i, j].ColumnNumber = j; m_CardsButtons[i, j].UpdateImageURL(); } } this.Update(); }
private void setDynamicControls() { m_FirstPlayerScoreLabel = new Label(); m_FirstPlayerScoreLabel.Text = m_FirstPlayer.Name + "'s score: " + m_FirstPlayer.Score; m_FirstPlayerScoreLabel.Left = this.Left + 8; m_FirstPlayerScoreLabel.BackColor = Color.LightGreen; m_FirstPlayerScoreLabel.AutoSize = true; this.Controls.Add(m_FirstPlayerScoreLabel); m_SecondPlayerScoreLabel = new Label(); m_SecondPlayerScoreLabel.Text = m_SecondPlayer.Name + "'s score: " + m_SecondPlayer.Score; m_SecondPlayerScoreLabel.Left = m_FirstPlayerScoreLabel.Left; m_SecondPlayerScoreLabel.BackColor = Color.MediumPurple; m_SecondPlayerScoreLabel.AutoSize = true; this.Controls.Add(m_SecondPlayerScoreLabel); m_CurrentPlayerTurnLabel = new Label(); m_CurrentPlayerTurnLabel.Text = "Current Player: " + m_FirstPlayer.Name; m_CurrentPlayerTurnLabel.Left = this.Left + 8; m_CurrentPlayerTurnLabel.BackColor = m_FirstPlayerScoreLabel.BackColor; m_CurrentPlayerTurnLabel.AutoSize = true; this.Controls.Add(m_CurrentPlayerTurnLabel); m_GameBoard.FillBoard(); setButtonsOnBoard(); m_CurrentPlayerTurnLabel.Top = m_CardsButtons[m_NumberOfRows - 1, 0].Bottom + 30; m_FirstPlayerScoreLabel.Top = m_CurrentPlayerTurnLabel.Bottom + 8; m_SecondPlayerScoreLabel.Top = m_FirstPlayerScoreLabel.Bottom + 8; this.Height = m_SecondPlayerScoreLabel.Bottom + 50; foreach (MemoryGameCard card in m_GameBoard.BoardMatrix) { card.CardVisabilityChanged += card_CardVisabilityChanged; } }
private void initializeComponent() { int formHight, formWidth; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingForm)); this.FormBorderStyle = FormBorderStyle.FixedDialog; this.Name = "BoardForm"; this.Text = "Memory Game"; this.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); this.MaximizeBox = false; this.MinimizeBox = false; this.StartPosition = FormStartPosition.CenterScreen; chooseFormSize(out formHight, out formWidth); this.ClientSize = new System.Drawing.Size(formWidth, formHight); m_FirstPlayerScoreLabel = new Label(); m_FirstPlayerScoreLabel.Text = m_FirstPlayer.Name + "'s score: " + m_FirstPlayer.Score; m_FirstPlayerScoreLabel.Left = this.Left + 8; m_FirstPlayerScoreLabel.BackColor = Color.LightGreen; m_FirstPlayerScoreLabel.AutoSize = true; this.Controls.Add(m_FirstPlayerScoreLabel); m_SecondPlayerScoreLabel = new Label(); m_SecondPlayerScoreLabel.Text = m_SecondPlayer.Name + "'s score: " + m_SecondPlayer.Score; m_SecondPlayerScoreLabel.Left = m_FirstPlayerScoreLabel.Left; m_SecondPlayerScoreLabel.BackColor = Color.MediumPurple; m_SecondPlayerScoreLabel.AutoSize = true; this.Controls.Add(m_SecondPlayerScoreLabel); m_CurrentPlayerTurnLabel = new Label(); m_CurrentPlayerTurnLabel.Text = "Current Player: " + m_FirstPlayer.Name; m_CurrentPlayerTurnLabel.Left = this.Left + 8; m_CurrentPlayerTurnLabel.BackColor = m_FirstPlayerScoreLabel.BackColor; m_CurrentPlayerTurnLabel.AutoSize = true; this.Controls.Add(m_CurrentPlayerTurnLabel); m_GameBoard.FillBoard(); setButtonsOnBoard(); m_CurrentPlayerTurnLabel.Top = m_CardsButtons[m_NumberOfRows - 1, 0].Bottom + 30; m_FirstPlayerScoreLabel.Top = m_CurrentPlayerTurnLabel.Bottom + 8; m_SecondPlayerScoreLabel.Top = m_FirstPlayerScoreLabel.Bottom + 8; foreach (MemoryGameCard card in m_GameBoard.BoardMatrix) { card.CardVisabilityChanged += card_CardVisabilityChanged; } }