// Show a list of options, and wait for the player to make a selection.
        public override IEnumerator RunOptions(Yarn.Options optionsCollection,
                                               Yarn.OptionChooser optionChooser)
        {
            // Do a little bit of safety checking
            if (optionsCollection.options.Count > optionButtons.Count)
            {
                Debug.LogWarning("There are more options to present than there are" +
                                 "buttons to present them in. This will cause problems.");
            }

            // Display each option in a button, and make it visible
            int i = 0;

            foreach (var optionString in optionsCollection.options)
            {
                optionButtons [i].gameObject.SetActive(true);
                optionButtons [i].GetComponentInChildren <Text> ().text = optionString;
                i++;
            }

            // Record that we're using it
            SetSelectedOption = optionChooser;

            // Wait until the chooser has been used and then removed (see SetOption below)
            while (SetSelectedOption != null)
            {
                yield return(null);
            }

            // Hide all the buttons
            foreach (var button in optionButtons)
            {
                button.gameObject.SetActive(false);
            }
        }
        private void RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser)
        {
            optionStrings = new string[optionsCollection.options.Count];

            for (int i = 0; i < optionStrings.Length; i++)
            {
                optionStrings[i] = optionsCollection.options[i];
            }

            inputOption        = -1;
            this.optionChooser = optionChooser;
        }
        public void RunOptions (Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser)
        {
            // Display each option in a button, and make it visible
            optionStrings = new string[optionsCollection.options.Count];
            for(int i=0; i<optionStrings.Length; i++)
            {
                optionStrings[i] = optionsCollection.options[i];
            }

            inputOption = -1;
            this.optionChooser = optionChooser;
        }
        // Show a list of options, and wait for the player to make a selection.
        public override IEnumerator RunOptions(Yarn.Options optionsCollection,
                                               Yarn.OptionChooser optionChooser)
        {
            // Do a little bit of safety checking
            if (optionsCollection.options.Count > optionButtons.Count)
            {
                Debug.LogWarning("There are more options to present than there are" +
                                 "buttons to present them in. This will cause problems.");
            }

            // Display each option in a button, and make it visible
            int i = 0;

            foreach (var optionString in optionsCollection.options)
            {
                optionButtons [i].gameObject.SetActive(true);
                optionButtons [i].GetComponentInChildren <Text> ().text = optionString;
                i++;
            }

            // Record that we're using it
            SetSelectedOption = optionChooser;

            //set currently selected option in event system
            events.SetSelectedGameObject(optionButtons[0].gameObject, new BaseEventData(events));

            //optionButtons[0].Select();
            //print(optionButtons[0].spriteState);
            // = optionButtons[0].spriteState.highlightedSprite;

            // Wait until the chooser has been used and then removed (see SetOption below)
            while (SetSelectedOption != null)
            {
                print("events selected" + events.currentSelectedGameObject);
                yield return(null);
            }

            // Hide all the buttons
            foreach (var button in optionButtons)
            {
                button.gameObject.SetActive(false);
            }
        }
示例#5
0
        /// Show a list of options, and wait for the player to make a selection.
        public override IEnumerator RunOptions(Yarn.Options optionsCollection,
                                               Yarn.OptionChooser optionChooser)
        {
            messageInput.GetComponentInChildren <Text>().text = "";
            // Do a little bit of safety checking
            if (optionsCollection.options.Count > optionButtons.Count)
            {
                Debug.LogWarning("There are more options to present than there are" +
                                 "buttons to present them in. This will cause problems.");
            }

            // Display each option in a button, and make it visible
            int i = 0;

            foreach (var optionString in optionsCollection.options)
            {
                optionButtons[i].gameObject.SetActive(true);
                optionButtons[i].GetComponentInChildren <Text>().text = (i + 1).ToString() + ". " + optionString;
                i++;
            }

            // Record that we're using it
            SetSelectedOption = optionChooser;

            // Wait until the chooser has been used and then removed (see SetOption below)
            while (SetSelectedOption != null)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (Input.GetKeyDown((j + 1).ToString()) && optionButtons[j].gameObject.activeInHierarchy)
                    {
                        SetOption(j);
                        //HideOptions();
                    }
                }
                yield return(null);
            }
            // Hide all the buttons
            //HideOptions();
        }
