Exemple #1
0
    IEnumerator OnAdvanceStory()
    {
        if (story.canContinue)
        {
            ChoiceGroupView   choiceView  = null;
            ChevronButtonView chevronView = null;
            while (story.canContinue)
            {
                string      content     = story.Continue().Trim();
                ContentView contentView = CreateContentView(content);
                if (!story.canContinue)
                {
                    if (story.currentChoices.Count > 0)
                    {
                        choiceView = CreateChoiceGroupView(story.currentChoices);
                    }
                    else
                    {
                        chevronView = CreateChevronView();
                    }
                }
                while (contentView.textTyper.typing)
                {
                    yield return(null);
                }
                if (story.canContinue)
                {
                    yield return(new WaitForSeconds(Mathf.Min(0.8f, contentView.textTyper.targetText.Length * 0.01f)));
                }
            }
            if (story.currentChoices.Count > 0)
            {
                yield return(new WaitForSeconds(0.01f));

                choiceView.RenderChoices();
                yield return(new WaitForSeconds(0.01f));
            }
            else
            {
                chevronView.Render();
                yield return(new WaitForSeconds(0.2f));
            }
        }
        else
        {
            yield return(new WaitForSeconds(0.2f));

            CreateChevronView();
        }
    }
    IEnumerator OnAdvanceStory()
    {
        if (story.canContinue)
        {
            ChoiceGroupView   choiceView  = null;
            ChevronButtonView chevronView = null;
            while (story.canContinue)
            {
                string content = story.Continue().Trim();
                if (content.StartsWith("FONT_OLD"))
                {
                    content = content.Substring(9);
                }
                bool append = false;
                bool delete = false;
                foreach (String tag in story.currentTags)
                {
                    if (tag.Contains("="))
                    {
                        string[] tagValue = tag.Split('=');
                        if (tagValue[0] == "Filename")
                        {
                            filenameText.text = tagValue[1];
                        }
                        if (tagValue[0] == "SetTime")
                        {
                            timeText.text = tagValue[1];
                            string[] timeSplit = tagValue[1].Split(':');
                            if (int.TryParse(timeSplit[0], out hourTime))
                            {
                                if (int.TryParse(timeSplit[1].Substring(0, 2), out minuteTime))
                                {
                                    outsideOfTime = false;
                                }
                                else
                                {                                // couldn't parse minutes
                                    outsideOfTime = true;
                                }
                            }
                            else
                            {
                                outsideOfTime = true;
                            }
                        }
                        if (tagValue[0] == "AddMinutes")
                        {
                            int newMinutes = 0;
                            if (int.TryParse(tagValue[1], out newMinutes))
                            {
                                minuteTime = minuteTime + newMinutes;
                                if (minuteTime > 60)
                                {
                                    hourTime   = hourTime + 1;
                                    minuteTime = minuteTime - 60;
                                }
                                if (minuteTime < 10)
                                {
                                    timeText.text = hourTime + ":0" + minuteTime + "pm";
                                }
                                else
                                {
                                    timeText.text = hourTime + ":" + minuteTime + "pm";
                                }
                            }
                            else
                            {
                                Debug.LogWarning("AddMinutes not given a number! " + tagValue[1]);
                            }
                        }
                        if (tagValue[0] == "SetDate")
                        {
                            dateText.text = tagValue[1];
                        }
                        if (tagValue[0] == "SetSeal")
                        {
                            int index = int.Parse(tagValue[1]);
                            contentManager.sealImage.sprite = sealImages[index];
                        }
                        if (tagValue[0] == "EndBack")
                        {
                            if (tagValue[1] == "blood")
                            {
                                endBackground.sprite = endBlood;
                            }
                        }
                    }
                    else
                    {
                        if (tag == "Append")
                        {
                            append = true;
                        }
                        else if (tag == "Delete")
                        {
                            delete = true;
                        }
                    }
                }
                if (content.Length > 0 || delete)
                {
                    ContentView contentView;
                    if (append)
                    {
                        contentView = AppendToLastContentView(content);
                    }
                    else if (delete)
                    {
                        contentView = DeleteLastContentView(content);
                    }
                    else
                    {
                        contentView = CreateContentView(content);
                    }

                    if (!story.canContinue)
                    {
                        if (story.currentChoices.Count > 0)
                        {
                            choiceView = CreateChoiceGroupView(story.currentChoices);
                        }
                        else
                        {
                            while (contentView.textTyper.typing)
                            {
                                Debug.Log("wait to make end chevron");
                                yield return(null);
                            }
                            CreateEmptyView(100f);
                            yield return(new WaitForSeconds(1.5f));

                            chevronView = CreateChevronView();
                        }
                    }
                    while (contentView.textTyper.typing)
                    {
                        yield return(null);
                    }

                    if (delete)
                    {
                        Destroy(contentView.gameObject);
                    }
                    if (story.canContinue)
                    {
                        yield return(new WaitForSeconds(Mathf.Min(1.0f, contentView.textTyper.targetText.Length * 0.01f)));
                    }
                }
                else
                {
                    if (!story.canContinue)
                    {
                        if (story.currentChoices.Count > 0)
                        {
                            choiceView = CreateChoiceGroupView(story.currentChoices);
                        }
                        else
                        {
                            //chevronView = CreateChevronView();
                        }
                    }
                }
            }
            if (story.currentChoices.Count > 0)
            {
                yield return(new WaitForSeconds(1f));

                choiceView.RenderChoices();
                yield return(new WaitForSeconds(0.5f));
            }
            else                 // finished typing out, can't continue and no choices
            {
                bool foundMeeting = false;
                foreach (String tag in story.currentTags)
                {
                    Debug.Log("Read tag " + tag);
                    if (tag.Contains("="))
                    {
                        string[] tagValue = tag.Split('=');
                        if (tagValue[0] == "NextMeeting")
                        {
                            Debug.Log("Trying to go to " + tagValue[1]);
                            StartCoroutine(FadeBetweenMeetings(tagValue[1]));
                            foundMeeting = true;
                        }
                        if (tagValue[0] == "Ending")
                        {
                            Debug.Log("Trying to go to " + tagValue[1]);
                            StartCoroutine(FadeBetweenMeetings(tagValue[1], true));
                            foundMeeting = true;
                        }
                    }
                }
                if (!foundMeeting)
                {
                    chevronView.Render();
                }
                yield return(new WaitForSeconds(2));
            }
        }
        else
        {
            yield return(new WaitForSeconds(2));

            CreateChevronView();
        }
    }
    IEnumerator OnAdvanceStory()
    {
        if (story.canContinue)
        {
            ChoiceGroupView   choiceView  = null;
            ChevronButtonView chevronView = null;
            while (story.canContinue)
            {
                string content = story.Continue().Trim();

                string[] splitArray = content.Split('#');

                if (splitArray.Length > 1)
                {
                    Debug.Log("this is after the #: " + splitArray [1]);
                    AudioClipDatabase.Instance.AnalyzeAudioTag(splitArray [1]);

                    content = splitArray [0];
                    Debug.Log("this.content = " + splitArray [0]);
                }



                ContentView contentView = CreateContentView(content);
                if (!story.canContinue)
                {
                    if (story.currentChoices.Count > 0)
                    {
                        choiceView = CreateChoiceGroupView(story.currentChoices);
                    }
                    else
                    {
                        chevronView = CreateChevronView();
                    }
                }
                while (contentView.textTyper.typing)
                {
                    yield return(null);
                }
                if (story.canContinue)
                {
                    yield return(new WaitForSeconds(Mathf.Min(1.0f, contentView.textTyper.targetText.Length * 0.01f)));
                }
            }
            if (story.currentChoices.Count > 0)
            {
                yield return(new WaitForSeconds(1f));

                choiceView.RenderChoices();
                yield return(new WaitForSeconds(0.5f));
            }
            else
            {
                chevronView.Render();
                yield return(new WaitForSeconds(2));
            }
        }
        else
        {
            yield return(new WaitForSeconds(2));

            CreateChevronView();
        }
    }