private string ReplaceSubstringVariables(string sInput)
        {
            string sModified;

            if (sInput.IndexOf("[Scene:") >= 0)
            {
                string       sceneName         = sInput.Substring(8, sInput.Length - 9);
                AIConversant currentConversant = playerConversant.GetCurrentConversant();

                SceneText sceneText = Resources.Load(sceneName) as SceneText;
                sModified = sceneText.GetText(currentConversant.gameObject);
            }
            else
            {
                sModified = sInput;
            }
            sModified = sModified.Replace("[Player]", playerConversant.playerName);
            sModified = sModified.Replace("[]", "    ");
            return(sModified);
        }
示例#2
0
        /// <summary>
        /// Will update the values of each component and the visibility of the three buttons in function of the number of choices available
        /// </summary>
        void UpdateUI()
        {
            if (playerConversant == null)
            {
                return;
            }
            this.gameObject.SetActive(playerConversant.isActive());
            if (!playerConversant.isActive())
            {
                return;
            }
            currentSpeaker.text = playerConversant.GetCurrentConversant();
            dialogueText.text   = playerConversant.GetText();
            List <string> choices = playerConversant.GetChoices();

            closeButton.activate(true);
            closeButton.gameObject.SetActive(true);
            if (choices != null && choices.Count > 0)
            {
                if (choices.Count >= 3)
                {
                    choice3Button.activate(true);
                    choice3Button.gameObject.SetActive(true);
                    choice3Button.GetComponentInChildren <TextMeshProUGUI>().text = choices[2];
                }
                else
                {
                    choice3Button.activate(false);
                    choice3Button.gameObject.SetActive(false);
                }

                if (choices.Count >= 2)
                {
                    choice2Button.activate(true);

                    choice2Button.gameObject.SetActive(true);
                    choice2Button.GetComponentInChildren <TextMeshProUGUI>().text = choices[1];
                }
                else
                {
                    choice2Button.activate(false);
                    choice2Button.gameObject.SetActive(false);
                }

                if (choices.Count >= 1)
                {
                    choice1Button.activate(true);
                    choice1Button.gameObject.SetActive(true);
                    choice1Button.GetComponentInChildren <TextMeshProUGUI>().text = choices[0];
                    GetComponent <UIStateMachine>().changeActiveObject(choice1Button);
                }
            }
            else
            {
                choice1Button.activate(false);
                choice2Button.activate(false);
                choice3Button.activate(false);

                choice1Button.gameObject.SetActive(false);
                choice2Button.gameObject.SetActive(false);
                GetComponent <UIStateMachine>().changeActiveObject(closeButton);

                choice3Button.gameObject.SetActive(false);
            }
        }