Beispiel #1
0
    void Update()
    {
        if (Application.loadedLevelName == "TowerDefense")
        {
            int currentPopulation = GlobalManager.globalManager.population;

            if (currentPopulation <= population / 2 && currentPopulation > population / 3)
            {
                if (audio.isPlaying && audio.clip != worriedClip)                                    // if there is audio playing
                {
                    fadeOut(0.5f);
                }
                else
                {
                    fadeIn(worriedClip, 10f);
                }
            }

            if (currentPopulation <= population / 3 && currentPopulation > 0)
            {
                if (audio.isPlaying && audio.clip != scaredClip)                                    // if there is audio playing
                {
                    fadeOut(0.5f);
                }
                else
                {
                    fadeIn(scaredClip, 10f);
                }
            }

            if (currentPopulation == 0)
            {
                if (audio.isPlaying && audio.clip != happyClip)                                    // if there is audio playing
                {
                    fadeOut(10f);
                }
                else
                {
                    fadeIn(happyClip, 0.1f);
                }
            }


            /*
             * time = globalManager.time;
             *
             * if (time > 60f && audio.clip==happyClip)
             * {
             *      if (audio.isPlaying)                    // if there is audio playing
             *              audio.Stop();
             *      audio.clip = worriedClip;                 // set the audio clip
             *      audio.Play();
             * }
             *
             * if (time > 120f && audio.clip == worriedClip)
             * {
             *      if (audio.isPlaying)                    // if there is audio playing
             *              audio.Stop();
             *      audio.clip = scaredClip;                 // set the audio clip
             *      audio.Play();
             * }
             */
        }
        else
        {
            fear = globalManager.GetComponent <GlobalManager>().globalFear;

            if (fear == 0)
            {
                if (audio.isPlaying && audio.clip != happyClip2)                                    // if there is audio playing
                {
                    fadeOut(0.5f);
                }
                else
                {
                    fadeIn(happyClip2, 0.1f);
                }
            }

            if (fear > 0f && fear <= 60f)
            {
                if (audio.isPlaying && audio.clip != worriedClip)                                    // if there is audio playing
                {
                    fadeOut(10f);
                }
                else
                {
                    fadeIn(worriedClip, 10.0f);
                }
            }

            if (fear > 60f)
            {
                if (audio.isPlaying && audio.clip != scaredClip)                                    // if there is audio playing
                {
                    fadeOut(10f);
                }
                else
                {
                    fadeIn(scaredClip, 10.0f);
                }
            }
        }
    }