示例#1
0
 /**
  * Event: On highlight quest
  */
 public void OnHighlight(QuestManager.Quest quest)
 {
     foreach(OnHighlightDelegate callback in highlightCallbacks)
     {
         callback(quest);
     }
 }
        /**
         * Event: Begin quest
         */
        public void OnBeginQuest(QuestManager.Quest quest)
        {
            this.SetImage(quest.image.Value);
            this.SetHeading("Quest started");
            this.SetBody(quest.title);

            if(this.GetComponent<Interpolator>() != null)
            {
                this.GetComponent<Interpolator>().SetAllDelays(this.delay);
                this.GetComponent<Interpolator>().Play(true);
            }
        }
        /**
         * Event: Progress objective
         */
        public void OnProgresssObjective(QuestManager.Objective objective)
        {
            QuestManager.Quest quest = objective.GetQuest();

            this.SetImage(quest.image.Value);
            this.SetHeading(quest.title);
            this.SetBody(objective.title + "(" + objective.progress + "/" + objective.goal + ")");

            if(this.GetComponent<Interpolator>() != null)
            {
                this.GetComponent<Interpolator>().SetAllDelays(this.delay);
                this.GetComponent<Interpolator>().Play(true);
            }
        }
        /**
         * Event: On highlight
         */
        public void OnHighlight(QuestManager.Quest quest)
        {
            if(this.title != null)
            {
                this.title.text = quest.title;
            }

            if(this.description != null)
            {
                this.description.text = quest.description;
            }

            if(this.image != null)
            {
                this.image.sprite = quest.image.Value;
            }
        }
        public void OnProgress(QuestManager.Objective objective = null)
        {
            QuestManager.Quest quest = QuestManager.GetCurrentQuest();
            QuestManager.Objective obj = quest.GetCurrentObjective();
            UIText label = this.GetComponent<UIText>();

            if(obj != null && label != null)
            {
                string output = pattern;

                output = output.Replace("{{quest_title}}", quest.title);
                output = output.Replace("{{objective_title}}", obj.title);
                output = output.Replace("{{objective_progress}}", obj.progress.ToString());
                output = output.Replace("{{objective_goal}}", obj.goal.ToString());

                label.text = output;
            }
        }
示例#6
0
        /**
         * Creates a list item
         */
        private void CreateListItem(QuestManager.Quest quest)
        {
            int index = this.transform.childCount - 1;

            // Init
            Button listItem = Instantiate(this.listItemTemplate);
            listItem.gameObject.SetActive(true);
            listItem.name = quest.title;

            // Text
            Text label = listItem.GetComponentInChildren<Text>();
            label.text = quest.title;

            // Position
            listItem.transform.SetParent(this.transform);
            listItem.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, index * this.listItemTemplate.GetComponent<RectTransform>().rect.height);
            listItem.GetComponent<RectTransform>().sizeDelta = listItemTemplate.GetComponent<RectTransform>().sizeDelta;

            // Event
            listItem.onClick.AddListener(() => {
                OnHighlight(quest);
            });
        }
示例#7
0
        /**
         * Gets an instance of this manager
         */
        public static QuestManager GetInstance()
        {
            if(instance == null)
            {
                instance = ManagerBase.GetManagerInstance<QuestManager>();
            }

            return instance;
        }