예제 #1
0
    // Use this for initialization
    void Start()
    {
        seedX = FloatRandom.floatRandomRange(0.0f, 6.28f);
        seedY = FloatRandom.floatRandomRange(0.0f, 6.28f);

        originalScale = this.transform.localScale;
    }
예제 #2
0
    // Update is called once per frame
    new void Update()
    {
        elapsedTime += Time.deltaTime;
        if (elapsedTime > (1.0f / animationSpeed))
        {
            frame = (frame + 1) % images.Length;

            mat.sprite = images [frame];
        }

        if (state != ChispaWorldState.idle)
        {
            timeToEmit += Time.deltaTime;
            if (timeToEmit > (1.0f / dustFrequency))
            {
                timeToEmit = 0.0f;
                float      newAngle  = FloatRandom.floatRandomRange(0, 6.28f);
                GameObject newDustGO = (GameObject)Instantiate(dustPrefab, this.transform.position,
                                                               Quaternion.Euler(0, 0, newAngle));
            }
        }



        if (state == ChispaWorldState.comingOut)
        {
            if (anim.GetCurrentAnimatorStateInfo(0).IsName("ChispaRemainsOut"))
            {
                notifyFinishAction();
                state         = ChispaWorldState.Out;
                transitioning = false;
            }

            /*AnimatorStateInfo inf = anim.GetCurrentAnimatorStateInfo (0);
             * float nt = inf.normalizedTime;
             *
             *
             * if ((anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1.0f)
             *      && !anim.IsInTransition(0)) {
             *
             *      notifyFinishAction();
             *      state = ChispaWorldState.Out;
             * }*/
        }



        if (state == ChispaWorldState.returning)
        {
            if (anim.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
            {
                mat.color = new Color(0, 0, 0, 0);
                notifyFinishAction();
                state         = ChispaWorldState.idle;
                transitioning = false;
            }
        }
    }
    public void initialize()
    {
        anim = roca.GetComponent <Animator> ();

        level = GameObject.Find("LevelController").GetComponent <LevelControllerScript> ();

        r     = this.GetComponent <Rigidbody> ();
        angle = FloatRandom.floatRandomRange(0.0f, 6.28f);
    }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        float randomYAngle = FloatRandom.floatRandomRange(0, 360.0f);

        this.transform.parent.rotation = Quaternion.Euler(0, randomYAngle, 0);
        delay       = FloatRandom.floatRandomRange(0.2f, 0.8f);
        anim        = this.GetComponent <Animator> ();
        state       = 0;
        elapsedTime = 0.0f;
        //roll ();
    }
예제 #5
0
 public void crack()
 {
     theImage.enabled = true;
     theImage.sprite  = crackedGlass [0];
     levelController.playSound(crackAudio [0]);
     theImage.color  = new Color(1, 1, 1, 1);
     elapsedTime     = 0.0f;
     nextTimeToCrack = FloatRandom.floatRandomRange(minTimeToCrack, maxTimeToCrack);
     state           = HUDCrackGlassState.cracking;
     ds.storeBoolValue("IsHUDCracked", true);
 }
