Esempio n. 1
0
        public virtual void Repaint(Quest quest)
        {
            if (this.m_Title != null)
            {
                this.m_Title.text = quest != null?quest.Title:"";
            }

            if (this.m_Description != null)
            {
                this.m_Description.text = quest != null?quest.Description:"";
            }

            for (int i = 0; i < this.m_TaskSlotCache.Count; i++)
            {
                this.m_TaskSlotCache[i].gameObject.SetActive(false);
            }

            if (quest != null)
            {
                for (int i = 0; i < quest.tasks.Count; i++)
                {
                    if (!this.m_DisplayTasks.HasFlag <TaskDisplay>(TaskDisplay.Inactive) && quest.tasks[i].Status == Status.Inactive ||
                        !this.m_DisplayTasks.HasFlag <TaskDisplay>(TaskDisplay.Active) && quest.tasks[i].Status == Status.Active ||
                        !this.m_DisplayTasks.HasFlag <TaskDisplay>(TaskDisplay.Completed) && quest.tasks[i].Status == Status.Completed ||
                        !this.m_DisplayTasks.HasFlag <TaskDisplay>(TaskDisplay.Failed) && quest.tasks[i].Status == Status.Failed ||
                        !this.m_DisplayTasks.HasFlag <TaskDisplay>(TaskDisplay.Canceled) && quest.tasks[i].Status == Status.Canceled)
                    {
                        continue;
                    }
                    TaskSlot slot = null;
                    if (i < this.m_TaskSlotCache.Count)
                    {
                        slot = this.m_TaskSlotCache[i];
                    }
                    else
                    {
                        slot = Instantiate(this.m_TaskSlotPrefab);
                        slot.transform.SetParent(this.m_TaskSlotPrefab.transform.parent, false);
                        this.m_TaskSlotCache.Add(slot);
                    }
                    slot.gameObject.SetActive(true);
                    slot.Repaint(quest.tasks[i]);
                }
            }
        }
Esempio n. 2
0
        public virtual void Show(Quest quest)
        {
            base.Show();
            for (int i = 0; i < this.m_TaskSlotCache.Count; i++)
            {
                this.m_TaskSlotCache[i].gameObject.SetActive(false);
            }

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

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



            for (int i = 0; i < quest.tasks.Count; i++)
            {
                TaskSlot slot = null;
                if (i < this.m_TaskSlotCache.Count)
                {
                    slot = this.m_TaskSlotCache[i];
                }
                else
                {
                    slot = Instantiate(this.m_TaskSlotPrefab);
                    slot.transform.SetParent(this.m_TaskSlotPrefab.transform.parent, false);
                    this.m_TaskSlotCache.Add(slot);
                }
                slot.gameObject.SetActive(true);
                slot.Repaint(quest.tasks[i]);
            }

            int count = this.m_RewardParent.childCount;

            for (int i = count - 1; i >= 0; i--)
            {
                DestroyImmediate(m_RewardParent.GetChild(i).gameObject);
            }

            quest.DisplayReward(this.m_RewardParent);

            if (this.m_AcceptButton != null)
            {
                if (quest.CanActivate())
                {
                    this.m_AcceptButton.gameObject.SetActive(true);
                    this.m_AcceptButton.onClick.RemoveAllListeners();
                    this.m_AcceptButton.onClick.AddListener(() =>
                    {
                        quest.Activate();
                        Close();
                    });
                }
                else
                {
                    this.m_AcceptButton.gameObject.SetActive(false);
                }
            }

            if (this.m_DeclineButton != null)
            {
                if (quest.CanActivate())
                {
                    this.m_DeclineButton.gameObject.SetActive(true);
                    this.m_DeclineButton.onClick.RemoveAllListeners();
                    this.m_DeclineButton.onClick.AddListener(() =>
                    {
                        quest.Decline();
                        Close();
                    });
                }
                else
                {
                    this.m_DeclineButton.gameObject.SetActive(false);
                }
            }

            if (this.m_CompleteButton != null)
            {
                if (quest.CanComplete())
                {
                    this.m_CompleteButton.gameObject.SetActive(true);
                    this.m_CompleteButton.onClick.RemoveAllListeners();
                    this.m_CompleteButton.onClick.AddListener(() =>
                    {
                        quest.Complete();
                        Close();
                    });
                }
                else
                {
                    this.m_CompleteButton.gameObject.SetActive(false);
                }
            }

            if (this.m_CancelButton != null)
            {
                if (quest.CanComplete())
                {
                    this.m_CancelButton.gameObject.SetActive(true);
                    this.m_CancelButton.onClick.RemoveAllListeners();
                    this.m_CancelButton.onClick.AddListener(() =>
                    {
                        QuestManager.UI.dialogBox.Show(QuestManager.Notifications.cancelQuest, (int result) => {
                            switch (result)
                            {
                            case 0:
                                quest.Cancel();
                                Close();
                                break;

                            case 1:
                                break;
                            }
                        }, "Yes", "No");
                        //quest.Cancel();
                        //Close();
                    });
                }
                else
                {
                    this.m_CancelButton.gameObject.SetActive(false);
                }
            }
        }