Example #1
0
 public void SetPlayerDone()
 {
     if (PlayerID != GameController.ActivePlayer)
     {
         Debug.Log("TotalValueTracker_script: SetPlayerDone: Wrong Player " + PlayerID + "/" + GameController.ActivePlayer);
         return;
     }
     _uiManager.SetPlayerDone(PlayerID);
     _playerDoneScreen.SetActive(true);
     PlayerDone = true;
     TogglePlayer(false);
     Debug.Log("TotalValueTracker_script: SetPlayerDone: set player done ID - " + PlayerID);
     GameController.SwitchPlayer();
 }
Example #2
0
    IEnumerator DoDeterminePlay() //check for play
    {
        //yield return new WaitForSeconds(_globalDeck.MoveTime); //added delay to player switch in game controller
        float rWait = Random.Range(0.5f, 1f);

        yield return(new WaitForSeconds(rWait));

        if (AIBoard.PlayerDone)
        {
            yield break;
        }
        PlayCard_script tempCard = null;
        PlayCard_script drawCard = null;

        if (PlayerBoard.ActiveValue > _gameController.MaxValue) //player over max, AI should expect to win
        {
            AIBoard.SetPlayerDone();
            yield break;
        }

        //Check if random card gets AI close
        if (AIBoard.ActiveValue >= (_gameController.MaxValue - AIStates.EndOffset) && AIBoard.ActiveValue < _gameController.MaxValue && !PlayerBoard.PlayerDone)
        {
            Debug.Log("AIMananger_script: DoDeterminePlay: random card close to max, end round");
            AIBoard.SetPlayerDone();
            yield break;
        }

        //Check if out of cards
        if (_aiDeck.ActiveCards.Count <= 0)
        {
            if (AIBoard.ActiveValue > _gameController.MaxValue)
            {
                AIBoard.SetPlayerDone();
                yield break;
            }
            Debug.Log("AIMananger_script: DoDeterminePlay: out of cards, skip");
            //Sound effect or something
            _gameController.SwitchPlayer();
            yield break;
        }

        if (AIBoard.ActiveValue > _gameController.MaxValue) //Active value over max, check for minus card
        {
            tempCard = CheckOverMax();
            if (tempCard == null) //No card to get lower the max
            {
                AIBoard.SetPlayerDone();
            }
            else //found card play it
            {
                Debug.Log("AIMananger_script: DoDeterminePlay: Play card");
                _moveCard = StartCoroutine(MoveCard(tempCard));
                yield break;
            }
        }

        //check able to get 20
        Debug.Log("AIMananger_script: DoDeterminePlay: check for max");
        tempCard = CheckMaxValue();

        if (tempCard != null)
        {
            Debug.Log("AIMananger_script: DoDeterminePlay: Play card");
            _moveCard = StartCoroutine(MoveCard(tempCard));
            yield break;
        }

        //check close to max
        Debug.Log("AIMananger_script: DoDeterminePlay: check close to max");
        tempCard = CheckCloseMaxValue();

        if (tempCard != null)
        {
            Debug.Log("AIMananger_script: DoDeterminePlay: Play card");
            _moveCard = StartCoroutine(MoveCard(tempCard));
            yield break;
        }

        if (PlayerBoard.PlayerDone && (drawCard != null || tempCard != null)) //not possible to win try for a draw
        {
            int risk = Random.Range(0, 100);
            if (risk > AIStates.RiskValue) //AI will not risk a new card, goes for draw
            {
                Debug.Log("AIMananger_script: DoDeterminePlay: Play card");
                _moveCard = StartCoroutine(MoveCard(tempCard));
                yield break;
            }
        }

        //need to check max

        Debug.Log("AIMananger_script: DoDeterminePlay: no valid card found, skip");
        //Sound effect or something
        _gameController.SwitchPlayer();
    }