Example #1
0
        public TicTacToe()
        {
            InitializeComponent();
            TicTacToeEngine engine = new TicTacToeEngine();

            PromptPlayer(engine.Board());
        }
        private void InitializeGameBoard()
        {
            gameEngine = new TicTacToeEngine();

            //Initialize the array, 2-Dimensions, 3 rows and 3 columns
            Button[,] gameBoard = new Button[3, 3];

            //Save the first row of tiles to the array
            gameBoard[0, 0] = gameTile1;
            gameBoard[0, 1] = gameTile2;
            gameBoard[0, 2] = gameTile3;

            //Save the second row of tiles
            gameBoard[1, 0] = gameTile4;
            gameBoard[1, 1] = gameTile5;
            gameBoard[1, 2] = gameTile6;

            //Save the third row of tiles
            gameBoard[2, 0] = gameTile7;
            gameBoard[2, 1] = gameTile8;
            gameBoard[2, 2] = gameTile9;

            //Assign the gameBoard to the gameEngine
            gameEngine.Initialize(gameBoard);
            UpdateUI();
        }