private void buildBoardGame() { int x = r_ButtonsSpaces; int y = r_ButtonsSpaces; int width = 75; int hight = 60; for (int i = 0; i < r_RowsNumber; i++) { for (int j = 0; j < r_ColsNumber; j++) { BoardButtons newButton = new BoardButtons(i, j); r_ButtonsArray[i, j] = newButton; newButton.Size = new Size(width, hight); newButton.Location = new Point(x, y); newButton.Click += new EventHandler(this.boardButton_click); this.Controls.Add(newButton); x += width + r_ButtonsSpaces; } y += hight + r_ButtonsSpaces; x = r_ButtonsSpaces; } this.Size = new Size(this.Size.Width, this.Size.Height + hight); m_GameMenegment.InitFirstPlayer(m_GameSettings.Player1Name); m_GameMenegment.InitSecondPlayer(m_GameSettings.ComputerOrPlayer2Name); m_CurrentPlayer = m_GameMenegment.Player1; setScore(); }
private void computerTurn() { Point locationOfCell = m_GameMenegment.ComputerMove(); BoardButtons changeThebutton = r_ButtonsArray[locationOfCell.X, locationOfCell.Y]; changeThebutton.Enabled = false; changeThebutton.Text = m_CurrentPlayer.Type.ToString(); endOrNewTurn(); }
private void boardButton_click(object sender, EventArgs e) { BoardButtons currentButton = sender as BoardButtons; currentButton.Text = m_CurrentPlayer.Type.ToString(); currentButton.Enabled = false; m_GameMenegment.CellChange(currentButton.X, currentButton.Y, m_CurrentPlayer); if (!endOrNewTurn()) { if (m_isPlayingAgainstComp) { computerTurn(); } } }