Example #1
0
    private void CommitMove()
    {
        _currentBoard.PlayMove(_nextMove);
        _boardVisualization.PlayMove(_nextMove.Location, _currentBoard.IsLeftPlayerMove ? TileState.White : TileState.Black);
        _nextMove = null;


        if (_currentBoard.IsGameOver)
        {
            var winner      = _currentBoard.IsLeftPlayerMove ? PlayerColours.White : PlayerColours.Black;
            var winnerIndex = _currentBoard.IsLeftPlayerMove ? 1 : 0;



            _boardVisualization.ShowWinner(_currentBoard.WinningLine, winner);

            _agents[winnerIndex].OnGameOverEvent(true);
            _agents[1 - winnerIndex].OnGameOverEvent(false);
            _lastGameTime = Time.time;
            return;
        }

        switch (PaintMode)
        {
        case PaintMode.PaintBlack:
            _currentBoard.ForcePlayerToPlay(PlayerColours.Black);
            break;

        case PaintMode.PaintWhite:
            _currentBoard.ForcePlayerToPlay(PlayerColours.White);
            break;
        }
        GetNextMoveFromAgent();

        _lastMoveTime = Time.time;
    }