Пример #1
0
    public virtual IEnumerator ShowStory(List <ChapterData> chapterDatas)
    {
        canvasGroup.alpha = 1;
        for (int i = 0; i < data.chapterData.Count; i++)
        {
            txt.text = "";

            StartCoroutine(ChangeCharacter(
                               data.GetCharacter(data.chapterData[i].Character1),
                               data.GetCharacter(data.chapterData[i].Character2),
                               data.chapterData[i].Highlight,
                               data.GetScene(data.chapterData[i].Scene)));

            data.durationTime = 0.05f;

            if (data.nextPart && txt.text.Length == data.chapterData[i].Dialogue.Length)
            {
                data.nextPart = false;
                continue;
            }
            else if (data.nextPart)
            {
                txt.text = data.chapterData[i].Dialogue;
            }
            else
            {
                for (int j = 0; j < data.chapterData[i].Dialogue.Length; j++)
                {
                    txt.text += data.chapterData[i].Dialogue[j];
                    yield return(new WaitForSecondsRealtime(0.01f));
                }
            }


            data.nextPart = false;
            float timer = 0;
            while (!data.nextPart)
            {
                timer += Time.deltaTime;
                if (timer > idleTime)
                {
                    canvasGroup.alpha = 0;
                }
                if (timer > idleTime + closeTime)
                {
                    data.nextPart     = true;
                    canvasGroup.alpha = 1;
                }

                yield return(null);
            }
            data.nextPart = false;
        }
        StartCoroutine(FinishStory());
    }
Пример #2
0
    public virtual IEnumerator ShowStory(List <ChapterData> chapterDatas)
    {
        for (int i = 0; i < data.chapterData.Count; i++)
        {
            txt.text = "";

            StartCoroutine(ChangeCharacter(
                               data.GetCharacter(data.chapterData[i].Character1),
                               data.GetCharacter(data.chapterData[i].Character2),
                               data.chapterData[i].Highlight,
                               data.GetScene(data.chapterData[i].Scene)));

            data.durationTime = 0.05f;

            for (int j = 0; j < data.chapterData[i].Dialogue.Length; j++)
            {
                txt.text += data.chapterData[i].Dialogue[j];
                yield return(new WaitForSecondsRealtime(0.01f));

                if (data.nextPart)
                {
                    txt.text      = data.chapterData[i].Dialogue;
                    j             = data.chapterData[i].Dialogue.Length;
                    data.nextPart = false;
                }
            }
            float timer = 0;
            while (!data.nextPart)
            {
                yield return(null);

                timer += Time.deltaTime;
                if (timer > 10)
                {
                    data.nextPart = true;
                }
            }
            data.nextPart = false;
        }
        StartCoroutine(FinishStory());
    }