Esempio n. 1
0
        /// <summary>
        /// Presents choices based on a specified prefab containing a button and a horizontal/vertical layout group
        /// </summary>
        /// <param name="choices"></param>
        /// <param name="buttonPrefab"></param>
        /// <param name="panel"></param>
        protected Button[] AddChoices(StratusStoryChoice[] choices, Button choicePrefab, LayoutGroup choicesPanel)
        {
            Button[] buttons = new Button[choices.Length];

            // For each given choice,
            for (int i = 0; i < choices.Length; ++i)
            {
                StratusStoryChoice choice = choices[i];
                Button             button = CreateChoiceView(choicePrefab, choicesPanel, choices[i].text.Trim());
                button.onClick.AddListener(delegate
                {
                    SelectChoice(choice);
                });
                buttons[i] = button;
            }
            return(buttons);
        }
Esempio n. 2
0
        /// <summary>
        /// Called upon when a particular choice has been selected
        /// </summary>
        /// <param name="choice"></param>
        public void SelectChoice(StratusStoryChoice choice)
        {
            if (logging)
            {
                StratusDebug.Log(choice.text + " was selected", this);
            }

            // Inform the current conversation of the choice
            var choiceEvent = new StratusStory.SelectChoiceEvent()
            {
                story = this.story, reader = this.reader
            };

            choiceEvent.choice = choice;
            reader.gameObject.Dispatch <StratusStory.SelectChoiceEvent>(choiceEvent);
            StratusScene.Dispatch <StratusStory.SelectChoiceEvent>(choiceEvent);

            // Now do any extra stuff
            OnChoiceSelected();
        }