// Update is called once per frame
    void Update()
    {
        if (state == 0)           // stopped

        {
        }
        if (state == 100)           // waiting for fadeout
        {
            if (!isWaitingForTaskToComplete)
            {
                state = 101;
            }
        }
        if (state == 101)
        {
            emocionarioCanvas.SetActive(false);
            //notifyFinishTask ();

            state = 0;
        }
        if (state == 200)           //  waiting for text to disappear
        {
            if (descriptionFader.getFadeValue() == 0.0f)
            {
                descriptionText.text = nextText;
                descriptionFader.fadeIn();
                timer = 0.0f;
                state = 0;
            }
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (going)
     {
         if (remainingTime > 0.0f)
         {
             remainingTime -= Time.deltaTime;
             if (remainingTime <= 0.0f)
             {
                 if (fader != null)
                 {
                     if (fadeIn)
                     {
                         fader.fadeIn();
                     }
                     else
                     {
                         fader.fadeOut();
                     }
                 }
                 if (textFader != null)
                 {
                     if (fadeIn)
                     {
                         textFader.fadeIn();
                     }
                     else
                     {
                         textFader.fadeOut();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (state == 0)           // idling

        {
        }

        if (state == 1)
        {
            timer += Time.deltaTime;
            if (timer > 0.75f)
            {
                titleFader.fadeIn();
                state = 2;
                timer = 0;
            }
        }

        if (state == 2)
        {
            timer += Time.deltaTime;
            if (timer > 0.75f)
            {
                descrFader.fadeIn();
                state = 3;
            }
        }

        if (state == 3)           // delaying
        //timer += Time.deltaTime;
        {
            if (timer > 30f)
            {
                fader.fadeOutTask(this);
                state = 4;
            }

            if (Input.GetMouseButtonDown(0))
            {
                timer = 31f;
            }
        }

        if (state == 4)           // waiting for fadeout
        {
            if (!isWaitingForTaskToComplete)
            {
                notifyFinishTask();
                state = 0;
            }
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (state == 0)
        {
        }

        if (state == 1 || state == 2 || state == 3)
        {
            centerWheel.transform.Rotate(0, 0, angleSpeed);
            for (int i = 0; i < icons.Length; ++i)
            {
                icons [i].transform.Rotate(0, 0, -angleSpeed);
            }
            if (Input.GetMouseButtonDown(0))
            {
                timer = delay;
            }
        }

        if (state == 1)
        {
            timer += Time.deltaTime;
            if (timer > 0.75f)
            {
                titleFader.fadeIn();
                state = 2;
            }
        }

        if (state == 2)
        {
            timer += Time.deltaTime;
            if (timer > delay)
            {
                state = 3;
                fader.fadeOutTask(this);
            }
        }

        if (state == 3)
        {
            if (!isWaitingForTaskToComplete)
            {
                //waiter.bReturnValue = //
                notifyFinishTask();
                state = 0;
            }
        }
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (state == 0)           // idle

        {
        }
        if (state == 1)
        {
            bool newv = Version.newVersionAvailable();
            if (newv)
            {
                ++state;
            }
            else
            {
                mcRef.setActivityFinished();
            }
        }
        if (state == 2)
        {
            fader1.fadeIn();
            fader2.fadeIn();
            fader3.fadeIn();
            ++state;
        }
        if (state == 3)
        {
            if (Input.GetMouseButtonDown(0))
            {
                elapsedTime = 0.0f;
                fader1.fadeOut();
                fader2.fadeOut();
                fader3.fadeOut();
                ++state;
            }
        }
        if (state == 4)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 2.0f)
            {
                ++state;
            }
        }
        if (state == 5)
        {
            mcRef.setActivityFinished();
        }
    }
Exemplo n.º 6
0
 public void fadeIn()
 {
     if (textFader_N != null)
     {
         textFader_N.fadeIn();
     }
     if (imageFader_N != null)
     {
         imageFader_N.fadeOut();
     }
     if (iconFader_N != null)
     {
         iconFader_N.fadeOut();
     }
 }
Exemplo n.º 7
0
    public void connectToRoomButton()
    {
        //controlHub.masterController.network_initGame (roomToConnectTo);
        roomstatus = -1;
        //controlHub.masterController.network_joinGame (roomToConnectTo);
        controlHub.masterController.network_joinServer();
        controlHub.masterController.network_sendMessage("checkroom " + roomToConnectTo + "$" + " " + controlHub.masterController.localUserLogin + " ");
        treeViewObject.SetActive(false);
        currentRoom.gameObject.GetComponent <Text> ().text = classroomToConnectTo;
        currentRoom.fadeIn();
        inClassroom = true;
        macrostate  = INCLASSROOM;
        controlHub.masterController.localUserRoom      = roomToConnectTo;
        controlHub.masterController.localUserClassroom = classroomToConnectTo;

        state = 300;
    }
Exemplo n.º 8
0
    new void Update()
    {
        bool change = Utils.updateSoftVariable(ref sparkScale, sparkTargetScale, 30.0f);

        if (change)
        {
            spark1.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
            spark2.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
            spark3.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
        }

        if (state == QAControllerState.idle)
        {
            elapsedTime += Time.deltaTime;


            if (elapsedTime > initialDelay)
            {
                letterOutputSpeed = slowletterOutputSpeed;
                state             = QAControllerState.idle2;
            }
        }

        if (state == QAControllerState.idle2)
        {
            /* extract question and answers */

            ab            = qa.getNextBank();
            correctAnswer = qb.correntAnswer [currentQuestion];
            ab.rosetta    = rosetta;
            qb.rosetta    = rosetta;

            ab.reset();

            burn [currentQuestion].lightUp();

            question = qb.getNextString();

            state = QAControllerState.printingQuestion;

            questionLetterOutput = 0.0f;
        }

        if (state == QAControllerState.printingQuestion)
        {
            int letters = (int)questionLetterOutput;

            if (Input.GetMouseButtonDown(0))
            {
                letterOutputSpeed = fastletterOutputSpeed;
            }

            if ((letters > 2) && (letters < question.Length - 2))
            {
                questionText.text = "<color=" + color1 + ">" + question.Substring(0, letters) + "</color>" +
                                    "<color=" + color2 + ">" + question.Substring(letters, 1) + "</color>" +
                                    "<color=" + color3 + ">" + question.Substring(letters + 1, 1) + "</color>" +
                                    "<color=" + color4 + ">" + question.Substring(letters + 2, question.Length - 1 - letters - 2) +
                                    "</color>";
            }
            if (letters == question.Length)
            {
                questionText.text = question;
            }
            questionLetterOutput += letterOutputSpeed * Time.deltaTime;

            if (letters > question.Length - 1)
            {
                letters           = question.Length - 1;
                questionText.text = "" + question;
                state             = QAControllerState.waitingForAnswer;

                for (int i = 0; i < maxAnswers; ++i)
                {
                    answerGO [i] = null;
                }

                float yPos = YAdjust - (question.Length / QuestionLettersPerLine) * QuestionLineHeight;
                for (int i = 0; i < ab.nItems(); ++i)
                {
                    GameObject newAnswer;
                    newAnswer = Instantiate(QAnswerPrefab);
                    newAnswer.transform.SetParent(answerPanel.transform);
                    newAnswer.transform.localScale = Vector3.one;
                    newAnswer.GetComponent <RectTransform>().sizeDelta        = new Vector2(800, 45);
                    newAnswer.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
                    newAnswer.GetComponent <Text> ().alignment = TextAnchor.UpperCenter;
                    newAnswer.GetComponent <QAAnswer> ().initialize(yPos);
                    newAnswer.GetComponent <QAAnswer> ().answerNumber = i + 1;
                    int nLines;
                    newAnswer.GetComponent <QAAnswer> ().setText(StringUtils.chopLines(ab.getNextString(), 85, out nLines));
                    newAnswer.GetComponent <QAAnswer> ().setDelay(i * 0.3f);
                    yPos        -= (InterAnswerDistance + AnswerLineHeight * (nLines - 1));
                    answerGO [i] = newAnswer;
                }
            }
        }

        if (state == QAControllerState.waitingForAnswer)
        {
            bool waiting = true;
            for (int i = 0; i < ab.nItems(); i++)
            {
                if (answerGO [i].GetComponent <QAAnswer> ().state != QAAnswerState.idle)
                {
                    waiting = false;
                }
                else
                {
                    waiting = true;
                }
            }

            if (waiting)
            {
                for (int i = 0; i < ab.nItems(); i++)
                {
                    answerGO [i].GetComponent <QAAnswer> ().state = QAAnswerState.ready;
                    state = QAControllerState.waitingForAnswer2;
                }
            }
        }

        if (state == QAControllerState.waitingForAnswer2)
        {
        }

        if (state == QAControllerState.answered)
        {
            letterOutputSpeed = slowletterOutputSpeed;
            for (int i = 0; i < ab.nItems(); ++i)
            {
                if (answerGO [i].GetComponent <QAAnswer> ().answerNumber != selectedAnswer)
                {
                    answerGO [i].GetComponent <QAAnswer> ().dispose();
                }
                else
                {
                    answerGO [i].GetComponent <QAAnswer> ().blink(selectedAnswer == correctAnswer);
                    if (selectedAnswer == correctAnswer)
                    {
                        levelRef.playSound(hitSound);
                    }
                    else
                    {
                        levelRef.playSound(missSound);
                    }
                }
            }

            elapsedTime = 0.0f;
            state       = QAControllerState.preparingNextQuestion;
        }

        if (state == QAControllerState.preparingNextQuestion)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > postAnswerTimeOut)
            {
                elapsedTime = 0.0f;
                state       = QAControllerState.preparingNextQuestion2;
                if (selectedAnswer == correctAnswer)
                {
                    burn [currentQuestion].burstInFlames();
                }
                else
                {
                    ++nMisses;
                    if (nMisses > 1)
                    {
                        fader._wa_fadeOut(this);
                        keyChannel = -1;
                        // mark this flame for resurrection, please
                        string lvl           = ds.retrieveStringValue("CurrentLevelFlame");
                        int    FlameIndex    = ds.retrieveIntValue("CurrentFlameIndex");
                        string FlameName     = ds.retrieveStringValue("FlameResurrectionName" + lvl + FlameIndex);
                        string FlameLocation = ds.retrieveStringValue("FlameResurrectionLocation" + lvl + FlameIndex);
                        ds.storeIntValue("Flame" + (FlameIndex) + "Resurrect" + FlameLocation, 3);
                        ds.storeStringValue("Flame" + (FlameIndex) + "Resurrect" + FlameLocation, FlameName);
                        this.isWaitingForActionToComplete = true;
                        state = QAControllerState.exitting3;
                    }
                }
                if (currentQuestion == numQuestions - 1)
                {
                    //fader._wa_fadeOut (this);
                    //this.isWaitingForActionToComplete = true;
                    /* do the flower thing */
                    flowerRenderQuad.GetComponent <GameObjectFader> ().fadeIn();
                    flowerAnim.SetBool("open", true);
                    spark1Anim.SetBool("open", true);
                    spark2Anim.SetBool("open", true);
                    spark3Anim.SetBool("open", true);
                    levelRef.dipMusic(4);
                    levelRef.playSound(sparksSound);
                    sparkTargetScale = 60.0f;
                    elapsedTime      = 0.0f;
                    state            = QAControllerState.exitting1;
                }
            }
        }

        if (state == QAControllerState.preparingNextQuestion2)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > postAnswerTimeOut)
            {
                questionText.text = "";
                ++currentQuestion;
                state = QAControllerState.idle;
            }
        }

        if (state == QAControllerState.exitting1)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 5.6f)
            {
                fader.setFadeColor(1, 1, 1);
                fader._wa_fadeOut(this);
                keyImageFader.fadeIn();
                youGotAKeyTextFader.fadeIn();
                this.isWaitingForActionToComplete = true;
                state = QAControllerState.exitting2;
            }
        }

        if (state == QAControllerState.exitting2)
        {
            if (!isWaitingForActionToComplete)
            {
                levelRef.playSound(winSound);
                elapsedTime = 0.0f;
                state       = QAControllerState.exitting3;
            }
        }

        if (state == QAControllerState.exitting3)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 2.0f)
            {
                secondFader.setFadeValue(1.0f);
                secondFader.setFadeColor(0, 0, 0);
                secondFader._wa_fadeOut(this);
                this.isWaitingForActionToComplete = true;
                state = QAControllerState.exitting4;
            }
        }

        if (state == QAControllerState.exitting4)
        {
            string rLoc = mcRef.getStorage().retrieveStringValue("ReturnLocation");
            string lvl  = rLoc.Substring(0, 6);

            if (isWaitingForActionToComplete)
            {
            }
            else
            {
                switch (keyChannel)
                {
                case 0:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "RedKey", true);
                    break;

                case 1:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "OrangeKey", true);
                    break;

                case 2:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "BlueKey", true);
                    break;

                case 3:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "GreenKey", true);
                    break;

                case 4:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "YellowKey", true);
                    break;

                case 5:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "PurpleKey", true);
                    break;

                case 6:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "BrownKey", true);
                    break;
                }
                mcRef.getStorage().storeBoolValue("IsHUDCracked", false);                   // return HUD crack to non-crcked

                // increment number of keys
                string curLev = mcRef.getStorage().retrieveStringValue("CurrentLevel");
                int    n      = mcRef.getStorage().retrieveIntValue(curLev + "NumberOfKeys");
                ++n;
                mcRef.getStorage().storeIntValue(curLev + "NumberOfKeys", n);
                SceneManager.LoadScene(rLoc);
            }
        }
    }
    void Update()
    {
        if (state == 0)
        {
        }

        if (state == 1)
        {
        }

        if (state == 2)           // wait a little bit and fadeout
        {
            timer += Time.deltaTime;
            if (timer > 1.0f)
            {
                timer = 0.0f;
                state = 3;

                if (myTurn)
                {
                    //gameController.networkAgent.broadcast ("nschosenmask:" + chosenMask + ":");
                }

                gameController.synchNumber++;                 // sync other players
                //gameController.networkAgent.broadcast ("synch:");
                fader.fadeOut();
            }
        }

        if (state == 3)           // wait for all players to be ready
        {
            if (gameController.synchNumber >= gameController.nPlayers)
            {
                syncCanvas.SetActive(false);
                state = 4;
                fader.fadeIn();
                gameController.synchNumber = 0;                 // reset syncs
            }
        }

        if (state == 4)
        {
            if (myTurn)
            {
                resultMasks [chosenMask].fadeIn();
            }
            else
            {
                resultMasks [turnPlayerChosenMask].fadeIn();
                if (chosenMask == turnPlayerChosenMask)
                {
                    tickBlink.startBlinking();
                    flechaFader.fadeOut();
                    textFader.fadeIn();
                }
                else
                {
                    batsuBlink.startBlinking();
                }
            }
            state = 5;
        }

        if (state == 5)
        {
            if (Input.GetMouseButtonDown(0))
            {
                fader.fadeOutTask(this);
                state = 6;
            }
        }
        if (state == 6)
        {
            if (!isWaitingForTaskToComplete)
            {
                tickBlink.stopBlinking(false);
                batsuBlink.stopBlinking(false);
                notifyFinishTask();
            }
        }
    }
Exemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        if (state == 0)           // idling

        {
        }



        if (state == 1)           // delaying
        {
            timer += Time.deltaTime;
            if (timer > delay)
            {
                //current.fadeIn ();
                explosionAnim.SetTrigger("Explode");
                titleFader.fadeIn();
                //next.fadeOutTask (this);
                timer = 0.0f;
                state = 2;
            }
            if (Input.GetMouseButtonDown(0))
            {
                timer = delay;
            }
        }

        if (state == 2)
        {
            timer += Time.deltaTime;
            if (timer > 0.5f)
            {
                descrFader.fadeIn();
                timer = 0.0f;
                state = 3;
            }
        }

        if (state == 3)
        {
            timer += Time.deltaTime;
            if (timer > 0.5f)
            {
                state = 4;
            }
        }

        if (state == 4)           // waiting for xfade

        {
            if (!isWaitingForTaskToComplete)
            {
                timer = 0;
                state = 5;
            }
        }

        if (state == 5)           // another delay
        //timer += Time.deltaTime;
        {
            if (timer > 30f)
            {
                fader.fadeOutTask(this);
                state = 6;
            }
            if (Input.GetMouseButtonDown(0))
            {
                timer = 31f;
            }
        }


        if (state == 6)           // waiting for fadeout
        {
            if (!isWaitingForTaskToComplete)
            {
                state = 0;

                notifyFinishTask();
            }
        }
    }
