Пример #1
0
    // Use this for initialization
    public void Start()
    {
        timer = 0.0f;

        int i = Random.Range(0, stringsInBubble.Length);

        emotionText.rosetta = rosetta.rosetta;

        int k;

        int match = 0;

        for (k = 0; k < emotionText.nItems(); ++k)
        {
            if (emotionText.getString(k).Equals(stringsInBubble [i]))
            {
                match = k;
                break;
            }
        }

        if (k < emotionText.nItems())
        {
            icon.texture = emotionTexture [match];
            text.text    = emotionText.getString(match);
        }
        else
        {
            Destroy(this.gameObject);
        }
    }
    // Use this for initialization
    void Start()
    {
        elapsedTime          = 0.0f;
        rosetta              = GameObject.Find("Rosetta").GetComponent <Rosetta> ();
        tryAgainBank.rosetta = rosetta;
        tryAgainBank.reset();
        t1.text = tryAgainBank.getString(0);
        t2.text = tryAgainBank.getString(0);
        mc      = GameObject.Find("MasterController").GetComponent <MasterControllerScript> ();
        ds      = mc.getStorage();

        aSource = this.GetComponent <AudioSource> ();
    }
Пример #3
0
    // Use this for initialization
    public void Start()
    {
        state = 1;
        timer = 0.0f;
        textAndImage.Start();

        int    i       = Random.Range(0, stringsInBubble.Length);
        string laQueNo = stringsInBubble [i];

        emotionText.rosetta = rosetta;

        int k;

        int match = 0;

        for (k = 0; k < emotionText.nItems(); ++k)
        {
            string emotionTextk = emotionText.getString(k);
            if (emotionTextk.Equals(stringsInBubble [i]))
            {
                match = k;
                break;
            }
        }

        if (k < emotionText.nItems())
        {
            icon.texture = emotionTexture [match];
            text.text    = emotionText.getString(match);
        }
        else
        {
            Destroy(this.gameObject);
            Debug.Log("Emotion not found: " + laQueNo);
            icon.enabled = false;
            text.enabled = false;
        }
    }
Пример #4
0
    public void startNSVotation(Task w, int attitude)
    {
        //
        w.isWaitingForTaskToComplete = true;
        waiter         = w;
        angSpeed       = 0.0f;
        angle          = 0.0f;
        state          = 6;
        selectedItem   = gameController.selectedItem;
        titleText.text = rosetta.rosetta.retrieveString(textPrefix, selectedItem);
        titleFader.reset();
        testDescrText.reset();
        //titleFader.fadeIn ();
        bigIcon[selectedItem].extend();
        testVote = -1;

        attitudeStrings.rosetta = rosetta.rosetta;
        attitudeStrings.reset();
        voteText.text = attitudeStrings.getString(attitude);
        interrogationFader.Start();
        NSVoted = false; Debug.Log("<color=red>fadeOut línea 245</color>");
        interrogationFader.fadeOut();
        helpButtonScaler.scaleIn();
        rouletteRig.gameObject.SetActive(false);
        arrowRig.gameObject.SetActive(false);



        isNegativeSituation = true;
        neededVotes         = gameController.nPlayers - 1;
        titleFader.fadeOut();
        testDescrText.fadeOut();
        for (int i = 0; i < judges.Length; ++i)
        {
            judges [i].gameObject.GetComponent <UIAnimatedImage> ().reset();
            judges [i].extend();
        }

        if (attitude != gameController.NSPlayerAttitude)
        {
            botonaco.extend();
            fader.fadeIn();
        }
        else
        {
            fader.setFadeValue(1.0f);
            botonaco.retract();
        }
    }
Пример #5
0
    // network callbacks

    // called by master. Slaves are sitting at <1, 43>
    public void startNS(int attitude)
    {
        test.SetActive(false);
        mask.SetActive(true);
        butoncicoOK.reset();
        maskInterrogation.setFadeValue(0.0f);
        maskInterrogation.Start();
        if (attitude < (attitudeMasks.Length - 1))
        {
            maskInterrogation.fadeOut();
        }
        maskButton.enabled   = true;
        maskRawImage.texture = attitudeMasks [attitude];
        maskText.text        = maskStrings.getString(attitude);
    }
