Ejemplo n.º 1
0
    IEnumerator GameLoop()
    {
        while (gameParticipatns.Count > 1)
        {
            //Debug.Log("It's " + curParticipant.participantName + "'s turn.");
            curParticipant.AnnouncePlayer();
            curParticipant.BeginTurn();



            if (curParticipant == PlayerController.instance)
            {
                bool playerTurn = true;

                while (playerTurn)
                {
                    //PlayerController.instance.PlayersTurn();
                    yield return(new WaitUntil(() => playerStepThrough == true));

                    playerStepThrough = false;

                    switch (PlayerController.instance.playerPAR)
                    {
                    case PlayerActionResult.Busted:
                        curPlayersToElim.Add(curParticipant);
                        playerTurn = false;
                        break;

                    case PlayerActionResult.DrawnToDeck:

                        break;

                    case PlayerActionResult.DrawnToHand:

                        break;

                    case PlayerActionResult.PlayedLetter:
                        playerTurn = false;
                        break;

                    case PlayerActionResult.PickOne:
                        PlayerController.instance.ChoosePlayer();
                        yield return(new WaitUntil(() => playerStepThrough == true));

                        playerStepThrough = false;
                        playerTurn        = false;
                        break;
                    }
                }
                advanceButton.SetActive(true);
                drawButton.SetActive(false);
            }
            else
            {
                yield return(new WaitUntil(() => stepThrough == true));

                stepThrough = false;

                curPAR = curParticipant.TryAction();

                while (curPAR != PlayerActionResult.PlayedLetter)
                {
                    //Debug.Log("action failed.");

                    if (curPAR == PlayerActionResult.Busted)
                    {
                        curPlayersToElim.Add(curParticipant);
                        break;
                        //EliminatePlayer(curParticipant);
                        //yield break;
                    }

                    yield return(new WaitUntil(() => stepThrough == true));

                    stepThrough = false;

                    curPAR = curParticipant.TryAction();
                }
            }

            yield return(new WaitUntil(() => stepThrough == true));

            stepThrough = false;

            for (int i = 0; i < curPlayersToElim.Count; i++)
            {
                EliminatePlayer(curPlayersToElim[i]);
                yield return(new WaitUntil(() => stepThrough == true));

                stepThrough = false;
            }

            curPlayersToElim.Clear();

            curParticipantID = (curParticipantID + 1) % gameParticipatns.Count;
            curParticipant   = gameParticipatns[curParticipantID];
        }

        ShowGameOverPanel(gameParticipatns[0].participantName + " won the game because all other players were eliminated.");
    }