示例#6
0
        /// Show a list of options, and wait for the player to make a selection.
        public override IEnumerator RunOptions(Yarn.Options optionsCollection,
                                               Yarn.OptionChooser optionChooser)
        {
            // Do a little bit of safety checking
            if (optionsCollection.options.Count > optionButtons.Count)
            {
                Debug.LogWarning("There are more options to present than there are" +
                                 "buttons to present them in. This will cause problems.");
            }
            isActive = true;
            // Display each option in a button, and make it visible
            int  i        = 0;
            bool needItem = false;

            foreach (var optionString in optionsCollection.options)
            {
                optionButtons[i].gameObject.SetActive(true);
                optionButtons[i].GetComponent <SelectableOption>().UpdateText(optionString);
                if (optionString.Contains("Item"))
                {
                    needItem = true;
                }
                i++;
            }
            m_tradingUIManager.ShowItemButton(needItem);
            // Record that we're using it
            SetSelectedOption = optionChooser;

            // Wait until the chooser has been used and then removed (see SetOption below)
            while (SetSelectedOption != null)
            {
                yield return(null);
            }
            // Hide all the buttons
            foreach (var button in optionButtons)
            {
                button.gameObject.SetActive(false);
            }
            isActive = false;
        }
示例#7
0
 /// Display the options, and call the optionChooser when done.
 public abstract IEnumerator RunOptions(Yarn.Options optionsCollection,
                                        Yarn.OptionChooser optionChooser);
        // Show a list of options, and wait for the player to make a selection.
        public override IEnumerator RunOptions(Yarn.Options optionsCollection,
                                               Yarn.OptionChooser optionChooser)
        {
            // Do a little bit of safety checking
            if (optionsCollection.options.Count > optionIndicators.Length)
            {
                Debug.LogWarning("There are more options to present than there are" +
                                 "indicators to display. This will cause problems.");
            }

            PositionBubble(playerName);                                                   //show bubble over player because we're deciding dialogue

            #region ShowOptionUI
            optionIndicators[0].transform.parent.GetComponent <LayoutElement>().ignoreLayout = false; //make indicator parent respond to layout
            for (int i = 0; i < optionsCollection.options.Count; i++)                                 //for every dialogue option
            {
                optionIndicators[i].SetActive(true);                                                  //enable option indicators
                optionsCollection.options[i] = AddLineBreaks(optionsCollection.options[i]);           //add line breaks to the option text
            }
            foreach (GameObject arrow in arrows)                                                      //enable arrows
            {
                arrow.SetActive(true);
            }
            stemImage.enabled = false;                                                              //disable stem image because we're thinking
            optionPanelLayout.padding.left = optionPanelLayout.padding.right = Mathf.RoundToInt(layoutPaddings[1].x);
            optionPanelLayout.padding.top  = optionPanelLayout.padding.bottom = Mathf.RoundToInt(layoutPaddings[1].y);
            #endregion

            int currentlyDisplayedOption = 0;                                                             //keep track of what option we're on
            DisplayOption(optionsCollection.options[currentlyDisplayedOption], currentlyDisplayedOption); //display first option by default

            SetSelectedOption = optionChooser;                                                            //Record that we're using it
            bool axisReady = true;                                                                        //so the joystick has to go back to zero before you can change again

            yield return(new WaitForSeconds(.1f));

            while (SetSelectedOption != null)               // Wait until the chooser has been used and then removed (see SetOption below)
            {
                #region GetChangeInput
                float h = Input.GetAxis("Horizontal");
                if (h > deadZone && axisReady)
                {
                    if (currentlyDisplayedOption < optionsCollection.options.Count - 1)
                    {
                        currentlyDisplayedOption++;
                    }
                    else
                    {
                        currentlyDisplayedOption = 0;
                    }
                    DisplayOption(optionsCollection.options[currentlyDisplayedOption], currentlyDisplayedOption);
                    axisReady = false;
                }
                else if (h < -deadZone && axisReady)
                {
                    if (currentlyDisplayedOption < 1)
                    {
                        currentlyDisplayedOption = optionsCollection.options.Count - 1;
                    }
                    else
                    {
                        currentlyDisplayedOption--;
                    }
                    DisplayOption(optionsCollection.options[currentlyDisplayedOption], currentlyDisplayedOption);
                    axisReady = false;
                }
                else if (h < deadZone && h > -deadZone && !axisReady)
                {
                    axisReady = true;
                }
                #endregion
                #region GetSelectInput
                if (Input.GetButtonDown("Interact"))
                {
                    SetOption(currentlyDisplayedOption);
                    yield return(null);
                }
                #endregion
                yield return(null);
            }
            #region HideOptionUI
            optionIndicators[0].transform.parent.GetComponent <LayoutElement>().ignoreLayout = true; //make indicator parent not respond to layout
            for (int i = 0; i < optionsCollection.options.Count; i++)                                //for every dialogue option
            {
                optionIndicators[i].SetActive(false);                                                //disable option indicators
            }
            foreach (GameObject arrow in arrows)                                                     //enable arrows
            {
                arrow.SetActive(false);
            }
            stemImage.enabled = true;                                                              //disable stem image because we're thinking
            optionPanelLayout.padding.left = optionPanelLayout.padding.right = Mathf.RoundToInt(layoutPaddings[0].x);
            optionPanelLayout.padding.top  = optionPanelLayout.padding.bottom = Mathf.RoundToInt(layoutPaddings[0].y);
            #endregion
        }
