コード例 #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;
    }
コード例 #2
0
    // .............
    // Cursor

    void CursorSet(RectTransform prefab, float fadeIn = 0f)
    {
        Image       img   = null;
        CanvasGroup group = null;

        // Stop any cursor fades
        img   = this.cursor.GetComponentInChildren <Image>();
        group = this.cursor.GetComponentInChildren <CanvasGroup>();

        if (group != null)
        {
            ImageFade.Stop(group, this);
        }
        else if (img != null)
        {
            ImageFade.Stop(img);
        }

        // Remove all cursor content
        for (int i = 0; i < this.cursor.childCount; i++)
        {
            GameObject.Destroy(this.cursor.GetChild(i).gameObject);
        }

        this.cursor.DetachChildren();

        // Create a new cursor
        RectTransform child = Instantiate(prefab);

        child.SetParent(this.cursor);
        child.localPosition = prefab.localPosition;
        child.localScale    = prefab.localScale;

        if (fadeIn > 0f)
        {
            group = child.GetComponent <CanvasGroup>();
            img   = child.GetComponent <Image>();

            if (group != null)
            {
                group.alpha = 0f;
            }
            else if (img != null)
            {
                Color c = img.color;
                c.a       = 0f;
                img.color = c;
            }
        }

        CursorShow(fadeIn);
    }
コード例 #3
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;
    }