Esempio n. 1
0
    private void Update()
    {
        if (!nextStep)
        {
            return;
        }

        if (!firstStep)
        {
            for (int i = 0; i < buttons.childCount; i++)
            {
                Destroy(buttons.GetChild(i).gameObject);
            }
            panelSizedButton.interactable = false;
        }

        string sentences = "";

        while (inkStory.canContinue)
        {
            sentences += inkStory.Continue();
            var tags = inkStory.currentTags;
            if (storyScript)
            {
                foreach (var tag in tags)
                {
                    storyScript.InProcessTag(tag, this, inkStory);
                }
            }
            else if ((inkFile.name == "$cat_whitey") || (inkFile.name == "$cat_cutey"))
            {
                foreach (var tag in tags)
                {
                    string op, data;
                    StoryScript.StandardizationTag(tag, out op, out data);
                    if (op == "upd_info")
                    {
                        PlayerInfo.UpdateFromInkStory(inkStory);
                    }
                }
                StoryManager.Instance.refreshFlag = true;
            }
        }
        if (sentences != "")
        {
            SetText(sentences);
            if (speaker)
            {
                SetName(speaker.npcName);
            }
            else
            {
                nameText.text = "";
            }
            LogPanel.Instance.AddLog(nameText.text, sentences.Replace("$", string.Empty), false);
        }

        foreach (var choice in inkStory.currentChoices)
        {
            panelSizedButton.interactable = true;
            panelSizedButton.onClick.RemoveAllListeners();

            if (choice.text == "n")
            {
                var path = choice.pathStringOnChoice;
                panelSizedButton.onClick.AddListener(() => { ChoicePathSelected(path); });
            }
            else
            {
                panelSizedButton.onClick.AddListener(
                    () =>
                {
                    if (!isFinish)
                    {
                        ChoicePathSelected();
                    }
                    panelSizedButton.interactable = false;
                }
                    );
                var btn = Instantiate(button).GetComponent <Button>();
                btn.transform.SetParent(buttons);
                btn.transform.localScale = Vector3.one;

                var btnText = btn.GetComponentInChildren <TextMeshProUGUI>();
                btnText.text = choice.text;

                var path = choice.pathStringOnChoice;
                btn.onClick.AddListener(() => { ChoicePathSelected(path, true, choice.text); });
            }
        }

        nextStep = false;

        if (firstStep && sentences == "" && inkStory.currentChoices.Count == 1)
        {
            ChoicePathSelected(inkStory.currentChoices[0].pathStringOnChoice, true,
                               inkStory.currentChoices[0].text);
        }

        firstStep = false;

        if (!inkStory.canContinue && inkStory.currentChoices.Count == 0)
        {
            EndTalk();
        }
    }
Esempio n. 2
0
    private void Update()
    {
        if (!nextStep)
        {
            return;
        }

        if (!firstStep)
        {
            for (int i = 0; i < buttons.childCount; i++)
            {
                Destroy(buttons.GetChild(i).gameObject);
            }
            panelSizedButton.gameObject.SetActive(false);
        }

        string sentences = "";

        while (inkStory.canContinue)
        {
            sentences += inkStory.Continue();
            var tags = inkStory.currentTags;
            if (storyScript)
            {
                foreach (var tag in tags)
                {
                    storyScript.InProcessTag(tag, this, inkStory);
                }
            }
        }
        if (sentences != "")
        {
            text.text = sentences;
        }

        foreach (var choice in inkStory.currentChoices)
        {
            if (choice.text == "n")
            {
                panelSizedButton.gameObject.SetActive(true);
                var path = choice.pathStringOnChoice;
                panelSizedButton.onClick.RemoveAllListeners();
                panelSizedButton.onClick.AddListener(() => { ChoicePathSelected(path); });
            }
            else
            {
                var btn = Instantiate(button).GetComponent <Button>();
                btn.transform.SetParent(buttons);
                btn.transform.localScale = Vector3.one;

                var btnText = btn.GetComponentInChildren <TextMeshProUGUI>();
                btnText.text = choice.text;

                var path = choice.pathStringOnChoice;
                btn.onClick.AddListener(() => { ChoicePathSelected(path); });
            }
        }

        nextStep = false;

        if (firstStep && sentences == "" && inkStory.currentChoices.Count == 1)
        {
            ChoicePathSelected(inkStory.currentChoices[0].pathStringOnChoice);
        }

        firstStep = false;

        if (!inkStory.canContinue && inkStory.currentChoices.Count == 0)
        {
            EndTalk();
        }
    }