Exemplo n.º 11
0
    void Update()
    {
        if (state == -1)           // idling
        {
            if (deferredAngle > -1.0f)
            {
                finishAngle = deferredAngle;
                T           = Mathf.Sqrt((2 * finishAngle) / angAccel);
                angle       = finishAngle - 0.5f * angAccel * (T)*(T);
                wheel.transform.localRotation = Quaternion.Euler(0, 0, -angle);
                deferredAngle = -2.0f;
                state         = 1;
            }
        }

        if (state == 0)           // idling

        {
        }

        if (state == 1)           // spinning the wheel
        // do a very simple wheel dynamics update
        //  (using a 2d rigid body would be overkill, I'm afraid)

        {
            if (timer < T)
            {
                angle  = finishAngle - 0.5f * angAccel * (T - timer) * (T - timer);
                timer += Time.deltaTime;
            }
            else
            {
                angle        = finishAngle;
                timer        = 0.0f;
                state        = 2;
                selectedItem = 4 - (int)Mathf.Floor((angle - Mathf.Floor(angle / 360.0f) * 360.0f) / 72.0f);
                if (MasterController_mono.ForceTest != -1)
                {
                    selectedItem = MasterController_mono.ForceTest;
                }
                //if (selectedItem == 0)
                //	selectedItem = 3;
                //if (selectedItem == 2)
                //selectedItem = 4;
                //selectedItem = masterController.testIncremento;
                //if(masterController.testIncremento != 3) masterController.testIncremento = (masterController.testIncremento + 1) % 5;
                mainGameController.tType = selectedItem;

                //if(selectedItem > 1)
                //				selectedItem = 1;
                gameController.selectedItem = selectedItem;

                wheelSelection.transform.Rotate(0, 0, -72.0f * selectedItem);
                wheelSelection.go();
            }

            clampedAngle = angle - Mathf.Floor(angle / (360.0f / 5.0f)) * (360.0f / 5.0f);

            if ((clampedAngle + 5.0f) < 16.0f)
            {
                arrow.transform.localRotation = Quaternion.Euler(0, 0, 6.0f * (clampedAngle + 5.0f));
            }
            else
            {
                arrow.transform.localRotation = Quaternion.Euler(0, 0, 0);
            }

            wheel.transform.localRotation = Quaternion.Euler(0, 0, -angle);
        }

        if (state == 2)           // small delay
        {
            timer += Time.deltaTime;
            if (timer > delay)
            {
                rouletteRig.retract();
                arrowRig.retract();
                timer = 0.0f;
                state = 3;
            }
        }

        if (state == 3)           // waiting for fadeout
        {
            timer += Time.deltaTime;
            if (timer > delay / 2)
            {
                titleText.text = rosetta.rosetta.retrieveString(textPrefix, selectedItem);
                testDescrText.GetComponent <Text> ().text = rosetta.rosetta.retrieveString(testDescrPrefix [selectedItem]);
                titleFader.fadeIn();
                testDescrText.fadeIn();
                bigIcon [selectedItem].extend();
                state = 4;
                if (answerAvailable)
                {
                    answerAvailable = false;
                    Debug.Log("<color=red>fadeOut línea 355</color>");
                    interrogationFader.fadeOut();
                    helpButtonScaler.scaleIn();
                }
            }
        }

        if (state == 4)           // waiting for network callback
        {
            if (mustFinish)
            {
                state = 6; neededVotes = 0;
            }
        }

        if (state == 6)           // waiting for other players to vote...
        {
            if (gameController.currentTurnVotes >= neededVotes)
            {
                gameController.updateVoteVariables();
                fader.fadeOutTask(this);
                botonaco.retract();
                titleFader.fadeOut();
                testDescrText.fadeOut();
                if ((selectedItem > 0) && (selectedItem < bigIcon.Length))
                {
                    bigIcon [selectedItem].retract();
                }
                for (int i = 0; i < judges.Length; ++i)
                {
                    judges [i].gameObject.GetComponent <UIAnimatedImage> ().reset();
                    judges [i].retract();
                }
                gameController.currentTurnVotes = 0;                 // reset votes count
                state = 10;
            }
        }

        if (state == 10)           // waiting for fadeout
        {
            if (!isWaitingForTaskToComplete)
            {
                state = 0;
                wheelSelection.transform.Rotate(0, 0, 72.0f * selectedItem);
                wheelSelection.reset();
                rouletteRig.extend();
                arrowRig.extend();
                answerAvailable = false;
                mustFinish      = false;
                interrogationFader.fadeIn();
                helpButtonScaler.scaleOut();
                notifyFinishTask();
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (state == 0)           // initial delay

        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > initialDelay)
            {
                flasher.go();
                state       = 1;
                elapsedTime = 0.0f;
            }
        }

        if (state == 1)           // flashing

        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 0.25f)
            {
                for (int i = 0; i < piece.Length; ++i)
                {
                    piece [i].go();
                }
                if ((aSource != null) && (breakSound != null))
                {
                    aSource.PlayOneShot(breakSound);
                }
                elapsedTime = 0.0f;
                ++state;
            }
        }

        if (state == 2)           // pieces separating
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.0f)
            {
                text1.fadeIn();
                text2.fadeIn();
                elapsedTime = 0.0f;
                ++state;
            }
        }

        if (state == 3)           // showing text
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.0f)
            {
                planetFader.fadeIn();
                planetScaler.go();
                elapsedTime = 0.0f;
                ++state;
            }
        }

        if (state == 4)           // showing planet, and final delay
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 6.0f)
            {
                fader.fadeOut();
                elapsedTime = 0.0f;
                ++state;
            }
        }

        if (state == 5)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 3.0f)
            {
                killLevel(1);
            }
        }
    }