예제 #6
0
    // Update is called once per frame
    new void Update()
    {
        if (state == HUDCrackGlassState.cracking)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > nextTimeToCrack)
            {
                elapsedTime     = 0.0f;
                nextTimeToCrack = FloatRandom.floatRandomRange(minTimeToCrack, maxTimeToCrack);
                if (frame < crackedGlass.Length - 1)
                {
                    ++frame;
                    theImage.sprite = crackedGlass [frame];
                    levelController.playSound(crackAudio [frame]);
                }
                else
                {
                    state = HUDCrackGlassState.cracked;
                }
            }
        }

        if (state == HUDCrackGlassState.cracked)
        {
        }

        if (state == HUDCrackGlassState.changingActivity)
        {
            --waitFrames;
            if (waitFrames == 0)
            {
                ds.storeStringValue("ReturnLocation", levelController.locationName);
                levelController.storeStringValue("CurrentLevel", levelController.locationName);
                levelController.storePlayerCoordinates();
                SceneManager.LoadScene("Scenes/QA");
            }
        }
    }
    public void reset()
    {
        mc                     = GameObject.Find("MasterController").GetComponent <MasterControllerScript> ();
        rosetta                = GameObject.Find("Rosetta").GetComponent <Rosetta> ();
        currentAlphaCurtain    = alphaCurtains [0];
        currentCurtainPosition = targetCurtainPosition = rightClosedCurtain;
        currentAlphaCurtain.transform.position = new Vector3(currentCurtainPosition,
                                                             currentAlphaCurtain.transform.position.y,
                                                             currentAlphaCurtain.transform.position.z);

        amountRequired = mc.getStorage().retrieveIntValue("TVFerfuflosAmount");

        adsAnim = ads.GetComponent <Animator> ();
        // do not always start at the beginning...
        adsAnim.SetFloat("offset", FloatRandom.floatRandomRange(0.0f, 1.0f));

        answer.text = "";

        state     = 0;
        chipScale = 1.0f;
        opacity   = 0.0f;

        whiteCard.GetComponent <Image>().color  = new Color(1, 1, 1, 0);
        blackCard.GetComponent <Image> ().color = new Color(1, 1, 1, 0);
        chip.GetComponent <Image> ().color      = new Color(1, 1, 1, 0);
        whiteHalo.color = new Color(1, 1, 1, 0);
        blackHalo.color = new Color(1, 1, 1, 0);
        answer.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, 0));
        assertion.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, 0));
        transmission.GetComponent <Renderer> ().material.SetColor("_Tint", new Color(1, 1, 1, 0));


        chipOnWhite = chipOnBlack = false;

        //
        //propositionBank = stringBanks [0].bank [0];

        //wiseAnswers = stringBanks [0].bank [2];
        /* just in case */
        propositionBank.rosetta = rosetta;
        propositionBank.reset();

        //wiseAnswers.rosetta = rosetta;

        transmissionBank.rosetta = rosetta;
        transmissionBank.reset();

        //propositionBank.reset ();

        //wiseAnswers.reset ();

        chipInserted = false;

        // update number of screen id usage


        foreach (StringBank sb in sabias)
        {
            sb.rosetta = rosetta;
            sb.reset();
        }

        foreach (StringBank sb in ignorantes)
        {
            sb.rosetta = rosetta;
            sb.reset();
        }

        chip.transform.position   = chipRelaxPos;
        chipCurrentPos            = chipRelaxPos;
        chip.transform.localScale = Vector3.one;
    }