示例#9
0
 /// Show a list of options, and wait for the player to make a selection.
 public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser)
 {
     yield break;
 }
示例#10
0
        /// Show a list of options, and wait for the player to make a selection.
        public override IEnumerator RunOptions(Yarn.Options optionsCollection,
                                               Yarn.OptionChooser optionChooser)
        {
            // Do a little bit of safety checking
            if (optionsCollection.options.Count > optionButtons.Count)
            {
                Debug.LogWarning("There are more options to present than there are" +
                                 "buttons to present them in. This will cause problems.");
            }

            // Display each option in a button, and make it visible
            openToOptions = true;
            //highlight.gameObject.SetActive(true);
            highlightOption    = 0;
            accidentPrevention = 0;
            int i = 0;

            foreach (var optionString in optionsCollection.options)
            {
                optionButtons [i].gameObject.SetActive(true);
                optionButtons [i].GetComponentInChildren <Text> ().text = optionString;
                i++;
            }
            optionCount = i;

            // Record that we're using it
            SetSelectedOption = optionChooser;

            //highlight.transform.position = optionButtons[highlightOption].transform.position;

            // Wait until the chooser has been used and then removed (see SetOption below)
            while (SetSelectedOption != null)
            {
                if (accidentPrevention < 0.5f)
                {
                    accidentPrevention += Time.deltaTime;
                }
                //highlight.transform.position = optionButtons[highlightOption].transform.position;
                for (int x = 0; x < buttonText.Count; x++)
                {
                    if (x == highlightOption)
                    {
                        //optionButtons[x].image.color = new Color(0.56078f, 0.50196f, 0.92549f);
                        ColorBlock cb = optionButtons[x].colors;
                        cb.normalColor = new Color(0.1553724f, 0.137104f, 0.745283f);
                        //cb.normalColor = Color.red;
                        optionButtons[x].colors = cb;
                        buttonText[x].color     = Color.white;
                    }
                    else
                    {
                        //optionButtons[x].image.color = Color.white;
                        ColorBlock cb = optionButtons[x].colors;
                        cb.normalColor          = Color.white;
                        optionButtons[x].colors = cb;
                        buttonText[x].color     = Color.black;
                    }
                }
                //highlight.gameObject.SetActive(true);
                yield return(null);
            }

            // Hide all the buttons
            openToOptions = false;
            //highlight.gameObject.SetActive(false);
            foreach (var button in optionButtons)
            {
                button.gameObject.SetActive(false);
            }
        }