Пример #6
0
 public void showSecret(int id)
 {
     secretText.text = secretsSB.getString(id);
     secretReader.SetActive(true);
 }
    new void Update()
    {
        float relX;        //, relY;

        relX = chipCurrentPos.x / Screen.width;
        //relY = chipCurrentPos.y / Screen.height;
        string currentCard;

        currentCard = chip.GetComponent <ChipTrigger>().SayName();

        if (currentCard == "WhiteCard")
        {
            whiteHalo.GetComponent <Glower> ().glow();
            chipOnWhite = true;
        }
        else
        {
            whiteHalo.GetComponent <Glower> ().reglow();
            chipOnWhite = false;
        }
        if (currentCard == "BlackCard")
        {
            blackHalo.GetComponent <Glower> ().glow();
            chipOnBlack = true;
        }
        else
        {
            blackHalo.GetComponent <Glower> ().reglow();
            chipOnBlack = false;
        }

        /*if ((relX > 0.89f) && (relX <= 0.965f) &&!chipInserted) {
         *      whiteHalo.color = new Color (1, 1, 1, 1);
         *      chipOnWhite = true;
         * } else {
         *      whiteHalo.color = new Color (1, 1, 1, 0);
         *      chipOnWhite = false;
         * }
         *
         * if ((relX > 0.04f) && (relX <= 0.10f) &&!chipInserted) {
         *      blackHalo.color = new Color (1, 1, 1, 1);
         *      chipOnBlack = true;
         * } else {
         *      blackHalo.color = new Color (1, 1, 1, 0);
         *      chipOnBlack = false;
         * }*/

        if (chipPicked)
        {
            chip.transform.position = chipCurrentPos = chipRelaxPos + (Input.mousePosition - chipCapturePos);
        }
        else
        {
            if (chipCurrentPos != chipRelaxPos)
            {
                Vector3 dir = chipRelaxPos - chipCurrentPos;
                dir.Normalize();
                dir            *= 36.0f;
                chipCurrentPos += dir;
                // check if we overpast the target
                Vector3 checkDir = chipRelaxPos - chipCurrentPos;
                if (Vector3.Dot(checkDir, dir) < 0.0f)
                {
                    chipCurrentPos = chipRelaxPos;
                }
                chip.transform.position = chipCurrentPos;
            }
        }

        if (chipInserted)
        {
            chipScale -= 6.0f * Time.deltaTime;
            if (chipScale < 0.0f)
            {
                chipScale = 0.0f;
            }
            chip.transform.localScale = new Vector3(chipScale, chipScale, chipScale);
        }

        /* wait for touch */
        if (state == 0)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > smallDelay)
            {
                ++state;

                string id = mc.getStorage().retrieveStringValue("TVFerfuflosId");
                nTimes = mc.getStorage().retrieveIntValue("TVFerfuflosTimes" + id);
                mc.getStorage().storeIntValue("TVFerfuflosTimes" + id, nTimes + 1);
            }
            //if (Input.GetMouseButtonDown (0))
            //	++state;
        }
        if (state == 1)
        {
            int testStatus = 0;
            rollController.reset();
            do
            {
                diceResult      = Random.Range(3, 18 + 1);
                sabiaOIgnorante = Random.Range(0, 2);
                if (sabiaOIgnorante == 0)
                {
                    sabiaOIgnorante--;
                }
                if (sabiaOIgnorante == 1)
                {
                    cual = Random.Range(0, sabias [diceResult - 3].nItems());
                }
                else
                {
                    cual = Random.Range(0, ignorantes [diceResult - 3].nItems());
                }
                if (sabiaOIgnorante == 1)
                {
                    testStatus = mc.getStorage().retrieveIntValue("Ferfuflo" + diceResult + "+1" + cual);
                }
                else
                {
                    testStatus = mc.getStorage().retrieveIntValue("Ferfuflo" + diceResult + "-1" + cual);
                }
            } while(testStatus != 0);
            //thisBatchVariables.Add ("Ferfuflo" + diceResult + "" + sabiaOIgnorante + "" + cual);
            if (sabiaOIgnorante == 1)
            {
                thisBatchVariables.Add("Ferfuflo" + diceResult + "+1" + cual);
            }
            else
            {
                thisBatchVariables.Add("Ferfuflo" + diceResult + "-1" + cual);
            }
            rollController.play(diceResult);
            ++state;
        }

        if (state == 2)
        {
            if (rollController.resultReady)
            {
                ++state;
                transmission.text = transmissionBank.getString(rollController.rollResult);
                string sss = propositionBank.getString(rollController.rollResult);
                assertion.text = StringUtils.chopLines(sss, 30);
                if (sabiaOIgnorante == 1)
                {
                    lameAnswers = sabias [rollController.rollResult - 3];
                }
                else
                {
                    lameAnswers = ignorantes [rollController.rollResult - 3];
                }
                lameAnswers.rosetta = rosetta;
                lameAnswers.reset();
                //answer.text = StringUtils.chopLines(lameAnswers.getNextString (), 25);
                answer.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, 0));
                curtainOpenLeft();
                adsAnim.SetBool("whiteNoise", true);
                elapsedTime = 0.0f;
                //ads.transform.position = new Vector3 (0, 0, 10);
                // ACTIVAR LAS ??? Y EL OFFSET DE LA IMAGEN TVCRACKED
                TV.GetComponent <TVController>().ShowParticles();
            }
        }

        if (state == 3)
        {
            if (elapsedTime <= 0.35f)
            {
                elapsedTime += Time.deltaTime;
                if (elapsedTime >= 0.35f)
                {
                    ads.transform.position = new Vector3(0, -20, 10);
                }
            }
            if (currentCurtainPosition == targetCurtainPosition)
            {
                ++state;
            }
        }

        if (state == 4)
        {
            if (Input.GetMouseButtonDown(0))
            {
                opacity = 1.0f;
                ++state;
            }
        }

        if (state == 5)
        {
            opacity -= opacitySpeed * Time.deltaTime;
            if (opacity < 0.0f)
            {
                opacity           = 0.0f;
                answer.text       = StringUtils.chopLines(lameAnswers.getNextString(), 25);
                assertion.text    = "";
                transmission.text = "";
                TV.GetComponent <TVController> ().ChangeTexture();
                ++state;
            }

            assertion.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, opacity));
            transmission.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, opacity));
        }

        if (state == 6)
        {
            opacity += opacitySpeed * Time.deltaTime;
            if (opacity >= 1.0f)
            {
                opacity     = 1.0f;
                elapsedTime = 0.0f;
                answer.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, opacity));
                //opacity = 0.0f;
                //if (opacity >= 1.0f) {  QUIZAS SEA MEJOR OPCION
                if (Input.GetMouseButtonDown(0))
                {
                    opacity = 0.0f;
                    ++state;
                }
            }
            else
            {
                answer.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, opacity));
            }
        }

        if (state == 7)
        {
            opacity += 6.0f * Time.deltaTime;
            if (opacity > 1.0f)
            {
                opacity = 1.0f;
                ++state;
            }
            whiteCard.GetComponent <Image>().color  = new Color(1, 1, 1, opacity);
            blackCard.GetComponent <Image> ().color = new Color(1, 1, 1, opacity);
            chip.GetComponent <Image> ().color      = new Color(1, 1, 1, opacity);
        }


        if (state == 9)
        {
            if (amountRequired == (nTimes + 1))           // exit! trance
            {
                state = 10;
            }
            else
            {
                state = 12;                 // nos quedamos
            }
        }

        if (state == 10)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 3.0f)
            {
                if (batchCorrect())
                {
                    mc.getStorage().storeIntValue("TVBatchResult", 1);
                }
                else
                {
                    resetBatchFerfuflosAnswers();
                    mc.getStorage().storeIntValue("TVBatchResult", -1);
                }
                fader._wa_fadeOut(this);
                this.isWaitingForActionToComplete = true;
                ++state;
            }
        }

        if (state == 11)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }

            countFerfuflosAnswers();

            string returnLoc = mc.getStorage().retrieveStringValue("ReturnLocation");

            UnityEngine.SceneManagement.SceneManager.LoadScene(returnLoc);
        }

        if (state == 12)
        {
            opacity -= 6.0f * Time.deltaTime;
            if (opacity <= 0.0f)
            {
                opacity = 0.0f;
                ++state;
                rollController.resetAnimation();
            }
            answer.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, opacity));
            whiteCard.GetComponent <Image>().color  = new Color(1, 1, 1, opacity);
            blackCard.GetComponent <Image> ().color = new Color(1, 1, 1, opacity);
            chip.GetComponent <Image> ().color      = new Color(1, 1, 1, opacity);
        }

        if (state == 13)           // loop back
        {
            reset();

            state       = 0;
            elapsedTime = 0;
        }

        if (currentCurtainPosition < targetCurtainPosition)
        {
            currentCurtainPosition += curtainSpeed * Time.deltaTime;
            if (currentCurtainPosition > targetCurtainPosition)
            {
                currentCurtainPosition = targetCurtainPosition;
            }

            currentAlphaCurtain.transform.position = new Vector3(currentCurtainPosition,
                                                                 currentAlphaCurtain.transform.position.y,
                                                                 currentAlphaCurtain.transform.position.z);
        }

        if (currentCurtainPosition > targetCurtainPosition)
        {
            currentCurtainPosition -= curtainSpeed * Time.deltaTime;
            if (currentCurtainPosition < targetCurtainPosition)
            {
                currentCurtainPosition = targetCurtainPosition;
            }

            currentAlphaCurtain.transform.position = new Vector3(currentCurtainPosition,
                                                                 currentAlphaCurtain.transform.position.y,
                                                                 currentAlphaCurtain.transform.position.z);
        }
    }
