예제 #1
0
    IEnumerator ShowPara()
    {
        StoryPara para = currentStory[currentPara];

        if (!para.IsTag)
        {
            storyBoard.AddText(para.x, para.y);
            currentChar = 0;
            float time      = 0f;
            float efxTime   = 0f;
            bool  isSpeedUp = false;
            while (currentChar < para.Length)
            {
                yield return(null);

                if (STBInput.GetButtonDown("Next"))
                {
                    isSpeedUp = true;
                }
                if (STBInput.GetButtonUp("Next"))
                {
                    isSpeedUp = false;
                }
                if (STBInput.GetButton("Skip"))
                {
                    currentChar = para.Length - 1;
                }

                time    += Time.deltaTime * (isSpeedUp ? 5f : 1f);
                efxTime += Time.deltaTime;

                if (time > TEXT_GAP)
                {
                    currentChar++;
                    if (efxTime >= TEXT_GAP)
                    {
                        SoundManager.instance.PlayUiEfx(UiEfx.TEXT);
                        while (efxTime >= TEXT_GAP)
                        {
                            efxTime -= TEXT_GAP;
                        }
                    }
                    storyBoard.SetText(para.Substring(currentChar));
                    if (para.GetChar(currentChar - 1).Equals('\n'))
                    {
                        time -= TEXT_GAP * 5f;
                    }
                    else
                    {
                        time -= TEXT_GAP;
                    }
                }
            }
            isParaOver = true;
            paraEndMark.Set(GetActPos(storyBoard.GetEndPosition()));
            currentPara++;
            para = currentStory[currentPara];
        }

        if (para.IsTag)
        {
            currentPara++;
            if (para.IsBgmPlay)
            {
                SoundManager.instance.PlayBgm(bgm, 2f);
            }
            if (para.IsBgmStop)
            {
                SoundManager.instance.StopBgm(1f);
            }
            if (para.IsPageEnd)
            {
                paraEndMark.Hide();
                pageEndMark.Set();
                isPageOver = true;
                yield break;
            }
            if (para.IsClipEnd)
            {
                OnSceneEnd();
                yield break;
            }
            if (!isParaOver)
            {
                StartCoroutine(ShowPara());
            }
        }
    }