Exemplo n.º 1
0
        private void SetQuestState(QuestInterface quest, QuestInterfaceStates state)
        {
            switch (state)
            {
            case QuestInterfaceStates.ACTIVE:
                if (m_ActiveQuest != null)
                {
                    SetQuestState(m_ActiveQuest, QuestInterfaceStates.DEFAULT);
                    m_ActiveQuest.OnQuestSubmitted -= OnQuestSubmitted;
                    m_ActiveQuest.SetInteractable(false);
                }
                m_ActiveQuest = quest;
                m_ActiveQuest.TargetTransform   = selectedQuestPosition;
                m_ActiveQuest.OnQuestSubmitted += OnQuestSubmitted;
                m_ActiveQuest.SetInteractable(true);
                m_QuestInterfaceTargets[quest].IsExpanded = false;
                break;

            case QuestInterfaceStates.HOVER:
                quest.TargetTransform = m_QuestInterfaceTargets[quest].hoverPosition;
                m_QuestInterfaceTargets[quest].IsExpanded = true;
                break;

            case QuestInterfaceStates.DEFAULT:
                quest.TargetTransform = m_QuestInterfaceTargets[quest].normalPosition;
                m_QuestInterfaceTargets[quest].IsExpanded = true;
                break;
            }
        }
Exemplo n.º 2
0
        private void OnQuestSubmitted()
        {
            QuestInstance quest = m_ActiveQuest.QuestInstance;

            Destroy(m_QuestInterfaceTargets[m_ActiveQuest].gameObject);
            m_QuestInterfaceTargets.Remove(m_ActiveQuest);
            m_ActiveQuest.TargetTransform = questSubmittedPosition;
            m_ActiveQuest = null;
        }
Exemplo n.º 3
0
        private void RemoveQuestInterface(QuestInstance quest)
        {
            QuestInterface questInterfaceToRemove = null;

            foreach (QuestInterface questInterface in m_QuestInterfaceTargets.Keys)
            {
                if (questInterface.QuestInstance == quest)
                {
                    questInterfaceToRemove = questInterface;
                    break;
                }
            }

            if (questInterfaceToRemove == null)
            {
                return;
            }

            Destroy(questInterfaceToRemove.gameObject);
            Destroy(m_QuestInterfaceTargets[questInterfaceToRemove].gameObject);
            m_QuestInterfaceTargets.Remove(questInterfaceToRemove);
        }
Exemplo n.º 4
0
        private void AddQuestInterface(QuestInstance quest)
        {
            QuestListEntry newEntry     = Instantiate(questListEntryPrefab, questListParent);
            QuestInterface newInterface = Instantiate(questInterfacePrefab, questInstancesParent);

            m_QuestInterfaceTargets[newInterface] = newEntry;

            newInterface.QuestInstance = quest;
            newInterface.SetInteractable(false);

            newEntry.GetComponent <RectTransform>().rect.Set(selectedQuestPosition.rect.x, selectedQuestPosition.rect.y, selectedQuestPosition.rect.width, selectedQuestPosition.rect.height);

            newEntry.OnButtonClick.AddListener(() => {
                if (m_ActiveQuest == newInterface)
                {
                    return;
                }
                SetQuestState(newInterface, QuestInterfaceStates.ACTIVE);
            });

            newEntry.OnHoverStart += () => {
                if (m_ActiveQuest == newInterface)
                {
                    return;
                }
                SetQuestState(newInterface, QuestInterfaceStates.HOVER);
            };

            newEntry.OnHoverEnd += () => {
                if (m_ActiveQuest == newInterface)
                {
                    return;
                }
                SetQuestState(newInterface, QuestInterfaceStates.DEFAULT);
            };

            SetQuestState(newInterface, QuestInterfaceStates.DEFAULT);
        }