Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (state == 0)
        {
            return;
        }

        if (state == 1)
        {
            if (gameController.localPlayerN != whichPlayer)               // if is voting player...
            // can't vote for myself
            // extend judges
            {
                for (int i = 0; i < judges.Length; ++i)
                {
                    judges [i].extend();
                    judges [i].gameObject.GetComponent <UIScaleFader> ().scaleOutImmediately();
                }
            }
            state = 2;
        }

        if (state == 2)           // waiting for all other players to vote
        {
            if (gameController.currentTurnVotes >= gameController.nPlayers - 1)
            {
                gameController.updateVoteVariables();                  // <- here it is....
                gameController.currentTurnVotes = 0;
                interrogationButton.scaleOut();
                fader.fadeOutTask(this);
                state = 3;
            }
        }
        if (state == 3)
        {
            if (!isWaitingForTaskToComplete)               // when the fadeout has finished....

            // check if es un bingo!
            {
                bool esunbingo = false;
                //if (gameController.localPlayerN != whichPlayer) {

                esunbingo = true;
                if ((gameController.currentVote.Count > 1))
                {
                    Vote basevote = gameController.currentVote [0];
                    nbottles = basevote.amount;
                    for (int i = 1; i < gameController.currentVote.Count; ++i)
                    {
                        if (!basevote.Equals(gameController.currentVote [i]))
                        {
                            esunbingo = false;
                            break;
                        }
                    }
                }
                else
                {
                    esunbingo = false;
                }

                //} else
                //	esunbingo = false;

                if (esunbingo)
                {
                    state = 4;
                }
                else
                {
                    state = 6;
                }
            }
        }

        if (state == 4)
        {
            bingoActivity.SetActive(true);
            bingoController.startBingo(this, nbottles, gameController.localPlayerN != whichPlayer);
            for (int i = 0; i < GameController_mono.MaxPlayers; ++i)
            {
                if ((i != whichPlayer) && (gameController.playerPresent[i]))
                {
                    gameController.playerList [i].bottlesReceived [TicketScreenController_mono.ClearBottle] += nbottles;
                }
            }
            state = 5;
        }

        if (state == 5)
        {
            if (!isWaitingForTaskToComplete)
            {
                bingoActivity.SetActive(false);
                state = 6;
            }
        }

        if (state == 6)
        {
            // clear votelist
            gameController.currentVote = new List <Vote> ();
            state = 0;
            notifyFinishTask();                      // end task
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (state == 0)
        {
            return;
        }

        if (state == 1)
        {
            if (gameController.localPlayerN != whichPlayer)               // if is voting player...
            // can't vote for myself
            // extend judges
            {
                for (int i = 0; i < judges.Length; ++i)
                {
                    judges [i].extend();
                    judges [i].gameObject.GetComponent <UIScaleFader> ().scaleOutImmediately();
                }
            }
            state = 2;
        }

        if (state == 2)           // waiting for all other players to vote
        {
            if (gameController.currentTurnVotes >= gameController.nPlayers - 1)
            {
                gameController.updateVoteVariables();                  // <- here it is....

                gameController.currentTurnVotes = 0;
                interrogationButton.scaleOut();

                saveText = avanzarScaler_plur.GetComponent <Text> ().text;

                if (gameController.localPlayerN == gameController.playerTurn)
                {
                    int v = 0;
                    for (int i = 0; i < gameController.currentVote.Count; ++i)
                    {
                        v += gameController.currentVote [i].amount;
                    }

                    if (v == 1)
                    {
                        avanzarScaler_sing.scaleIn();
                    }
                    else
                    {
                        avanzarScaler_plur.GetComponent <Text> ().text = saveText.Replace("<1>", "" + v).Replace("<2>", "" + (v * 2));
                        avanzarScaler_plur.scaleIn();
                    }
                    state = 30;                     // espera hasta que se toque la pantalla
                }
                else
                {
                    if (checkLowestScore())
                    {
                        retrocedesScaler.scaleIn();
                        state = 30;                         // espera hasta que se toque la pantalla
                    }
                    else
                    {
                        fader.fadeOutTask(this);
                        state = 3;
                    }
                }
            }
        }
        if (state == 30)
        {
            if (Input.GetMouseButtonDown(0))
            {
                fader.fadeOutTask(this);
                state = 3;
            }
        }
        if (state == 3)
        {
            if (!isWaitingForTaskToComplete)               // when the fadeout has finished....


            {
                avanzarScaler_plur.GetComponent <Text> ().text = saveText;

                // check if es un bingo!
                bool esunbingo = false;
                //if (gameController.localPlayerN != whichPlayer) {

                esunbingo = true;                         // se dice sólo 'bingo'
                if ((gameController.currentVote.Count > 1))
                {
                    Vote basevote = gameController.currentVote [0];
                    nbottles = basevote.amount;
                    for (int i = 1; i < gameController.currentVote.Count; ++i)
                    {
                        if (!basevote.Equals(gameController.currentVote [i]))
                        {
                            esunbingo = false;
                            break;
                        }
                    }
                }
                else
                {
                    esunbingo = false;
                }

                //} else
                //	esunbingo = false;

                if (esunbingo)
                {
                    state = 4;
                }
                else
                {
                    state = 6;
                }
            }
        }

        if (state == 4)
        {
            bingoActivity.SetActive(true);
            bingoController.startBingo(this, nbottles, gameController.localPlayerN != whichPlayer);
            for (int i = 0; i < GameController.MaxPlayers; ++i)
            {
                if ((i != whichPlayer) && (gameController.playerPresent[i]))
                {
                    gameController.playerList [i].bottlesReceived [TicketScreenController.ClearBottle] += nbottles;
                }
            }
            state = 5;
        }

        if (state == 5)
        {
            if (!isWaitingForTaskToComplete)
            {
                bingoActivity.SetActive(false);
                state = 6;
            }
        }

        if (state == 6)
        {
            // clear votelist
            gameController.currentVote = new List <Vote> ();
            state = 7;
            gameController.synchCanvas.SetActive(true);
            gameController.synchNumber++;
            //gameController.networkAgent.broadcast ("synch:");
        }
        if (state == 7)
        {
            if (gameController.synchNumber >= gameController.nPlayers)
            {
                gameController.synchNumber = 0;
                state = 0;
                gameController.synchCanvas.SetActive(false);
                notifyFinishTask();
            }
        }
    }