private void buildBoard() { int x = r_SpaceBetweenButtons; int y = r_SpaceBetweenButtons; int width = 80; int hight = 80; for (int i = 0; i < r_NumOfRows; i++) { for (int j = 0; j < r_NumOfCols; j++) { ButtonOnBoard newButton = new ButtonOnBoard(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 += (int)(width + r_SpaceBetweenButtons); } y += (int)(hight + r_SpaceBetweenButtons); x = r_SpaceBetweenButtons; } this.Size = new Size(this.Size.Width, this.Size.Height + hight); m_GameModel.InitFirstOpponent(m_GameSettingsForm.FirstOpponentName); m_GameModel.InitSecondOpponent(m_GameSettingsForm.SecondOpponentName); m_CurrentOpponent = m_GameModel.OpponentX; setScoreLabels(); }
private void computerMove() { Point cellLocation = m_GameModel.ComputerMove(); ButtonOnBoard buttonToUpdate = r_ButtonsArray[cellLocation.X, cellLocation.Y]; buttonToUpdate.Enabled = false; buttonToUpdate.Text = m_CurrentOpponent.Charachter.ToString(); isGameOverOrNewTurn(); }
private void boardButton_click(object sender, EventArgs e) { ButtonOnBoard currentButton = sender as ButtonOnBoard; currentButton.Text = m_CurrentOpponent.Charachter.ToString(); currentButton.Enabled = false; m_GameModel.UpdateCell(currentButton.X, currentButton.Y, m_CurrentOpponent); if (!isGameOverOrNewTurn()) { if (m_IsAgainstComputer) { computerMove(); } } }