Пример #1
0
    IEnumerator StartNewGame()
    {
        _uiManager.ToggleLoadingScreen(true);
        yield return(new WaitForSeconds(1f));

        LeftBoard.TogglePlayer(false);
        RightBoard.TogglePlayer(false);
        _uiManager.PreGameScreen.SetActive(false);
        _uiManager.GameBoardScreen.SetActive(true);
        LeftBoard.ResetValues(true);
        RightBoard.ResetValues(true);
        List <PlayCard_script> pcs = new List <PlayCard_script>();

        pcs.AddRange(LeftBoard.DiscardPile.GetComponentsInChildren <PlayCard_script>());
        pcs.AddRange(LeftBoard._mainCardBoard.GetComponentsInChildren <PlayCard_script>());
        pcs.AddRange(LeftBoard._handCardBoard.GetComponentsInChildren <PlayCard_script>());
        pcs.AddRange(RightBoard._mainCardBoard.GetComponentsInChildren <PlayCard_script>());
        pcs.AddRange(RightBoard._handCardBoard.GetComponentsInChildren <PlayCard_script>());
        foreach (PlayCard_script pc in pcs)
        {
            pc.DestroyCard();
        }
        //screen transition etc
        yield return(new WaitForSeconds(1f));

        GenerateDecks();
        yield return(new WaitForSeconds(1f));

        DetermingStartingPlayer();
        _uiManager.ToggleEndScreen(false, false);
        _uiManager.ResetUI();
        GameStage = 1;
        StartGame();
        _uiManager.ToggleLoadingScreen(false);
    }
Пример #2
0
    IEnumerator DoSwitchPlayer()
    {
        if (RoundDone)
        {
            Debug.Log("Round Over");
            //StopCoroutine(_switchPlayer);
            yield break;
        }

        LeftBoard.TogglePlayer(false);
        RightBoard.TogglePlayer(false);
        if (LeftBoard.PlayerDone && RightBoard.PlayerDone)
        {
            //CompareScore();
            StartCoroutine("CompareScore");
            yield break;
        }
        yield return(new WaitForSeconds(SwitchDelay));

        //Debug.Log("Do Switch Player");
        if (LeftBoard.PlayerDone && !RightBoard.PlayerDone)
        {
            ActivePlayer = 1;
        }
        else if (RightBoard.PlayerDone && !LeftBoard.PlayerDone)
        {
            ActivePlayer = 0;
        }
        else if ((LeftBoard.ActiveValue > MaxValue || RightBoard.ActiveValue > MaxValue))
        {
            RoundDone = true;
            //CompareScore();
            StartCoroutine("CompareScore");
            //StopCoroutine(_switchPlayer);
            yield break;
        }
        else
        {
            ActivePlayer = (ActivePlayer == 0) ? 1 : 0;
        }
        _uiManager.SwitchPlayer(ActivePlayer);
        _globalDeckManager.PlaceGlobalCard(ActivePlayer);
        yield return(new WaitForSeconds(_globalDeckManager.MoveTime));

        if (ActivePlayer == 0)
        {
            LeftBoard.TogglePlayer(true);
            RightBoard.TogglePlayer(false);
        }
        else
        {
            RightBoard.TogglePlayer(true);
            LeftBoard.TogglePlayer(false);
        }
        if (ActivePlayer == AiMananger.AIBoard.PlayerID)
        {
            AiMananger.DeterminPlay();
        }
    }