Esempio n. 1
0
    void OnMenuStates()
    {
        LocationPanel.SetActive(true);
        //Need to show the correct image and Location Panel
        while (InkStoryManager.CanContineStory())
        {
            string text = InkStoryManager.GetStoryContent();
            StoryTextUI.text = text;

            List <Choice> choices = InkStoryManager.GetChoices();
            if (choices.Count > 0)
            {
                foreach (Button b in ChoiceButtons)
                {
                    b.gameObject.SetActive(false);
                }
                for (int i = 0; i < choices.Count; i++)
                {
                    GameChoice currentChoice = new GameChoice
                    {
                        Name  = choices[i].text,
                        Index = choices[i].index
                    };

                    Debug.Log(currentChoice);
                    if (i < ChoiceButtons.Length)
                    {
                        Button button = ChoiceButtons[i];
                        button.gameObject.SetActive(true);
                        button.onClick.RemoveAllListeners();
                        button.GetComponentInChildren <Text>().text = choices[i].text;
                        button.onClick.AddListener(() => OnClickButton(currentChoice));
                    }
                }
                GameChoice exitChoice = new GameChoice
                {
                    Name  = choices[choices.Count - 1].text,
                    Index = choices[choices.Count - 1].index
                };
                ExitButton.gameObject.SetActive(true);
                ExitButton.onClick.RemoveAllListeners();
                ExitButton.onClick.AddListener(() => OnClickButton(exitChoice));
            }
        }
    }