Example #1
0
        //User play event from board control
        private void BoardCtrl_UserPlayEvent(PlayPosition playPos)
        {
            GameResult result = _gameController.UserPlay(playPos);

            //Show result
            ctrlDisplayBoard.displayResult(result);
            ctrlPlayers.showGameScore(result);

            //if 2nd player is a computer
            if (_gameController.gameType == GameType.Single && !result.GameOver)
            {
                //Introduce a delay bewteen first player play and computer play for smooth user experience
                Thread.Sleep(400);

                //DO 2nd computer play
                result = _gameController.DoComputerPlay();

                if (result.LastPlayedPosition != null)
                {
                    ctrlDisplayBoard.displayResult(result);
                    ctrlPlayers.showGameScore(result);
                }
            }
            //If game over then set board for next play
            if (result.GameOver)
            {
                result = _gameController.ClearBoard();
                ctrlDisplayBoard.displayResult(result);
                ctrlPlayers.showGameScore(result);
            }
        }