Ejemplo n.º 1
0
    void her_Update()
    {
        if (her_done)
        {
            return;
        }

        float delta = (Input.mousePosition - her_lastMousePos).magnitude;
        float move  = Mathf.Clamp(delta / Screen.height, 0f, 1f);
        Color color = uiImage.color;

        if (move < her_minScreenMove)
        {
            if (!ImageFade.IsInProgress(uiImage) && color.a > 0f)
            {
                ImageFade.Start(uiImage, 1f, 0f, move < her_minScreenMove ? her_minFadeoutTime : her_maxFadeoutTime);
            }
        }
        else if (!her_lineTriggered)
        {
            ImageFade.Stop(uiImage);

            color.a       = Mathf.Clamp(color.a + move * her_alphaFactor, 0f, 1f);
            uiImage.color = color;
        }

        // Show another line
        if (!her_lineTriggered && color.a >= her_alphaLineTriggerUp)
        {
            TwineText line = null;
            while (line == null)
            {
                TwineOutput output = story.Output[her_outputIndex];
                if (output is TwineText)
                {
                    line = (TwineText)output;
                }
                else if (output is TwineLink && output.Name == "continue")
                {
                    her_done = true;
                    StartCoroutine(her_alarm(output as TwineLink));
                    break;
                }
                her_outputIndex++;
            }

            if (line != null)
            {
                uiTextPlayer.DisplayOutput(line);
                her_lineTriggered = true;
            }
        }
        else if (her_lineTriggered && color.a <= her_alphaLineTriggerDown)
        {
            her_lineTriggered = false;
        }

        her_lastMousePos = Input.mousePosition;
    }
Ejemplo n.º 2
0
    void her_Update()
    {
        if (her_done)
        {
            return;
        }

        float delta = (Input.mousePosition - her_lastMousePos).magnitude;
        float move  = Mathf.Clamp(delta / Screen.height, 0f, 1f);
        Color color = uiImage.color;

        if (move < her_minScreenMove)
        {
            if (!ImageFade.IsInProgress(uiImage) && color.a > 0f)
            {
                ImageFade.Start(uiImage, 1f, 0f, move < her_minScreenMove ? her_minFadeoutTime : her_maxFadeoutTime);
            }
        }
        else if (!her_lineTriggered)
        {
            ImageFade.Stop(uiImage);

            color.a       = Mathf.Clamp(color.a + move * her_alphaFactor, 0f, 1f);
            uiImage.color = color;

            if (!her_sfxMatchStrike.isPlaying)
            {
                her_sfxMatchStrike.clip = her_sfxMatchStrikeSounds[Random.Range(0, her_sfxMatchStrikeSounds.Length)];
                her_sfxMatchStrike.Play();
            }
        }

        // Show another line
        if (!her_lineTriggered && color.a >= her_alphaLineTriggerUp)
        {
            StoryOutput output = null;
            while (her_outputIndex < story.Output.Count && !(output is LineBreak))
            {
                output = story.Output[her_outputIndex];
                if (output is StoryText)
                {
                    var line = (StoryText)output;
                    uiTextPlayer.DisplayOutput(line);
                }
                else if (output is StoryLink && output.Name == "continue")
                {
                    her_done = true;
                    StartCoroutine(her_alarm(output as StoryLink));
                    break;
                }
                her_outputIndex++;
            }

            // Show the closing line break, if any
            if (output != null)
            {
                uiTextPlayer.DisplayOutput(output);
            }

            // Play the match light sound
            if (!her_done)
            {
                her_sfxMatchLight.Play();
                her_cursorFlame.SetTrigger("light");
            }

            her_lineTriggered = true;
        }
        else if (her_lineTriggered && color.a <= her_alphaLineTriggerDown)
        {
            her_lineTriggered = false;
        }

        her_lastMousePos = Input.mousePosition;
    }