protected void SetQuestDetails(UnityUIQuestTemplate questControl, QuestInfo questInfo)
        { 
            // Set details if this is the selected quest:
            if (IsSelectedQuest(questInfo))
            {

                // Set the description:
                if (questHeadingSource == QuestHeadingSource.Name)
                {
                    questControl.description.text = questInfo.Description.text;
                    Tools.SetGameObjectActive(questControl.description, true);
                }

                // Set the entry description:
                if (questInfo.EntryStates.Length > 0)
                {
                    for (int i = 0; i < questInfo.Entries.Length; i++)
                    {
                        questControl.AddEntryDescription(questInfo.Entries[i].text, questInfo.EntryStates[i]);
                    }
                }

                UnityUIQuestTitle unityUIQuestTitle = null;

                // Set the track button:
                if (questControl.trackButton != null)
                {
                    unityUIQuestTitle = questControl.trackButton.gameObject.AddComponent<UnityUIQuestTitle>();
                    unityUIQuestTitle.questTitle = questInfo.Title;
                    questControl.trackButton.onClick.RemoveListener(() => ClickTrackQuestButton());
                    questControl.trackButton.onClick.AddListener(() => ClickTrackQuestButton());
                    Tools.SetGameObjectActive(questControl.trackButton, questInfo.Trackable);
                }

                // Set the abandon button:
                if (questControl.abandonButton != null)
                {
                    unityUIQuestTitle = questControl.abandonButton.gameObject.AddComponent<UnityUIQuestTitle>();
                    unityUIQuestTitle.questTitle = questInfo.Title;
                    questControl.abandonButton.onClick.RemoveListener(() => ClickAbandonQuestButton());
                    questControl.abandonButton.onClick.AddListener(() => ClickAbandonQuestButton());
                    Tools.SetGameObjectActive(questControl.abandonButton, questInfo.Abandonable);
                }
            }
            else
            {
                Tools.SetGameObjectActive(questControl.description, false);
                Tools.SetGameObjectActive(questControl.entryDescription, false);
                Tools.SetGameObjectActive(questControl.trackButton, false);
                Tools.SetGameObjectActive(questControl.abandonButton, false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Adds a quest to the table using the template.
        /// </summary>
        /// <param name="questInfo">Quest info.</param>
        private void AddQuestToTable(QuestInfo questInfo, int questIndex)
        {
            if ((questTable == null) || (questTemplate == null) || !questTemplate.ArePropertiesAssigned)
            {
                return;
            }

            // Instantiate a copy of the template:
            GameObject questGameObject = Instantiate(questTemplate.gameObject) as GameObject;

            if (questGameObject == null)
            {
                Debug.LogError(string.Format("{0}: {1} couldn't instantiate quest template", new object[] { DialogueDebug.Prefix, name }));
                return;
            }
            questGameObject.name = questInfo.Heading.text;
            questGameObject.transform.SetParent(questTable.transform, false);
            questGameObject.SetActive(true);
            UnityUIQuestTemplate questControl = questGameObject.GetComponent <UnityUIQuestTemplate>();

            if (questControl == null)
            {
                return;
            }
            questControl.Initialize();

            // Set the heading button:
            var questHeadingButton = questControl.heading;
            var heading            = questHeadingButton.GetComponentInChildren <UnityEngine.UI.Text>();

            if (heading != null)
            {
                heading.text = questInfo.Heading.text;
            }
            questHeadingButton.onClick.AddListener(() => ClickQuestFoldout(questInfo.Title));

            // Set details if this is the selected quest:
            if (IsSelectedQuest(questInfo))
            {
                // Set the description:
                if (questHeadingSource == QuestHeadingSource.Name)
                {
                    questControl.description.text = questInfo.Description.text;
                    Tools.SetGameObjectActive(questControl.description, true);
                }

                // Set the entry description:
                if (questInfo.EntryStates.Length > 0)
                {
                    for (int i = 0; i < questInfo.Entries.Length; i++)
                    {
                        questControl.AddEntryDescription(questInfo.Entries[i].text, questInfo.EntryStates[i]);
                    }
                }

                UnityUIQuestTitle unityUIQuestTitle = null;

                // Set the track button:
                if (questControl.trackButton != null)
                {
                    unityUIQuestTitle            = questControl.trackButton.gameObject.AddComponent <UnityUIQuestTitle>();
                    unityUIQuestTitle.questTitle = questInfo.Title;
                    questControl.trackButton.onClick.RemoveListener(() => ClickTrackQuestButton());
                    questControl.trackButton.onClick.AddListener(() => ClickTrackQuestButton());
                    Tools.SetGameObjectActive(questControl.trackButton, questInfo.Trackable);
                }

                // Set the abandon button:
                if (questControl.abandonButton != null)
                {
                    unityUIQuestTitle            = questControl.abandonButton.gameObject.AddComponent <UnityUIQuestTitle>();
                    unityUIQuestTitle.questTitle = questInfo.Title;
                    questControl.abandonButton.onClick.RemoveListener(() => ClickAbandonQuestButton());
                    questControl.abandonButton.onClick.AddListener(() => ClickAbandonQuestButton());
                    Tools.SetGameObjectActive(questControl.abandonButton, questInfo.Abandonable);
                }
            }
            else
            {
                Tools.SetGameObjectActive(questControl.description, false);
                Tools.SetGameObjectActive(questControl.entryDescription, false);
                Tools.SetGameObjectActive(questControl.trackButton, false);
                Tools.SetGameObjectActive(questControl.abandonButton, false);
            }
        }