コード例 #1
0
ファイル: Congratulations.cs プロジェクト: TeamGlitch/Glitch
    void Update()
    {

        if (!skip && InputManager.ActiveDevice.AnyButton.WasPressed)
        {
            skip = true;
            phase = congratulationsPhase.SECOND_PARTY;
        }

        switch (phase)
        {
        
            case congratulationsPhase.INTRO:

                float percentDone = (Time.time - startTime)/lightsOn;

                if(percentDone < 1)
                {
                    float alpha = (255 - (71 * percentDone)) / 255;
                    black.color = new Color(0,0,0,alpha);
                    
                }
                else
                {
                    black.color = new Color32(0,0,0,0);

                    congratulations.enabled = true;
                    light.enabled = true;
                    for (int i = 0; i < lights.Length; i++)
                    {
                        lights[i].enabled = true;
                    }

                    for (int i = 0; i < roundLights.Length; i++)
                    {
                        roundLights[i].enabled = true;
                    }



                    PickADance();
                    phase = congratulationsPhase.PARTY;
                }

                break;


            case congratulationsPhase.PARTY:

                if (Time.time - startTime >= firstDist)
                {
                    noise.enabled = true;
                    SoundManager.instance.musicSource.Pause();
                    whiteNoiseSource = SoundManager.instance.PlaySingle(shortNoise);
                    phase = congratulationsPhase.FIRST_NOISE;
                }

                break;

            case congratulationsPhase.FIRST_NOISE:

                if (!whiteNoiseSource.isPlaying)
                {
                    noise.enabled = false;
                    SoundManager.instance.musicSource.time = Time.time - startTime;
                    SoundManager.instance.musicSource.Play();
                    phase = congratulationsPhase.SECOND_PARTY;
                }

                break;

            case congratulationsPhase.SECOND_PARTY:

                if (skip || Time.time - startTime >= distFin)
                {
                    noise.enabled = true;
                    SoundManager.instance.musicSource.Pause();
                    whiteNoiseSource = SoundManager.instance.PlaySingle(longNoise);
                    black.color = new Color(0, 0, 0, 0);
                    phase = congratulationsPhase.FINAL_NOISE;
                }

                break;

            case congratulationsPhase.FINAL_NOISE:

                if (!whiteNoiseSource.isPlaying){
                    black.color = new Color(0, 0, 0, 1);
                    phase = congratulationsPhase.LOADING;
                    ReturnToMenu();
                }
                else if (whiteNoiseSource.time > 3.5f)
                {
                    float alpha = (whiteNoiseSource.time - 3.5f) / (6F - 3.5f);
                    black.color = new Color(0, 0, 0, alpha);
                }

                break;
        
        }

        if (nextChange < changes.Length && Time.time - startTime >= changes[nextChange] - 0.1f)
        {
            nextChange++;
            PickADance();
        }

        if (phase == congratulationsPhase.FIRST_NOISE || phase == congratulationsPhase.FINAL_NOISE)
        {
            actualNoiseImg++;

            if(actualNoiseImg > noiseImgs.Length - 1)
                actualNoiseImg = 0;

            noise.sprite = noiseImgs[actualNoiseImg];
        }

    }
コード例 #2
0
ファイル: Congratulations.cs プロジェクト: yazici/Glitch
    void Update()
    {
        if (!skip && InputManager.ActiveDevice.AnyButton.WasPressed)
        {
            skip  = true;
            phase = congratulationsPhase.SECOND_PARTY;
        }

        switch (phase)
        {
        case congratulationsPhase.INTRO:

            float percentDone = (Time.time - startTime) / lightsOn;

            if (percentDone < 1)
            {
                float alpha = (255 - (71 * percentDone)) / 255;
                black.color = new Color(0, 0, 0, alpha);
            }
            else
            {
                black.color = new Color32(0, 0, 0, 0);

                congratulations.enabled = true;
                light.enabled           = true;
                for (int i = 0; i < lights.Length; i++)
                {
                    lights[i].enabled = true;
                }

                for (int i = 0; i < roundLights.Length; i++)
                {
                    roundLights[i].enabled = true;
                }



                PickADance();
                phase = congratulationsPhase.PARTY;
            }

            break;


        case congratulationsPhase.PARTY:

            if (Time.time - startTime >= firstDist)
            {
                noise.enabled = true;
                SoundManager.instance.musicSource.Pause();
                whiteNoiseSource = SoundManager.instance.PlaySingle(shortNoise);
                phase            = congratulationsPhase.FIRST_NOISE;
            }

            break;

        case congratulationsPhase.FIRST_NOISE:

            if (!whiteNoiseSource.isPlaying)
            {
                noise.enabled = false;
                SoundManager.instance.musicSource.time = Time.time - startTime;
                SoundManager.instance.musicSource.Play();
                phase = congratulationsPhase.SECOND_PARTY;
            }

            break;

        case congratulationsPhase.SECOND_PARTY:

            if (skip || Time.time - startTime >= distFin)
            {
                noise.enabled = true;
                SoundManager.instance.musicSource.Pause();
                whiteNoiseSource = SoundManager.instance.PlaySingle(longNoise);
                black.color      = new Color(0, 0, 0, 0);
                phase            = congratulationsPhase.FINAL_NOISE;
            }

            break;

        case congratulationsPhase.FINAL_NOISE:

            if (!whiteNoiseSource.isPlaying)
            {
                black.color = new Color(0, 0, 0, 1);
                phase       = congratulationsPhase.LOADING;
                ReturnToMenu();
            }
            else if (whiteNoiseSource.time > 3.5f)
            {
                float alpha = (whiteNoiseSource.time - 3.5f) / (6F - 3.5f);
                black.color = new Color(0, 0, 0, alpha);
            }

            break;
        }

        if (nextChange < changes.Length && Time.time - startTime >= changes[nextChange] - 0.1f)
        {
            nextChange++;
            PickADance();
        }

        if (phase == congratulationsPhase.FIRST_NOISE || phase == congratulationsPhase.FINAL_NOISE)
        {
            actualNoiseImg++;

            if (actualNoiseImg > noiseImgs.Length - 1)
            {
                actualNoiseImg = 0;
            }

            noise.sprite = noiseImgs[actualNoiseImg];
        }
    }