Ejemplo n.º 1
0
        private void graphicBoardCell_Click(object sender, EventArgs e)
        {
            GraphicBoardCell currentBoardCell = sender as GraphicBoardCell;

            if (currentBoardCell != null && currentBoardCell.Enabled)
            {
                PlayerMove chosenMove = new PlayerMove(currentBoardCell.Row, currentBoardCell.Column);
                r_GameLogic.UpdateGamestate(chosenMove);
                clearPossibleMoves();
                r_GameLogic.CurrentGameState.ChangePlayerTurn();
                r_GameLogic.ChangeToNextPlayerWithLegalMoves();

                makeComputerMoveIfNeeded();

                if (!r_GameLogic.CurrentGameState.IsGameOver)
                {
                    this.Text = getCurrentGameTitle();
                    showPossibleMoves();
                }
                else
                {
                    if (!r_GameLogic.IsBoardFull())
                    {
                        MessageBox.Show("There are no possible moves left for either player. Press OK to see the final score");
                    }

                    this.Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void buildBoardCells()
        {
            GraphicBoardCell.eBoardCellType newCellType;

            for (int i = 0; i < r_BoardSize; i++)
            {
                for (int j = 0; j < r_BoardSize; j++)
                {
                    newCellType                = getGraphicBoardCellType(i, j);
                    r_BoardMatrix[i, j]        = new GraphicBoardCell(i, j, k_BoardCellWidth, k_BoardCellHeight, newCellType);
                    r_BoardMatrix[i, j].Left   = j * k_BoardCellWidth;
                    r_BoardMatrix[i, j].Top    = i * k_BoardCellHeight;
                    r_BoardMatrix[i, j].Click += graphicBoardCell_Click;
                    this.Controls.Add(r_BoardMatrix[i, j]);
                    r_GameLogic.CurrentGameState.GameBoard[i, j].OccupyingPlayerChanged += boardCell_OccupyingPlayerChanged;
                }
            }
        }