Exemplo n.º 13
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            goBackCallback();
        }

        if (state0 == 0)           // idling

        {
            return;
        }

        // end of state0 == 0

        else if (state0 == 1)           // State 0: FlyGames logo

        {
            if (substate0 == 0)               // showing the logo

            {
            }

            if (substate0 == 2)
            {
                timer0 = 0.0f;

                fader.fadeIn();

                initialMenu.SetActive(true);
                rootMenu.SetActive(false);
                noMagicMenu.SetActive(false);
                goBackButton.enabled = false;
                instructionsButton.SetActive(true);

                state0    = 2;
                substate0 = 0;
            }
        }

        // end state0 == 1

        else if (state0 == 2)           // State 1: showing Title

        {
            if (substate0 == 0)
            {
                timer0 += Time.deltaTime;
                if (timer0 > TitleDelay)
                {
                    substate0 = 1;
                    whiteCover.fadeIn();                      // show enabled menu
                    timer0 = 0.0f;
                }
            }
            else if (substate0 == 1)                 // delay a bit

            {
                timer0 += Time.deltaTime;
                if (timer0 > 0.33f)
                {
                    substate0 = 4000;                     // wait for user input...
                    versionText.fadeIn();
                }
            }
            else if (substate0 == 4000)                 // waiting for user input via callbacks

            // do nothing

            {
            }
            else if (substate0 == 20)                 // initial menu
            {
                if (!isWaitingForTaskToComplete)
                {
                    initialMenu.SetActive(false);
                    goBackButton.enabled = true;

                    gameController.loadData();
                    gameController.localUserLogin = "";

                    substate0 = 300;
//					if (!gameController.getUserLogin ().Equals ("")) {
//						// send data to server
//						WWWForm wwwForm = new WWWForm ();
//						wwwForm.AddField ("email", gameController.localUserEMail);
//						wwwForm.AddField ("passwd", gameController.getUserPass ());
//						wwwForm.AddField ("app", "EmpLite");
//						loggedInUserTexttris.text = gameController.localUserEMail;
//
//						www = new WWW (//gameController.networkAgent.bootstrapData.loginServer + ":" + //gameController.networkAgent.bootstrapData.loginServerPort + Utils.CheckUserScript, wwwForm);
//						substate0 = 300; // wait for www to get result data
//					} else {
//						whiteCover.fadeIn ();
//						rootMenu.SetActive (true);
//						substate0 = 1;
//					}
                }
            }
            else if (substate0 == 30)                 // clicked on gift... wait for fadeout and start gallery activity
            {
                if (!isWaitingForTaskToComplete)
                {
                    state0 = 0;                     // idle this
                    masterController.startActivity = "Gallery";

                    notifyFinishTask();                      // return to parent task
                    buyButton.GetComponent <Button> ().interactable = false;
                }
            }
            else if (substate0 == 2)                 // register menu

            {
                if (isWaitingForTaskToComplete)
                {
                    return;
                }
                // disable root menu and enable registry menu
                rootMenu.SetActive(false);
                registroMenu.SetActive(true);
                instructionsButton.SetActive(false);
                goBackButton.enabled = true;
                whiteCover.fadeIn();
                substate0 = 3;
            }
            else if (substate0 == 4)                 // sign in menu

            {
                if (isWaitingForTaskToComplete)
                {
                    return;
                }
                // disable root menu and enable registry menu
                rootMenu.SetActive(false);
                loginIncorrectText.SetActive(false);
                serverUnreachableText.SetActive(false);
                instructionsButton.SetActive(false);
                signInMenu.SetActive(true);
                goBackButton.enabled = true;
                whiteCover.fadeIn();
                substate0 = 5;
            }


            // new user submittal
            else if (substate0 == 100)               // waiting for www to return data from new user submittal
            {
                if (www.isDone)
                {
                    whiteCover.fadeOutTask(this);
                    timer0    = 0.0f;
                    substate0 = 0;
                    substate0 = 101;
                }
            }
            else if (substate0 == 101)                 // www has returned data, wait for fadeout
            {
                if (isWaitingForTaskToComplete)
                {
                    return;
                }
                registroMenu.SetActive(false);
                checkMailNotice.SetActive(true);
                goBackButton.enabled = false;
                whiteCover.fadeIn();
                substate0 = 102;
            }
            else if (substate0 == 102)
            {
                timer0 += Time.deltaTime;
                if ((timer0 > TitleDelay * 4) || Input.GetMouseButtonDown(0))
                {
                    whiteCover.fadeOutTask(this);
                    substate0 = 103;
                }
            }
            else if (substate0 == 103)                 // wait for fadeout

            {
                if (isWaitingForTaskToComplete)
                {
                    return;
                }
                timer0 = 0.0f;                 // go back to root menu

                fader.fadeIn();
                whiteCover.enabled = true;
                whiteCover.setFadeValue(1.0f);
                checkMailNotice.SetActive(false);
                diceButton.unpress();
                giftButton.unpress();
                initialMenu.SetActive(true);
                instructionsButton.SetActive(true);
                substate0 = 0;
            }


            //
            else if (substate0 == 200)               // waiting for www to return user id confirm data (manual input)
            {
                if (www.isDone)
                {
                    if (www.text.Equals(""))
                    {
                        serverUnreachableText.SetActive(true);
                        substate0 = 1;
                    }
                    else
                    {
                        string[] field = www.text.Split(':');

                        if (field.Length == 2)
                        {
                            int credits;
                            int.TryParse(field [1], out credits);
                            accountCredits = 10;                            //credits;
                            updateCreditsHUD();

                            if (accountCredits == -2)                               // special meaning
                            {
                                newMagicInput.text = "";
                                signInMenu.SetActive(false);
                                instructionsButton.SetActive(false);
                                noMagicMenu.SetActive(true);
                                noMoarMagicPanel.Start();
                                noMoarMagicPanel.scaleIn();
                                gameController.localUserEMail = loginUser.text;
                                gameController.setUserPass(loginPasswd.text);
                                //gameController.saveData ();
                                state0 = 0;
                                return;
                            }

                            int userUUID;
                            int.TryParse(field [0], out userUUID);
                            if (www.text.Equals(""))                                // server unreachable
                            {
                                serverUnreachableText.SetActive(true);
                                substate0 = 1;                                 // return to user input polling
                            }
                            else
                            {
                                if (userUUID > -1)
                                {
                                    loginIncorrectText.SetActive(false);
                                    serverUnreachableText.SetActive(false);
                                    whiteCover.fadeOutTask(this);
                                    timer0    = 0.0f;
                                    substate0 = 0;
                                    substate0 = 201;
                                    //gameController.setUserLogin ("" + userUUID);
                                    //gameController.localUserEMail = loginUser.text;
                                    //gameController.setUserPass (loginPasswd.text);
                                    //gameController.saveData ();
                                }
                                else
                                {
                                    loginIncorrectText.SetActive(true);
                                    substate0 = 1;                                     // return to user input polling
                                }
                            }
                        }
                        else
                        {
                            loginIncorrectText.SetActive(true);
                            substate0 = 1;                             // return to user input polling
                        }
                    }
                }
            }
            else if (substate0 == 201)                 // waiting for fadeout from substate0 = 200

//				if (isWaitingForTaskToComplete)
//					return;
            {
                rootMenu.SetActive(false);
                goBackButton.enabled = true;
                sessionMenu.SetActive(true);
                instructionsButton.SetActive(true);
//				loggedInUserText.text = gameController.localUserEMail;
//				loggedInUserAltText.text = gameController.localUserEMail;
//				loggedInUserTextbis.text = gameController.localUserEMail;
//				loggedInUserTexttris.text = gameController.localUserEMail;
                signInMenu.SetActive(false);
                whiteCover.fadeIn();
                substate0 = 1;
            }
            else if (substate0 == 300)                 // waiting for www to return user id confirm data (stored)
//				if (www.isDone) {
//
//					string[] field = www.text.Split (':');
//
//					if (field.Length == 2) {
//
//						int credits;
//						int.TryParse (field [1], out credits);
//						accountCredits = 10;//credits;
//						updateCreditsHUD ();
//
//						if (accountCredits == -2) { // special meaning
//							newMagicInput.text = "";
//							signInMenu.SetActive (false);
//							instructionsButton.SetActive (false);
//							noMagicMenu.SetActive (true);
//							whiteCover.fadeIn ();
//							noMoarMagicPanel.Start ();
//							noMoarMagicPanel.scaleIn ();
//							state0 = 0;
//							return;
//						}
//
//						int userUUID;
//						int.TryParse (field[0], out userUUID);
//						if (userUUID > -1) {
//							gameController.localUserLogin = field [0];
//							loginIncorrectText.SetActive (false);
//							serverUnreachableText.SetActive (false);
//							loggedInUserText.enabled = true;
//							loggedInUserText.text = gameController.localUserEMail;
//							loggedInUserTexttris.text = gameController.localUserEMail;
//							loggedInUserAltText.enabled = true;
//							loggedInUserAltText.text = gameController.localUserEMail;
//							rootMenu.SetActive (false);
//							instructionsButton.SetActive (false);
//							timer0 = 0.0f;
//							//substate0 = 0;
//							substate0 = 201;
//
//						} else {
//							//signInMenu.SetActive (true);
//							rootMenu.SetActive (true);
//							instructionsButton.SetActive (true);
//							whiteCover.fadeIn ();
//							//loginIncorrectText.SetActive (true);
//							substate0 = 1; // return to user input polling
//						}
//
//					} else {
//						//signInMenu.SetActive (true);
//						rootMenu.SetActive (true);
//						instructionsButton.SetActive (true);
//						whiteCover.fadeIn ();
//						//loginIncorrectText.SetActive (true);
//						substate0 = 1; // return to user input polling
//					}
//				}
            {
                substate0 = 201;
            }
            else if (substate0 == 500)                 // waiting for fadeout in order to go back to substate 0

            {
                if (isWaitingForTaskToComplete)
                {
                    return;
                }
                timer0 = TitleDelay;
                noMagicMenu.SetActive(false);
                loginIncorrectText.SetActive(false);
                serverUnreachableText.SetActive(false);
                signInMenu.SetActive(false);

                registroMenu.SetActive(false);

                goBackButton.enabled = true;
                fader.fadeIn();
                whiteCover.enabled = true;
                whiteCover.setFadeValue(1.0f);
                signInMenu.SetActive(false);
                sessionMenu.SetActive(false);
                rootMenu.SetActive(true);
                instructionsButton.SetActive(true);
                substate0 = 0;
            }
            else if (substate0 == 600)                 // waiting for fade to black in order to start a new game

            {
                if (isWaitingForTaskToComplete)
                {
                    return;
                }
                masterController.startActivity = "StartNewGame";
                diceButton.unpress();
                state0 = 0;
                notifyFinishTask();
                buyButton.GetComponent <Button> ().interactable = false;
            }
            else if (substate0 == 700)                 // waiting for fade to black in order to start a new game

            {
                if (isWaitingForTaskToComplete)
                {
                    return;
                }
                masterController.startActivity = "JoinNewGame";
                diceButton.unpress();
                state0 = 0;
                notifyFinishTask();
                buyButton.GetComponent <Button> ().interactable = false;
            }
            else if (substate0 == 900)                 // hit password recovery button
            {
                whiteCover.fadeOutTask(this);
                substate0 = 901;
            }
            else if (substate0 == 901)                 // wait for fadeout and show recovery message
            {
                if (!isWaitingForTaskToComplete)
                {
                    signInMenu.SetActive(false);
                    goBackButton.enabled = false;
                    recoveryMenu.SetActive(true);
                    goBackButton.enabled = true;
                    instructionsButton.SetActive(false);
                    whiteCover.fadeIn();
                    timer0    = 0.0f;
                    substate0 = 902;
                }
            }
            else if (substate0 == 902)
            {
                timer0 += Time.deltaTime;
                if (timer0 > 5.0f)
                {
                    whiteCover.fadeOutTask(this);
                    substate0 = 903;
                }
                if (Input.GetMouseButton(0))
                {
                    timer0 = 5.0f;
                }
            }
            else if (substate0 == 903)
            {
                if (!isWaitingForTaskToComplete)
                {
                    recoveryMenu.SetActive(false);
                    rootMenu.SetActive(true);
                    instructionsButton.SetActive(true);
                    goBackButton.enabled = true;
                    whiteCover.fadeIn();
                    substate0 = 4000;                     // wait for events...
                }
            }



            //
            else if (substate0 == 3000)               // continue game
            {
                fader.fadeOutTask(this);
                substate0 = 3001;
            }
            else if (substate0 == 3001)
            {
                if (!isWaitingForTaskToComplete)
                {
                    masterController.startActivity = "ContinueGame";
                    notifyFinishTask();
                    buyButton.GetComponent <Button> ().interactable = false;
                }
            }


            //
            else if (substate0 == 8000)
            {
                whiteCover.fadeOutTask(this);
                substate0 = 8001;
            }
            else if (substate0 == 8001)
            {
                if (!isWaitingForTaskToComplete)
                {
                    rootMenu.SetActive(false);
                    sessionMenu.SetActive(false);
                    initialMenu.SetActive(true);
                    instructionsButton.SetActive(true);
                    goBackButton.enabled = false;
                    state0    = 2;                  // go back to gift/dice state
                    substate0 = 1;
                    giftButton.unpress();
                    diceButton.unpress();
                    whiteCover.fadeIn();
                }
            }
        }
    }