Пример #8
0
    new void Update()
    {
        if (state == WordFightControllerState.delay0 && substate == -5)
        {
            cam._wa_warpToMarker(this, 4);
            substate = -4;
        }

        if (state == WordFightControllerState.delay0 && substate == -4)           // everything black

        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 2.6f)
            {
                elapsedTime  = 0.0f;
                substate     = -3;
                shadow.faded = false;
                hero.faded   = false;               // characters appear
            }
        }

        if (state == WordFightControllerState.delay0 && substate == -3)           // characters separate

        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.6f)
            {
                elapsedTime      = 0.0f;
                substate         = -2;
                shadow.displaced = false;
                hero.displaced   = false;
                cam._wa_moveToMarker(this, 3);
            }
        }

        if (state == WordFightControllerState.delay0 && substate == -2)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.6f)
            {
                elapsedTime = 0.0f;
                substate    = -1;
                shadow.setAnimation(0);
                hero.setAnimation(0);
            }
        }

        if (state == WordFightControllerState.delay0 && substate == -1)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.2f)
            {
                elapsedTime = 0.0f;
                substate    = 0;
                shadow.setAnimation(1);
                hero.setAnimation(1);
            }
        }

        if (state == WordFightControllerState.delay0 && substate == 0)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 0.4f)
            {
                if (tutorialMode)
                {
                    chispAlert._wa_alert(this, chispaStuff.getString(AHORAAPRENDERAS));
                    this.isWaitingForActionToComplete = true;
                }
                //shadow.setAnimation (0);
                //hero.setAnimation (0);
                ++substate;
                elapsedTime = 0.0f;
            }
        }

        if (state == WordFightControllerState.delay0 && substate == 1)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 0.2f)
            {
                substate = 0;
                state    = WordFightControllerState.delay;
                //cam.lerpSpeed = 1.6f;
                // CAMBIAR TIEMPO DEL ITWEEN ?
                //shadow.setAnimation (1);
                //hero.setAnimation (1);
            }
        }

        if (state == WordFightControllerState.delay)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }

            chispAlert.close();

            elapsedTime += Time.deltaTime;
            if (elapsedTime > 0.5f)
            {
                state = WordFightControllerState.zoomToPlayer0;
                heroFan.open();
                cam._wa_moveToMarker(this, 1);
            }
        }

        if (state == WordFightControllerState.zoomToPlayer0)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }
            // else {
            string currentLvl = ds.retrieveStringValue("CurrentLevel").Substring(0, 6);


            int nHeroes = 0;
            if (ds.retrieveBoolValue("Has" + currentLvl + "Warrior"))
            {
                ++nHeroes;
            }
            if (ds.retrieveBoolValue("Has" + currentLvl + "Master"))
            {
                ++nHeroes;
            }
            if (ds.retrieveBoolValue("Has" + currentLvl + "Philosopher"))
            {
                ++nHeroes;
            }
            if (ds.retrieveBoolValue("Has" + currentLvl + "Explorer"))
            {
                ++nHeroes;
            }
            if (ds.retrieveBoolValue("Has" + currentLvl + "Sage"))
            {
                ++nHeroes;
            }
            if (ds.retrieveBoolValue("Has" + currentLvl + "Wizard"))
            {
                ++nHeroes;
            }
            if (ds.retrieveBoolValue("Has" + currentLvl + "Yogi"))
            {
                ++nHeroes;
            }

            if (nHeroes == 0)
            {
                chispAlert._wa_alert(this, chispaStuff.getString(NOTIENESNINGUN));
                substate = 0;
                this.isWaitingForActionToComplete = true;
                state = WordFightControllerState.loseFromTheBeginning;
            }
            else if (tutorialMode)
            {
                chispAlert._wa_alert(this, chispaStuff.getString(DEBESELEGIR));
                this.isWaitingForActionToComplete = true;
                state    = WordFightControllerState.zoomToPlayer1;
                substate = 0;
            }
            else
            {
                state = WordFightControllerState.zoomToPlayer;
            }
        }

        if (state == WordFightControllerState.zoomToPlayer1 && substate == 0)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }
            if (tutorialMode)
            {
                chispAlert._wa_alert(this, chispaStuff.getString(JUZGALOS));
            }
            substate = 1;
        }
        if (state == WordFightControllerState.zoomToPlayer1 && substate == 1)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }
            if (tutorialMode)
            {
                chispAlert._wa_alert(this, chispaStuff.getString(CONQUEHEROE));
            }
            state = WordFightControllerState.zoomToPlayer2;
        }

        if (state == WordFightControllerState.zoomToPlayer2)
        {
            if (tutorialMode)
            {
                if (isWaitingForActionToComplete)
                {
                    return;
                }
                chispAlert.close();
            }
            state = WordFightControllerState.zoomToPlayer;
        }

        if (state == WordFightControllerState.zoomToPlayer)
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                Ray        ray = cam.gameObject.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);

                if (Physics.Raycast(ray, out hit))
                {
                    GameObject objectHit = hit.transform.gameObject;

                    if (objectHit.tag == "Hero")
                    {
                        WordFightHero h = objectHit.GetComponent <WordFightHero> ();

                        chosenHero = h.wisdom;
                        heroFan.keep(h.wisdom);
                        //heroFan.close ();

                        state       = WordFightControllerState.delay2;
                        substate    = -2;
                        elapsedTime = 0.0f;
                    }
                }
            }
        }

        if (state == WordFightControllerState.loseFromTheBeginning && substate == 0)
        {
            if (Input.GetMouseButtonDown(0))
            {
                chispAlert.close();
                fader._wa_fadeOut(this);
                this.isWaitingForActionToComplete = true;
                substate = 1;
            }
        }
        if (state == WordFightControllerState.loseFromTheBeginning && substate == 1)
        {
            if (!isWaitingForActionToComplete)
            {
                ds.storeIntValue("AlphabetReward", -Reward * 6);
                string ret = ds.retrieveStringValue("ReturnLocation");
                SceneManager.LoadScene(ret);
            }
        }

        if (state == WordFightControllerState.delay2 && substate == -2)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 0.5f)
            {
                ++substate;
                heroFan.closeSlowly();
            }
        }

        if (state == WordFightControllerState.delay2 && substate == -1)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.5f)
            {
                ++substate;
                heroGlow.glow();
                //heroFan.closeSlowly ();
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 0)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 3.5f)
            {
                elapsedTime = 0.0f;
                //cam._wa_moveToMarker (this, 3);
                cam._wm_moveToMarker(3);
                ++substate;
                if (!chosenHero.Equals(requiredWisdom))
                {
                    state    = WordFightControllerState.loseFromTheBeginning;
                    substate = 0;
                    chispAlert._wa_alert(this, chispaStuff.getString(NOHASELEGIDO));
                    fader.setFadeColor(0, 0, 0);
                    //fader.fadeOut ();
                }
                else if (tutorialMode)
                {
                    chispAlert._wa_alert(this, chispaStuff.getString(HASELEGIDOSABIA));
                    ++substate;
                }
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 1)
        {
            ++substate;
        }
        if (state == WordFightControllerState.delay2 && substate == 2)
        {
            if (tutorialMode)
            {
                if (isWaitingForActionToComplete)
                {
                    return;
                }
                chispAlert.close();
            }
            ++substate;
        }

        if (state == WordFightControllerState.delay2 && substate == 3)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 0.75f)
            {
                elapsedTime = 0.0f;

                shadowBar.grow();
                playerBar._wa_grow(this);
                //hero.fighting = true;
                //shadow.fighting = true;
                hero.showHalo();
                shadow.showHalo();
                //yingYang._wa_grow (this);

                timeToNextBlob = FloatRandom.floatRandomRange(minTimeToNextBlob / difficulty, maxTimeToNextBlob / difficulty);
                ++substate;
                // Cambiar esto para jugar en serio
                shadowEnergy = 0.1f;
                playerEnergy = 1.0f;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 4)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }

            if (tutorialMode)
            {
                chispAlert._wa_alert(this, chispaStuff.getString(TANTOTUSOMBRA));
            }
            ++substate;
        }

        if (state == WordFightControllerState.delay2 && substate == 5)
        {
            if (tutorialMode)
            {
                if (isWaitingForActionToComplete)
                {
                    return;
                }
            }

            if (tutorialMode)
            {
                chispAlert._wa_alert(this, chispaStuff.getString(TUAURAESLUM));
            }
            ++substate;
        }

        if (state == WordFightControllerState.delay2 && substate == 6)
        {
            if (tutorialMode)
            {
                if (isWaitingForActionToComplete)
                {
                    return;
                }
                chispAlert.close();
            }
            yinYang._wa_grow(this);

            ++substate;
        }

        if (state == WordFightControllerState.delay2 && substate == 7)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }

            hero.fighting   = true;
            shadow.fighting = true;
            elapsedTime     = 0.0f;
            if (tutorialMode)
            {
                ++substate;
            }
            else
            {
                state = WordFightControllerState.fightStart;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 8)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.5f)
            {
                if (tutorialMode)
                {
                    chispAlert._wa_alert(this, chispaStuff.getString(QUETIENESQUEHACER));
                }
                ++substate;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 9)
        {
            if (tutorialMode)
            {
                if (isWaitingForActionToComplete)
                {
                    return;
                }
            }

            if (tutorialMode)
            {
                chispAlert._wa_alert(this, chispaStuff.getString(CADAPALABRASERA));
            }
            ++substate;
        }

        if (state == WordFightControllerState.delay2 && substate == 10)
        {
            if (tutorialMode)
            {
                if (isWaitingForActionToComplete)
                {
                    return;
                }

                chispAlert._wa_alert(this, chispaStuff.getString(DEBESTOCARLOS));
            }
            elapsedTime = 0.0f;
            ++substate;
        }

        if (state == WordFightControllerState.delay2 && substate == 11)
        {
            if (tutorialMode)
            {
                if (isWaitingForActionToComplete)
                {
                    return;
                }
                chispAlert.close();
            }
            elapsedTime = 0.0f;
            ++substate;
        }

        if (state == WordFightControllerState.delay2 && substate == 12)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.0f)
            {
                yinYang.emitBlob(GenericGoodStuffBank.getNextString(), true);
                elapsedTime = 0.0f;
                ++substate;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 13)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.0f)
            {
                emittedBlob = GameObject.Find("WFBlob").GetComponent <WordFightWordBlob> ();
                emittedBlob.pause();
                chispAlert._wa_alert(this, chispaStuff.getString(YINYANGEMITIDOBUENO));
                ++substate;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 14)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }

            chispAlert.close();
            emittedBlob.unpause();
            shadowBar.queryClear();
            ++substate;
        }

        /* wait until player drags word onto yingyang */
        if (state == WordFightControllerState.delay2 && substate == 15)
        {
            checkMouseClick();

            if (shadowBar.queryEvent("HealthBarEvent"))
            {
                substate = 17;
                chispAlert._wa_alert(this, chispaStuff.getString(HASILUMINADO));
            }

            if (emittedBlob == null && shadowBar.targetBarFraction == 1)
            {
                yinYang.emitBlob(GenericGoodStuffBank.getNextString(), true);
                ++substate;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 16)
        {
            GameObject g = GameObject.Find("WFBlob");
            if (g != null)
            {
                emittedBlob = g.GetComponent <WordFightWordBlob> ();
                substate    = 15;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 17)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }
            chispAlert.close();
            ++substate;
            elapsedTime = 0.0f;
        }

        if (state == WordFightControllerState.delay2 && substate == 18)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.0f)
            {
                yinYang.emitBlob(GenericNaughtyStuffBank.getNextString(), false);
                elapsedTime = 0.0f;
                ++substate;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 19)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 1.0f)
            {
                emittedBlob = GameObject.Find("WFBlob").GetComponent <WordFightWordBlob> ();
                emittedBlob.pause();
                chispAlert._wa_alert(this, chispaStuff.getString(YINYANGEMITIDOMALO));
                ++substate;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 20)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }

            chispAlert.close();
            elapsedTime = 0.0f;
            ++substate;
        }


        if (state == WordFightControllerState.delay2 && substate == 21)
        {
            elapsedTime += Time.deltaTime;

            if (elapsedTime > 1.0f)
            {
                emittedBlob.unpause();
                ++substate;
            }
        }

        /* wait until naughtyWord has gone away */
        if (state == WordFightControllerState.delay2 && substate == 22)
        {
            checkMouseClick();

            /* blob has hit player. Emit another */
            if (emittedBlob == null && playerBar.queryEvent("HealthBarEvent"))
            {
                yinYang.emitBlob(GenericNaughtyStuffBank.getNextString(), false);
                ++substate;
                return;
            }

            if (playerBar.targetBarFraction < 0.5f)
            {
                playerBar.targetBarFraction = 0.9f;
            }

            /* blob has flown away. To next substate */
            if (emittedBlob == null && !playerBar.queryEvent("HealthBarEvent"))
            {
                substate = 24;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 23)
        {
            /* spawn new blob */
            GameObject g = GameObject.Find("WFBlob");
            if (g != null)
            {
                emittedBlob = g.GetComponent <WordFightWordBlob> ();
                substate    = 22;
            }
        }

        if (state == WordFightControllerState.delay2 && substate == 24)
        {
            chispAlert._wa_alert(this, chispaStuff.getString(CONTINUALABATALLA));
            ++substate;
        }

        if (state == WordFightControllerState.delay2 && substate == 25)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }
            chispAlert.close();
            state = WordFightControllerState.fightStart;
        }

        if (state == WordFightControllerState.fightEndWin && substate == 0)
        {
            cam.moveToMarker(2, 5);
            yinYang.home();
            elapsedTime = 0.0f;
            ++substate;
            ds.storeIntValue("AlphabetReward", Reward);
            int defeated = ds.retrieveIntValue("DefeatedShadows");
            ++defeated;
            ds.storeIntValue("DefeatedShadows", defeated);
            ds.storeBoolValue("WordFightTutorialDone", true);
        }

        if (state == WordFightControllerState.fightEndWin && substate == 1)
        {
            if (yinYang.isFinishedHoming())
            {
//				yinYang.GetComponent<Renderer> ().enabled = false;
//				justYin.GetComponent<Renderer> ().enabled = true;
//				justYang.GetComponent<Renderer> ().enabled = true;
                //blackSquare.GetComponent<Renderer> ().enabled = true;
                ++substate;
                elapsedTime = 0.0f;
            }
        }

        if (state == WordFightControllerState.fightEndWin && substate == 2)
        {
            elapsedTime += Time.deltaTime;
//			Vector3 pos;
//			pos = justYin.transform.localPosition;
//			pos.x += Time.deltaTime;
//			justYin.transform.position = pos;
//			pos = justYang.transform.localPosition;
//			pos.x -= Time.deltaTime;
//			justYang.transform.position = pos;
//			pos = blackSquare.transform.localScale;
//			pos.x -= Time.deltaTime;
//			blackSquare.transform.localScale = pos;

            if (!faderWhite.GetComponent <FaderItween>().action)
            {
                faderWhite.GetComponent <FaderItween> ().action = true;
            }

            if (elapsedTime > faderWhite.GetComponent <FaderItween> ().timeTo)
            {
                string levelName = ds.retrieveStringValue("CurrentLevel").Substring(0, 6);
                int    nWave     = ds.retrieveIntValue(levelName + "ShadowWaveNumber");
                ++nWave;
                ds.storeIntValue(levelName + "ShadowWaveNumber", nWave);                  // increment wave number
                //Handheld.PlayFullScreenMovie ("4.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
                if (Version.versionType == VersionType.demo)
                {
                    string returnLocation = ds.retrieveStringValue("ReturnLocation");
                    SceneManager.LoadScene(returnLocation);
                }
                else
                {
                    //string currentHero = ds.retrieveStringValue ();
                    int numHero = ds.retrieveIntValue("Has" + requiredWisdom);
                    //ds.storeStringValue ("TheaterFolder", requiredWisdom + numHero);
                    //SceneManager.LoadScene ("Scenes/Theater");
                    int wins = ds.retrieveIntValue("WordFightWins");
                    ds.storeIntValue("WordFightWins", ++wins);
                    ds.storeBoolValue("JustWonFight", true);
                    ds.storeBoolValue("FadeWhite", true);
                    string returnLocation = ds.retrieveStringValue("ReturnLocation");
                    SceneManager.LoadScene(returnLocation);
                }
            }
        }

        if (state == WordFightControllerState.fightEndLose && substate == 0)
        {
            chispAlert._wa_alert(this, chispaStuff.getString(HASPERDIDOLABATALLA));
            fader.setFadeColor(0, 0, 0);
            this.isWaitingForActionToComplete = true;
            ++substate;
        }

        if (state == WordFightControllerState.fightEndLose && substate == 1)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }

            chispAlert.close();
            fader._wa_fadeOut(this);
            this.isWaitingForActionToComplete = true;
            ++substate;
        }

        if (state == WordFightControllerState.fightEndLose && substate == 2)
        {
            if (isWaitingForActionToComplete)
            {
                return;
            }

            this.isWaitingForActionToComplete = true;
            ++substate;
        }

        if (state == WordFightControllerState.fightEndLose && substate == 3)
        {
            if (!this.isWaitingForActionToComplete)
            {
                string ret = ds.retrieveStringValue("ReturnLocation");
                ds.storeIntValue("AlphabetReward", -Reward);
                SceneManager.LoadScene(ret);
            }
        }

        if (state == WordFightControllerState.fightStart)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > timeToNextBlob)
            {
                elapsedTime    = 0.0f;
                timeToNextBlob = FloatRandom.floatRandomRange(minTimeToNextBlob / difficulty, maxTimeToNextBlob / difficulty);

                float chance = FloatRandom.floatRandomRange(0.0f, 1.0f);

                if (chance < 0.5f)
                {
                    string ns = GenericGoodStuffBank.getNextString();
                    int    a  = ns.Length;
                    yinYang.emitBlob(ns, true);
                }
                else
                {
                    string ns  = GenericNaughtyStuffBank.getNextString();
                    int    hhh = ns.Length;
                    yinYang.emitBlob(ns, false);
                }
            }

            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit[] hits;
                Ray          ray = cam.gameObject.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);

                hits = Physics.RaycastAll(ray);
                for (int i = 0; i < hits.Length; ++i)
                {
                    GameObject objectHit = hits[i].transform.gameObject;

                    if (objectHit.tag == "TextBlob")
                    {
                        WordFightWordBlob theBlob = objectHit.GetComponent <WordFightWordBlob> ();
                        //theBlob.tab = tab;
                        theBlob.pickUp(hits[i].point);

                        //Destroy (objectHit);
                    }
                    else if (objectHit.tag == "RayCastBillboard")
                    {
                        Vector3 worldCoords = hits[i].point;
                    }
                }
            }
        }
    }
    void Update()
    {
        doubleTapElapsedTime += Time.deltaTime;
        if (Input.GetMouseButtonDown(0))
        {
            if (doubleTapElapsedTime < maxDoubleTapDelay)
            {
                showGear();
            }
            doubleTapElapsedTime = 0.0f;
        }

        if (state == 666)
        {
            timer -= Time.deltaTime;
            if (timer < 0.0f)
            {
                timer = 0.25f;
                state = 667;
            }
        }
        if (state == 667)
        {
            timer -= Time.deltaTime;
            if (timer < 0.0f)
            {
                SceneManager.LoadScene("Scenes/Selector");
            }
        }

        if (runMode == RunMode.Debug)
        {
            return;
        }

        if (state == 0)           // idle

        {
        }
        if (state == 1)           // launch logo activity
        {
            logoActivity.SetActive(true);
            logoController.startLogoActivity(this);
            previousState = 2;
            state         = 2;     //
        }

        if (state == 20)
        {
            state = 21;
        }
        if (state == 21)
        {
            if (www.isDone)
            {
                if (www.text.Equals(""))
                {
                    string status = serverStatusStrings.getString(0);
                    serverStatusCanvas.SetActive(true);
                    serverStatusText.text = status;
                    state = 22;
                }
                else
                {
                    string[] msg = www.text.Split(':');

                    if (msg [0].Equals("0"))
                    {
                        state = previousState;                         // all A-OK, proceed normally
                        serverStatusCanvas.SetActive(false);
                    }
                    else if (msg [0].Equals("1"))                          // planned downtime

                    {
                        string status = serverStatusStrings.getString(1);
                        status = status.Replace("<1>", msg [1]);
                        status = status.Replace("<2>", msg [2]);
                        status = status.Replace("<3>", msg [3]);
                        status = status.Replace("<4>", msg [4]);
                        serverStatusBatsu.enabled = false;
                        serverStatusCanvas.SetActive(true);
                        serverStatusText.text = status;
                        state = 22;
                    }
                    else if (msg [0].Equals("3"))                          // pre-downtime notice
                    {
                        string status = serverStatusStrings.getString(2);
                        status = status.Replace("<1>", msg [1]);
                        status = status.Replace("<2>", msg [2]);
                        serverStatusBatsu.enabled = true;
                        serverStatusCanvas.SetActive(true);
                        serverStatusText.text = status;

                        state = previousState;
                    }
                    else                        // some other unplanned shit
                    {
                        string status = serverStatusStrings.getString(0);
                        serverStatusBatsu.enabled = false;
                        serverStatusCanvas.SetActive(true);
                        serverStatusText.text = status;
                        state = 22;
                    }
                }
            }
        }

        if (state == 2)           // wait for logo to end
        {
            if (!isWaitingForTaskToComplete)
            {
                logoActivity.SetActive(false);
                galleryActivity.SetActive(false);
                titleActivity.SetActive(true);
                titleController.startTitleActivity(this);
                state = 3;
            }
        }
        if (state == 3)           // wait for title to end
        {
            if (!isWaitingForTaskToComplete)
            {
                if (startActivity.Equals("Title"))
                {
                    joinGameActivity.SetActive(false);
                    createNewGameActivity.SetActive(false);
                    titleActivity.SetActive(true);
                    titleController.startTitleActivity(this);
                }
                if (startActivity.Equals("ContinueGame"))
                {
                    titleActivity.SetActive(false);
                    continueGameActivity.SetActive(true);

                    //state = 4;
                }
                if (startActivity.Equals("StartNewGame"))
                {
                    titleActivity.SetActive(false);
                    startActivity = "MainGame";
                }                /*
                                  * if (startActivity.Equals ("JoinNewGame")) {
                                  *     titleActivity.SetActive (false);
                                  *     joinGameActivity.SetActive (true);
                                  *     joinNewGameController.startJoinNewGameActivity (this);
                                  *     //state = 4;
                                  * }*/
                if (startActivity.Equals("Gallery"))
                {
                    titleActivity.SetActive(false);
                    galleryActivity.SetActive(true);
                    galleryController.startGalleryActivity(this);
                    state = 2;                     // start title when this task ends...
                }
                if (startActivity.Equals("Family"))
                {
//					joinGameActivity.SetActive (false);
//					newGameActivity.SetActive (false);
//					familyActivity.SetActive (true);
//					familyController.startFamilyActivity (this);
                    familyActivity.SetActive(false);
                    choosePlayerActivity.SetActive(true);
                    choosePlayerController.startChoosePlayerActivity(this);
                    //state = 4;
                }
                if (startActivity.Equals("ChoosePlayer"))
                {
                    familyActivity.SetActive(false);
                    choosePlayerActivity.SetActive(true);
                    choosePlayerController.startChoosePlayerActivity(this);
                    //state = 4;
                }
                if (startActivity.Equals("MainGame"))
                {
                    int myPlayer = gameController.localPlayerN = 0;
                    myPlayerMiniature.enabled = true;
                    myPlayerMiniature.texture = playersMiniature [myPlayer];
                    continueGameActivity.SetActive(false);
                    choosePlayerActivity.SetActive(false);
                    mainGameController.startMainGameActivity(this);
                    //state = 4;
                }
                if (startActivity.Equals("ResetGame"))
                {
                    //networkAgent.disconnect ();
                    gameController.reset();
                    hardReset();
                }
            }
        }
        if (state == 4)           // waiting for CreateNewGame activity to finish
        {
        }
    }