예제 #8
0
    void Update()
    {
        if (freezer.frozen)
        {
            return;
        }

        if (!frozen)
        {
            elapsedTime += Time.deltaTime;
        }

        /* busy: spawning whilwinds */
        if (state == InterconNetworkState.busy)
        {         // pursuing player
            elapsedVeeringTime += Time.deltaTime;
            if (elapsedVeeringTime > timeToVeer)
            {
                elapsedVeeringTime = 0.0f;
                //int r = Random.Range (0, 100);

                Vector3 pPos  = player.transform.position;
                Vector3 tPos  = this.transform.position;
                Vector3 delta = pPos - tPos;
                delta.Normalize();
                targetAngle = Mathf.Acos(delta.x);
                if (delta.z < 0.0)
                {
                    targetAngle = (2.0f * 3.1416f) - targetAngle;
                }

                linearSpeed = floatRandomRange(minLinearSpeed, maxLinearSpeed);

                Debug.Log("<color=orange>Target Angle updated: " + targetAngle + "</color>");
            }

            if (elapsedTime > timeToWhirl)
            {
                elapsedTime = 0.0f;
                GameObject newWhirl = (GameObject)Instantiate(whirlwindPrefab, this.transform.position, Quaternion.Euler(0, 0, 0));
                newWhirl.name = "Whirlwind";
                newWhirl.GetComponent <Whirlwind> ().thoughtTextPrefab = thoughtTextPrefab;
                newWhirl.GetComponent <Whirlwind> ().parent            = this;
                newWhirl.GetComponent <Whirlwind> ().shadowPrefab      = shadowPrefab;
                newWhirl.GetComponent <Whirlwind> ().rosetta           = rosetta;
                newWhirl.GetComponent <Whirlwind> ().FamilyIcon        = FamilyIcon;
                newWhirl.GetComponent <Whirlwind> ().CoupleIcon        = CoupleIcon;
                newWhirl.GetComponent <Whirlwind> ().FriendsIcon       = FriendsIcon;
                //newWhirl.GetComponent<Whirlpool> ().Start ();
                newWhirl.GetComponent <Whirlwind> ().WorkIcon = WorkIcon;
                int wave = shadowSpawnController.getWaveIndex();

                newWhirl.GetComponent <Whirlwind> ().shadowStringBanks     = HeroShadows[wave];
                newWhirl.GetComponent <Whirlwind> ().redEyesStringBanks    = HeroRedeyes[wave];
                newWhirl.GetComponent <Whirlwind> ().shadowSpawnController = shadowSpawnController;
                newWhirl.GetComponent <Whirlwind> ().placesStringBank      = places;
                newWhirl.GetComponent <Whirlwind> ().datesStringBank       = dates;

                timeToWhirl = floatRandomRange(minTimeToWhirl / whirlDifficulty, maxTimeToWhirl / whirlDifficulty);
            }

            if (level == null)
            {
                level = GameObject.Find("LevelController").GetComponent <LevelControllerScript> ();
            }
            string lvl      = level.locationName.Substring(0, 6);
            int    nShadows = level.retrieveIntValue(lvl + "SpawnedShadows");

            if (nShadows >= ShadowSpawnController.maxShadows)
            {
                state = InterconNetworkState.driftingAway;
            }
        }

        if (state == InterconNetworkState.driftingAway)
        {         // pursuing player
            if (!deletedWhirlwinds)
            {
                if (GameObject.Find("Whirlwind") != null)
                {
                    Destroy(GameObject.Find("Whirlwind"));
                }
                else
                {
                    deletedWhirlwinds = true;
                }
            }

            elapsedVeeringTime += Time.deltaTime;
            if (elapsedVeeringTime > timeToVeer)
            {
                elapsedVeeringTime = 0.0f;

                //int r = Random.Range (0, 100);

                Vector3 pPos  = player.transform.position;
                Vector3 tPos  = this.transform.position;
                Vector3 delta = -(pPos - tPos);                 // flee from player
                delta.Normalize();
                targetAngle = Mathf.Acos(delta.x);
                if (delta.z < 0.0)
                {
                    targetAngle = (2.0f * 3.1416f) - targetAngle;
                }

                linearSpeed = floatRandomRange(minLinearSpeed, maxLinearSpeed);
            }
        }

        if (state == InterconNetworkState.relaxed)
        {         // just float by...
            elapsedVeeringTime += Time.deltaTime;
            if (elapsedVeeringTime > timeToVeer)
            {
                elapsedVeeringTime = 0.0f;

                //int r = Random.Range (0, 6.28f);
                float newAngle = FloatRandom.floatRandomRange(0, 6.28f);

                targetAngle = newAngle;

                linearSpeed = floatRandomRange(minLinearSpeed, maxLinearSpeed);
            }
        }

        if (angle < targetAngle)
        {
            angle += angleSpeed * Time.deltaTime;
            if (angle > targetAngle)
            {
                angle = targetAngle;
            }
        }

        if (angle > targetAngle)
        {
            angle -= angleSpeed * Time.deltaTime;
            if (angle < targetAngle)
            {
                angle = targetAngle;
            }
        }
    }
예제 #9
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;
                    }
                }
            }
        }
    }