Exemplo n.º 14
0
 public void fadeIn()
 {
     buttonImage.fadeOut();
     buttonText.fadeIn();
 }
Exemplo n.º 15
0
 public void showNPlayersInRoom()
 {
     connectedSabios_Text.fadeIn();
     connectedSabiosValue_Text.fadeIn();
 }
Exemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        if (timer2 > 0.0f)
        {
            timer2 -= Time.deltaTime;
            if (timer2 < 0.0f)
            {
                timer2 = 0.0f;
                titleImage.fadeIn();
            }
        }


        if (state == 0)         // idling
        {
            return;             // do no more, know no more
        }

        if (state == 1)           // show title
        {
            titleObject.SetActive(true);
            signInMenu.SetActive(false);
            searchGameMenu.SetActive(false);
            titleImage.fadeOut();
            controlHub.touchableThingsController.CanTouch(true);
            state = 2;
            buttonsObject.SetActive(true);
        }

        if (state == 2)           // small delay
        {
            timer += Time.deltaTime;
            if (timer > delay)
            {
                timer = 0.0f;
                state = 200;                 // check stored user&password
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            }
        }

        if (state == 3)           // make root menu appear
        {
            if (!isWaitingForTaskToComplete)
            {
                rootMenu.SetActive(true);
                instructionsButton.SetActive(true);
                timer2 = 0.0f;
                searchGameMenu.SetActive(false);
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().showTask(this);
                state = 4;
            }
        }

        if (state == 4)
        {
            if (!isWaitingForTaskToComplete)
            {
                state = 5;
            }
        }



        if (state == 20)           // obtaining list of countries from server

        {
            wwwForm = new WWWForm();
            wwwForm.AddField("country", "es");
            www   = new WWW(controlHub.networkAgent.bootstrapData.extraServer + ":" + controlHub.networkAgent.bootstrapData.extraServerPort + Utils.getCountryListScript, wwwForm);
            state = 21;
        }

        if (state == 21)           // wait for list to be pulled from server
        {
            if (www.isDone)
            {
                state             = 22;
                wwwErrorText.text = www.error;
            }
        }

        if (state == 22)
        {
        }

        if (state == 23)           // wait here...

        {
        }


        // login
        if (state == 80)           // deploying login interface

        {
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            backButton.fadeOut();
            state = 81;
        }
        if (state == 81)           // waiting for button panel to hide

        {
            if (!isWaitingForTaskToComplete)
            {
                rootMenu.SetActive(false);
                instructionsButton.SetActive(false);
                signInMenu.SetActive(true);
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                state = 82;
            }
        }



        /* submitting login data */
        if (state == 90)           // check credentials

        {
            wwwForm = new WWWForm();
            wwwForm.AddField("email", loginUser.text);
            wwwForm.AddField("passwd", loginPass.text);
            wwwForm.AddField("app", "Arr");
            www = new WWW(controlHub.networkAgent.bootstrapData.loginServer + ":" +
                          controlHub.networkAgent.bootstrapData.loginServerPort + Utils.CheckUserScript, wwwForm);
            state = 91;
        }
        if (state == 91)           // manual input of data
        {
            if (www.isDone)
            {
                string[] field = www.text.Split(':');

                if (field.Length == 2)
                {
                    int credits;
                    int.TryParse(field [1], out credits);
                    accountCredits = credits;


                    if (accountCredits == -2)                       // special meaning
                    {
                        newMagicInput.text = "";
                        signInMenu.SetActive(false);
                        instructionsButton.SetActive(false);
                        NoMoarMagicMenu.Start();
                        NoMoarMagicMenu.scaleIn();
                        controlHub.masterController.localUserEMail = loginUser.text;
                        controlHub.masterController.localUserPass  = loginPass.text;
                        controlHub.masterController.saveData();
                        state = 0;
                        return;
                    }

                    int userUUID;
                    int.TryParse(field[0], out userUUID);

                    if (userUUID > -1)
                    {
                        updateCreditsHUD();
                    }

                    if ((userUUID > -1))
                    {
                        loginIncorrectText.enabled    = false;
                        serverUnreachableText.enabled = false;

                        controlHub.masterController.localUserLogin = ("" + userUUID);
                        controlHub.masterController.localUserEMail = loginUser.text;
                        controlHub.masterController.localUserPass  = loginPass.text;
                        controlHub.masterController.saveData();

//						if (!(accountCredits > 0)) {
//							NoMoarCreditsMenu.scaleIn ();
//						}
                        state = 92;
                    }
                    else
                    {
                        loginIncorrectText.enabled = true;
                        loginIncorrectText.gameObject.GetComponent <UIAutoDelayFadeout> ().show();
                        state = 0;
                    }
                }
                else
                {
                    serverUnreachableText.enabled = true;
                    serverUnreachableText.gameObject.GetComponent <UIAutoDelayFadeout> ().show();
                    state = 0;
                }
            }
        }
        if (state == 92)           // User OK, retrieve Real name + nick from Arreit Server
        {
            wwwForm = new WWWForm();
            wwwForm.AddField("email", loginUser.text);
            wwwForm.AddField("passwd", loginPass.text);
            www   = new WWW(controlHub.networkAgent.bootstrapData.commandServer + ":" + controlHub.networkAgent.bootstrapData.commandServerPort + Utils.retrievePupilInfo, wwwForm);
            state = 93;
        }
        if (state == 93)
        {
            if (!www.isDone)
            {
                return;
            }
            string[] fields = www.text.Split(':');
            if (fields.Length > 1)
            {
                controlHub.masterController.userInfo.nickname = fields [1];
                controlHub.masterController.userInfo.realname = fields [0];
                loginIncorrectText.enabled    = false;
                serverUnreachableText.enabled = false;
                if (controlHub.masterController.userInfo.nickname.Equals(""))
                {
                    currentLogin.gameObject.GetComponent <Text> ().text = loginUser.text;
                }
                else
                {
                    nickname.text = controlHub.masterController.userInfo.nickname;
                    currentLogin.gameObject.GetComponent <Text> ().text = controlHub.masterController.userInfo.nickname;
                }
                realName.text = controlHub.masterController.userInfo.realname;
            }
            else
            {
                controlHub.masterController.userInfo.nickname       = "";
                controlHub.masterController.userInfo.realname       = "";
                currentLogin.gameObject.GetComponent <Text> ().text = loginUser.text;
            }
            //currentLogin.gameObject.GetComponent<Text> ().text = loginUser.text;
            isLogged = true;
            updateServerPupilInfo();
            controlHub.masterController.localUserEMail = loginUser.text;
            controlHub.masterController.localUserPass  = loginPass.text;
            controlHub.masterController.saveData();
            currentLogin.fadeIn();
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            state = 94;
            backButton.fadeIn();             // hide back button
        }
        if (state == 94)
        {
            if (!isWaitingForTaskToComplete)
            {
                signInMenu.SetActive(false);
                //if (accountCredits != -2) {
                searchGameMenu.SetActive(true);
                instructionsButton.SetActive(true);
                macrostate = SEARCHCLASSROOMMENU;
                //titleImage.fadeIn ();
                controlHub.uiController.updateNPlayersInRoom(0);
                buttonsObject.gameObject.GetComponent <UIDrawHide>().hideImmediate();
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                //}
                state = 0;
            }
        }



        /* go back to root menu */
        if (state == 100)           // go back to root menu
        {
            buttonsObject.gameObject.GetComponent <UIDrawHide>().hideTask(this);
            state = 101;
        }
        if (state == 101)
        {
            if (!isWaitingForTaskToComplete)
            {
                rootMenu.SetActive(true);
                instructionsButton.SetActive(true);
                signInMenu.SetActive(false);
                checkMailMenu.SetActive(false);
                createAccountMenu.SetActive(false);
                searchGameMenu.SetActive(false);
                macrostate = ROOTMENU;
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                state = 0;
            }
        }



        /* create new account menu */
        if (state == 120)
        {
            buttonsObject.gameObject.GetComponent <UIDrawHide>().hideTask(this);
            state = 121;
        }
        if (state == 121)
        {
            if (!isWaitingForTaskToComplete)
            {
                rootMenu.SetActive(false);
                instructionsButton.SetActive(false);
                newAccountPass1.text         = "";         // clear all four fields...
                newAccountPass2.text         = "";
                newAccountUser.text          = "";
                newAccountRealName.text      = "";
                newAccountNick.text          = "";
                passwordMismatchText.enabled = false;
                fieldsInvalidText.enabled    = false;
                userExistsText.enabled       = false;
                backButton.fadeOut();
                createAccountMenu.SetActive(true);
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                state = 0;
            }
        }



        /* create new account button pressed */
        if (state == 130)
        {
            if (!www.isDone)
            {
                return;
            }
            if (www.text.Equals("Exists"))
            {
                userExistsText.enabled = true;
                userExistsText.gameObject.GetComponent <UIAutoDelayFadeout> ().show();
                state = 0;
            }
            else
            {
                wwwForm = new WWWForm();                  // store extended info in Arreit Server
                wwwForm.AddField("email", newAccountUser.text);
                wwwForm.AddField("password", newAccountPass1.text);
                wwwForm.AddField("realname", newAccountRealName.text);
                wwwForm.AddField("nick", newAccountNick.text);
                www   = new WWW(controlHub.networkAgent.bootstrapData.commandServer + ":" + controlHub.networkAgent.bootstrapData.commandServerPort + Utils.preStorePupilInfo, wwwForm);
                state = 131;
            }
        }
        if (state == 131)
        {
            buttonsObject.gameObject.GetComponent <UIDrawHide>().hideTask(this);
            state = 132;
            backButton.fadeIn();
        }
        if (state == 132)
        {
            if (!isWaitingForTaskToComplete)
            {
                createAccountMenu.SetActive(false);
                checkMailMenu.SetActive(true);
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                state = 0;
            }
        }



        /* initial login data check */
        if (state == 200)           // check credentials

        {
            wwwForm = new WWWForm();
            wwwForm.AddField("email", controlHub.masterController.localUserEMail);
            wwwForm.AddField("passwd", controlHub.masterController.localUserPass);
            wwwForm.AddField("app", "Arr");
            www = new WWW(controlHub.networkAgent.bootstrapData.loginServer + ":" +
                          controlHub.networkAgent.bootstrapData.loginServerPort + Utils.CheckUserScript, wwwForm);
            state = 202;
        }
