Example #1
0
        /// <summary>
        /// Refresh the button of the grid according to the board state
        /// </summary>
        public void UpdateGridValue()
        {
            int[,] gridBoard = board.GetBoard();
            int numPlayableTiles = 0;
            int numEmptyTiles    = 0;

            for (int y = 0; y < Constants.GRID_SIZE; y++)
            {
                for (int x = 0; x < Constants.GRID_SIZE; x++)
                {
                    //Set the playable tiles
                    if (board.IsPlayable(x, y, board.GetTurn()))
                    {
                        tiles[x, y].IsPlayable = true;
                        numPlayableTiles++;
                    }
                    else
                    {
                        tiles[x, y].IsPlayable = false;
                    }

                    if (gridBoard[x, y] == -1)
                    {
                        numEmptyTiles++;
                    }

                    tiles[x, y].State = gridBoard[x, y];
                }
            }

            updateImagePlayer();
            checkGameEnd(numPlayableTiles, numEmptyTiles);
        }
Example #2
0
 /// <summary>
 /// Show a transparent token when the mouse is over and if the tile is playable
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseEnter(MouseEventArgs e)
 {
     base.OnMouseEnter(e);
     if (isPlayable)
     {
         if (board.GetTurn())
         {
             Background = BRUSHES_TRANSPARENT[0];
         }
         else
         {
             Background = BRUSHES_TRANSPARENT[1];
         }
     }
 }
Example #3
0
 public Board(Board boardSource)
 {
     board       = (int[, ])boardSource.GetBoard().Clone();
     playerWhite = boardSource.PlayerWhite;
     playerBlack = boardSource.PlayerBlack;
     isWhite     = boardSource.GetTurn();
 }