예제 #10
0
    void Update()
    {
        float scaleFactor = Screen.height / 600.0f;

        if (showText)
        {
            controller.theText.color = new Color(1, 1, 1, 1);
            showText = false;
        }

        if (state == ChispaState.leftToRight || state == ChispaState.rightToLeft)
        {
            xPos   += xSpeed * scaleFactor * Time.deltaTime;
            xSpeed += xAccel * scaleFactor * Time.deltaTime;

            // we are in absolute coordinates: 0 is left, Screen.width is right
            yPos = (maxY / 2.0f) + swayAmplitude * Mathf.Sin(angle);

            angle += angleSpeed * Time.deltaTime;

            this.transform.position = new Vector2(xPos, yPos);

            if (xPos > maxX || xPos < minX)
            {
                state  = ChispaState.idle;
                xSpeed = swipeSpeed;
            }

            elapsedTime += Time.deltaTime;
            if (elapsedTime > timeToEmitDust)
            {
                elapsedTime = 0.0f;
                GameObject newDustGO = (GameObject)Instantiate(dustPrefab, this.transform.position,
                                                               Quaternion.Euler(0, 0, FloatRandom.floatRandomRange(0, 180.0f)));
                newDustGO.transform.parent = this.transform.parent;
                ChispaAlertDustParticle newDust = newDustGO.GetComponent <ChispaAlertDustParticle> ();
                newDust.initialize();
            }
        }

        if (state == ChispaState.leftToRight)
        {
            if (Input.GetMouseButtonDown(0))                // finish at once

            {
                xSpeed = xSpeed * scaleFactor * 10.0f;
            }
        }

        if (state == ChispaState.rightToLeft)
        {
            if (Input.GetMouseButtonDown(0))                // finish at once

            {
                xSpeed = xSpeed * scaleFactor * 10.0f;
            }
        }

        if (state == ChispaState.idle)
        {
            if (Input.GetMouseButtonDown(0))
            {
                controller.dismiss();
            }
        }
    }
예제 #11
0
    void Update()
    {
        if (state == WFYingYangState.idle)
        {
        }

        if (state == WFYingYangState.homing)
        {
            int   nTurns      = (int)(angle / 360.0f);
            float normalAngle = angle - 360.0f * nTurns;
            angle       = normalAngle;
            angle      += angleSpeed * Time.deltaTime;
            angleSpeed += Time.deltaTime * 20.0f;
            if (angle > 360.0f)
            {
                angle = 360.0f;
                state = WFYingYangState.idle;
            }
            this.transform.rotation = Quaternion.Euler(0, 0, angle);
        }

        if (state == WFYingYangState.growing)
        {
            scale += scaleSpeed * Time.deltaTime;

            if (scale > maxScale)
            {
                scale = maxScale;
                state = WFYingYangState.spinning;
                notifyFinishAction();
            }

            angle += angleSpeed * Time.deltaTime;

            this.transform.localScale = new Vector3(scale, scale, scale);
            this.transform.rotation   = Quaternion.Euler(0, 0, angle);

            if (angleSpeed > slowAngleSpeed)
            {
                angleSpeed = angleSpeed * 0.97f;
            }
        }

        if (state == WFYingYangState.spinning)
        {
            if (angleSpeed > slowAngleSpeed)
            {
                angleSpeed = angleSpeed * 0.97f;
            }
            angle += angleSpeed * Time.deltaTime;
            this.transform.rotation = Quaternion.Euler(0, 0, angle);
        }

        if (state == WFYingYangState.trembling)
        {
            angle += angleSpeed * Time.deltaTime;
            this.transform.rotation = Quaternion.Euler(0, 0, angle);

            Vector3 newPos = this.transform.position;

            if (oddFrame)
            {
                newPos.y += 0.05f;
            }
            else
            {
                newPos.y -= 0.05f;
            }

            this.transform.position = newPos;

            oddFrame = !oddFrame;

            elapsedTime += Time.deltaTime;
            if (elapsedTime > tremblingTime)
            {
                elapsedTime = 0.0f;
                newPos      = this.transform.position;

                if (oddFrame)
                {
                    newPos.y += 0.05f;
                }
                else
                {
                    newPos.y -= 0.05f;
                }

                this.transform.position = newPos;
                Vector3 spawnPos = this.transform.position;
                spawnPos.z += zOffset;
                GameObject        newBlobGO = (GameObject)Instantiate(wordBlobPrefab, spawnPos, Quaternion.Euler(Vector3.zero));
                WordFightWordBlob newBlob   = newBlobGO.GetComponent <WordFightWordBlob> ();
                newBlobGO.name = "WFBlob";
                newBlob.angle  = FloatRandom.floatRandomRange(0.0f, 6.28f);
                newBlob.initialize();
                newBlob.good       = nextGood;
                newBlob.controller = controller;
                newBlob.yinYang    = this;
                newBlob.cam        = cam;
                newBlob.difficulty = difficulty;
                if (nextString.Equals(""))
                {
                    nextString = "";
                }
                newBlob.setText(nextString);
                state = WFYingYangState.spinning;
            }
        }
    }