//		if (state == 201) {
//			if (canPlayWithZeroCredit != -1)
//				state = 202;
//		}
        if (state == 202)           // check stored
        {
            if (www.isDone)
            {
                string[] field = www.text.Split(':');

                if (field.Length == 2)
                {
                    int credits;
                    int.TryParse(field [1], out credits);
                    accountCredits = credits;


                    if (accountCredits == -2)                       // special meaning
                    {
                        newMagicInput.text = "";
                        signInMenu.SetActive(false);
                        instructionsButton.SetActive(false);
                        NoMoarMagicMenu.Start();
                        NoMoarMagicMenu.scaleIn();

                        state = 0;
                        return;
                    }

                    int userUUID;
                    int.TryParse(field[0], out userUUID);

                    if (userUUID > -1)
                    {
                        updateCreditsHUD();
                    }

                    if ((userUUID > -1))
                    {
//						if ((accountCredits == 0) && (canPlayWithZeroCredit == 0)) {
//							NoMoarCreditsMenu.scaleIn ();
//						}

                        controlHub.masterController.localUserLogin = ("" + userUUID);

                        state = 203;
                    }
                    else
                    {
                        state = 3;
                    }
                }
                else
                {
                    state = 3;
                }
            }
        }
        if (state == 203)           // stored login information ok
        {
            wwwForm = new WWWForm();
            wwwForm.AddField("email", controlHub.masterController.localUserEMail);
            wwwForm.AddField("passwd", controlHub.masterController.localUserPass);
            www   = new WWW(controlHub.networkAgent.bootstrapData.commandServer + ":" + controlHub.networkAgent.bootstrapData.commandServerPort + Utils.retrievePupilInfo, wwwForm);
            state = 204;
        }
        if (state == 204)
        {
            if (!www.isDone)
            {
                return;
            }
            string[] fields = www.text.Split(':');
            if (fields.Length > 1)
            {
                controlHub.masterController.userInfo.nickname = fields [1];
                controlHub.masterController.userInfo.realname = fields [0];
                loginIncorrectText.enabled    = false;
                serverUnreachableText.enabled = false;
                if (controlHub.masterController.userInfo.nickname.Equals(""))
                {
                    currentLogin.gameObject.GetComponent <Text> ().text = loginUser.text;
                }
                else
                {
                    nickname.text = controlHub.masterController.userInfo.nickname;
                    currentLogin.gameObject.GetComponent <Text> ().text = controlHub.masterController.userInfo.nickname;
                }
                realName.text = controlHub.masterController.userInfo.realname;
            }
            else
            {
                controlHub.masterController.userInfo.nickname       = "";
                controlHub.masterController.userInfo.realname       = "";
                currentLogin.gameObject.GetComponent <Text> ().text = loginUser.text;
            }
            loginIncorrectText.enabled    = false;
            serverUnreachableText.enabled = false;
            if (controlHub.masterController.userInfo.nickname.Equals(""))
            {
                currentLogin.gameObject.GetComponent <Text> ().text = controlHub.masterController.localUserEMail;
            }
            else
            {
                currentLogin.gameObject.GetComponent <Text> ().text = controlHub.masterController.userInfo.nickname;
            }
            currentLogin.fadeIn();
            isLogged = true;
            updateServerPupilInfo();
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            if (!controlHub.masterController.localUserRoom.Equals(""))                // stored room ok, connect to room
            //titleImage.fadeIn ();
            {
                roomToConnectTo      = controlHub.masterController.localUserRoom;
                classroomToConnectTo = controlHub.masterController.localUserClassroom;
                connectToRoomButton();
            }
            else               // stored room not ok, procceed to menu
            {
                state = 94;
                timer = 0.0f;
            }
        }



        /* go back to NO menu */
        if (state == 300)           // go back to root menu
        {
            buttonsObject.gameObject.GetComponent <UIDrawHide>().hideTask(this);
            state = 301;
        }
        if (state == 301)
        {
            if (!isWaitingForTaskToComplete)
            {
                // check user nickname
                wwwForm = new WWWForm();
                string mail = controlHub.masterController.localUserEMail;
                wwwForm.AddField("mail", mail);
                www   = new WWW(controlHub.networkAgent.bootstrapData.extraServer + ":" + controlHub.networkAgent.bootstrapData.extraServerPort + Utils.getUserNickname, wwwForm);
                state = 302;
            }
        }
        if (state == 302)           // get user nickname
        {
            if (www.isDone)
            {
                if (!www.text.Equals(""))
                {
                    string response = www.text;                     // user nickmane
                    if (!response.Equals(""))
                    {
                        controlHub.masterController.localUserNick           = www.text;
                        currentLogin.gameObject.GetComponent <Text> ().text = www.text;
                        isLogged = true;
                        //updateServerPupilInfo ();
                        controlHub.uiController.showNPlayersInRoom();
                    }
                    else
                    {
                        controlHub.masterController.localUserNick           = controlHub.masterController.userInfo.nickname;
                        currentLogin.gameObject.GetComponent <Text> ().text = controlHub.masterController.userInfo.nickname;
                    }
                    isLogged = true;
                    state    = 306;
                }
                else
                {
                    enterNicknameMenu.SetActive(true);
                    introduceNombreyNickAutofader.Start();
                    introduceNombreyNickAutofader.show();
                    nickNameButtonAutoConnect = true;
                    searchGameMenu.SetActive(false);
                    instructionsButton.SetActive(false);
                    macrostate = SEARCHCLASSROOMMENU;
                    buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                    state = 303;
                }
            }
        }
        if (state == 303)           // waiting for enterNicknameMenu.button to be hit...

        {
        }
        if (state == 304)
        {
            currentLogin.gameObject.GetComponent <Text> ().text = nickname.text;
            isLogged = true;
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            state = 305;
        }
        if (state == 305)
        {
            if (!isWaitingForTaskToComplete)
            {
                state = 306;
            }
        }
        if (state == 306)
        {
            rootMenu.SetActive(false);
            signInMenu.SetActive(false);
            checkMailMenu.SetActive(false);
            createAccountMenu.SetActive(false);
            searchGameMenu.SetActive(false);
            enterNicknameMenu.SetActive(false);
            instructionsButton.SetActive(false);
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
            titleImage.fadeIn();
            controlHub.gameController.playerGroup  = -1;
            controlHub.inertiaController.isEnabled = false;             // allow touch control of scene
            controlHub.touchableThingsController.CanTouch(true);
            //controlHub.touchableThingsController.cantTouchThis = true;
            controlHub.inertiaController.accelEnabled = false;
            controlHub.nexusController.startInteractionBlink();
            roomstatus = -1000;
            controlHub.masterController.network_sendMessage("checkroom " + roomToConnectTo + "$" + " " + controlHub.masterController.localUserLogin + " ");
            timer = 0.0f;
            state = 307;
        }
        if (state == 307)
        {
            if (roomstatus == 0)
            {
                roomNotReadyScaler.scaleOut();
                userRepeatedScaler.scaleOut();
                //controlHub.masterController.network_joinServer ();
                timer = 0.0f;
                state = 309;
            }
            else if (roomstatus == -2)               // player Repeated
            {
                timer += Time.deltaTime;
                if (timer > 2.0f)                   // prevent panel from popping in and then out
                {
                    userRepeatedScaler.scaleIn();
                    //controlHub.gameController.
                    state = 308;
                    timer = 0.0f;
                }
            }
            else if (roomstatus != -1000)               // Room not ready yet!
            {
                timer += Time.deltaTime;
                if (timer > 2.0f)                   // prevent panel from popping in and then out
                {
                    roomNotReadyScaler.scaleIn();
                    //controlHub.gameController.
                    state = 308;
                    timer = 0.0f;
                }
            }
        }
        if (state == 308)           // waiting for something to occur:

        {
            if (roomstatus == 0)
            {
                state = 307;
            }
            //timer += Time.deltaTime;
            // Instead of having timer increment automatically
            // it will be set to 5.0f by pressing the RETRY button
            if (timer > 5.0f)               // probe from time to time
            {
                roomstatus = -1000;
                controlHub.masterController.network_sendMessage("checkroom " + roomToConnectTo + "$" + " " + controlHub.masterController.localUserLogin + " ");
                timer = 0.0f;
            }
        }

        if (state == 309)
        {
            if (controlHub.gameController.randomId != -1)
            {
                controlHub.gameController.resumeGameResult = -1;
                controlHub.masterController.network_sendMessage("resumegame " + roomToConnectTo + "$" + " " + controlHub.gameController.randomId + " ");
                state = 310;                 // wait for response
            }
            else
            {
                controlHub.gameController.gameInited = true;
                controlHub.masterController.network_initGame(controlHub.masterController.localUserRoom);
                controlHub.masterController.network_sendMessage("listusers");
                controlHub.masterController.network_broadcast("refreshuserlist:");
                state = 311;
            }
        }

        if (state == 310)           // find out what is my group

        {
            if (controlHub.gameController.resumeGameResult == 0)
            {
                state = 311;
            }
        }

        if (state == 311)           // find out what is my randomId

        {
            controlHub.gameController.randomId = -1;
            controlHub.masterController.network_sendMessage("getroomrandomid " + roomToConnectTo);                      // ask for room id
            state = 312;
            timer = 0.0f;
        }
        if (state == 312)           // find out my group

        {
            if (controlHub.gameController.randomId != -1)
            {
                controlHub.masterController.network_sendMessage("mygroup");
                timer = 0.0f;
                state = 313;
            }
            else
            {
                timer += Time.deltaTime;
                if (timer > 1.0f)
                {
                    timer = 0.0f;
                    controlHub.masterController.network_sendMessage("getroomrandomid " + roomToConnectTo);                      // ask for room id
                }
            }
        }

        if (state == 313)
        {
            if (controlHub.gameController.playerGroup != -1)              // wait until we have a valid player group
            {
                updateServerPupilInfo();
                controlHub.masterController.network_sendMessage("listusers");
                controlHub.masterController.network_broadcast("refreshuserlist:");
                controlHub.inertiaController.isEnabled = true;                 // allow touch control of scene
                //controlHub.touchableThingsController.cantTouchThis = false;
                controlHub.touchableThingsController.CanTouch(false);
                controlHub.inertiaController.accelEnabled = true;
                //controlHub.masterController.network_broadcast ("panelreport:$", controlHub.gameController.playerGroup);
                controlHub.masterController.network_sendMessage("panelreport\n");
                controlHub.masterController.network_sendMessage("regionstatus\n");
                controlHub.masterController.network_sendMessage("labelstatus\n");
                controlHub.masterController.network_sendMessage("secretsreport\n");
                updateReps();
                showReps();
                controlHub.masterController.saveMoarData();
                state = 0;                 // stop this object
                timer = 0.0f;
            }
            else
            {
                timer += Time.deltaTime;
                if (timer > 1.0f)
                {
                    timer = 0.0f;
                    controlHub.masterController.network_sendMessage("mygroup");
                }
            }
        }


        /* create new account button pressed */
        if (state == 390)
        {
            state = 391;
            backButton.fadeIn();
            buttonsObject.gameObject.GetComponent <UIDrawHide>().hideTask(this);
        }
        if (state == 391)
        {
            if (!isWaitingForTaskToComplete)
            {
                createAccountMenu.SetActive(false);
                signInMenu.SetActive(false);
                checkMailMenu.SetActive(true);
                instructionsButton.SetActive(false);
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                state = 0;
            }
        }


        if (state == 500)           // hiding menu before showing update user info menu
        {
            backButton.fadeOut();
            //macrostate = SEARCHCLASSROOMMENU;
            nickname.text = controlHub.masterController.userInfo.nickname;
            realName.text = controlHub.masterController.userInfo.realname;
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            //enterNicknameMenu.SetActive (true);
            //		searchGameMenu.SetActive (false);
            //			buttonsObject.gameObject.GetComponent<UIDrawHide> ().show ();
            //			state = 303;
            state = 501;
        }
        if (state == 501)
        {
            if (!isWaitingForTaskToComplete)
            {
                enterNicknameMenu.SetActive(true);
                searchGameMenu.SetActive(false);
                instructionsButton.SetActive(false);
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                state = 303;
            }
        }

        if (state == 600)           // going back to search classroom menu
        {
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            state = 601;
        }
        if (state == 601)
        {
            if (!isWaitingForTaskToComplete)
            {
                enterNicknameMenu.SetActive(false);
                searchGameMenu.SetActive(true);
                instructionsButton.SetActive(true);
                macrostate = SEARCHCLASSROOMMENU;
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                if (nickNameButtonAutoConnect)
                {
                    nickNameButtonAutoConnect = false;
                    state = 300;
                }
                else
                {
                    state = 303;
                }
            }
        }

        if (state == 610)           // going back to no menu (WARNING duplicate???? maybe so)
        {
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            state = 611;
        }
        if (state == 611)
        {
            if (!isWaitingForTaskToComplete)
            {
                enterNicknameMenu.SetActive(false);
                buttonsObject.gameObject.GetComponent <UIDrawHide> ().show();
                state = 303;
            }
        }


        if (state == 666)           // nuking
        {
            timer -= Time.deltaTime;
            if (timer < 0.0f)
            {
                state = 667;
            }
        }
        if (state == 667)
        {
            controlHub.masterController.hardReset();
        }


        if (state == 1000)           // closing session

        {
            buttonsObject.gameObject.GetComponent <UIDrawHide> ().hideTask(this);
            controlHub.masterController.localUserLogin = "";
            controlHub.masterController.localUserEMail = "";
            controlHub.masterController.localUserPass  = "";
            controlHub.uiController.updateNPlayersInRoom(0);
            controlHub.uiController.hideNPlayersInRoom();
            controlHub.masterController.saveData();
            state = 1001;
        }
        else if (state == 1001)
        {
            state = 3;             // start root menu
        }



        // always chech this shit:
        if ((accountCredits == 0) && (canPlayWithZeroCredit == 0))
        {
            mustNukeAfterPurchase = true;
            NoMoarCreditsMenu.scaleIn();
            controlHub.inertiaController.isEnabled             = false;
            controlHub.touchableThingsController.cantTouchThis = true;
        }
    }
    public void debateDetails()
    {
        if (state != 0)
        {
            return;
        }

        if (touchIsMovement)
        {
            touchIsMovement = false;
            return;
        }



        if (stateWaitScroll != -1)           // show details

        {
            stateWaitScroll = -1;             // disabled

            if (page < numPages)
            {
                if (!debateChosen [page])
                {
                    tick.unpress();
                }
                else
                {
                    tick.press();
                }
            }

            tick.gameObject.GetComponent <UIFaderScript> ().fadeOut();


            left1.fadeOut();
            left2.fadeOut();
            right1.fadeOut();
            right2.fadeOut();
            //eligeText.SetActive (false);
            down1.fadeIn();
            down2.fadeIn();

            if (page < numPages)
            {
                debateDescription.GetComponent <Text> ().text = controlHub.masterController.dbinfo.items [debateIndices [page]].description;
            }
            debateDescription.fadeIn();
            descriptionBG.fadeOut();

            targetScale   = 0.45f;
            state         = 3;
            showingDetail = true;
        }
        else             // hide details

        {
            stateWaitScroll = 0;

            if (page != 0)
            {
                left1.fadeIn();
                left2.fadeIn();
            }
            if (page != (numPages - 1))
            {
                right1.fadeIn();
                right2.fadeIn();
            }
            //eligeText.SetActive (true);
            down1.fadeOut();
            down2.fadeOut();
            tick.gameObject.GetComponent <UIFaderScript> ().fadeIn();

            targetScale = 1.0f;
            state       = 3;


            debateDescription.fadeOut();
            descriptionBG.fadeIn();
        }
    }
Exemplo n.º 18
0
 public void showReps()
 {
     repsValue_Text.fadeIn();
     repsRValue_Text.fadeIn();
 }