private void m_ButtonMatrix_Click(object sender, EventArgs e) { GameButton button = sender as GameButton; m_GameManager.CurrentGame.PlayTurn(button.Y, button.X, m_GameManager.CurrentGame.IsPlayer1Turn); updateButtonMatrix(); if (m_GameManager.CurrentGame.GameMode == Game.eGameMode.SinglePlayer) { m_GameManager.CurrentGame.PlayComputerTurn(); } showValidMoves(); updateTitle(); m_GameManager.GameOverMessage(); }
private void initializeButtonMatrix() { this.Height = ((FormSettings.BoardSize + 1) * k_ButtonSize) + ((FormSettings.BoardSize - 1) * k_ButtonSpacing); this.Width = ((FormSettings.BoardSize + 1) * k_ButtonSize) + ((FormSettings.BoardSize - 1) * k_ButtonSpacing); ButtonMatrix = new GameButton[FormSettings.BoardSize, FormSettings.BoardSize]; for (int x = 0; x < r_BoardDimension; x++) { for (int y = 0; y < r_BoardDimension; y++) { s_ButtonMatrix[x, y] = new GameButton(); s_ButtonMatrix[x, y].X = x; s_ButtonMatrix[x, y].Y = y; s_ButtonMatrix[x, y].Width = s_ButtonMatrix[x, y].Height = k_ButtonSize; s_ButtonMatrix[x, y].Location = new System.Drawing.Point((x * (k_ButtonSize + k_ButtonSpacing)) + k_ButtonSpacing + 5, (y * (k_ButtonSpacing + k_ButtonSize)) + k_ButtonSpacing + 5); s_ButtonMatrix[x, y].Click += m_ButtonMatrix_Click; s_ButtonMatrix[x, y].TabIndex = ((x + 1) * r_BoardDimension) + (y + 1); s_ButtonMatrix[x, y].Enabled = false; s_ButtonMatrix[x, y].BackColor = Color.Empty; this.Controls.Add(s_ButtonMatrix[x, y]); } } }