Example #1
0
        private void InitLogEntries()
        {
            ClearEntries();
            m_quests.Clear();
            m_quests.AddRange(m_questHandler.GetActiveStepsByCategory(EQuestType.QUEST_TYPE_MAIN));
            m_quests.AddRange(m_questHandler.GetActiveStepsByCategory(EQuestType.QUEST_TYPE_SIDE));
            m_quests.AddRange(m_questHandler.GetActiveStepsByCategory(EQuestType.QUEST_TYPE_ONGOING));
            m_quests.AddRange(m_questHandler.GetActiveStepsByCategory(EQuestType.QUEST_TYPE_GRANDMASTER));
            m_quests.AddRange(m_questHandler.GetActiveStepsByCategory(EQuestType.QUEST_TYPE_PROMOTION));
            Int32 num = 0;

            foreach (QuestStep p_questStep in m_quests)
            {
                GameObject          gameObject = NGUITools.AddChild(m_entryHook, m_prefabEntry);
                NewHUDQuestLogEntry component  = gameObject.GetComponent <NewHUDQuestLogEntry>();
                component.Init(p_questStep, num, this, false);
                ScrollingHelper.InitScrollListeners(this, gameObject);
                component.BusinessChanged += OnBusinessChanged;
                component.QuestHovered    += OnQuestHovered;
                m_entries.Insert(num, component);
                m_busyEntries.Add(component);
                num++;
            }
            RepositionEntries();
            if (m_entries.Count > 0)
            {
                m_currentlyVisibleEntry = m_entries[0];
            }
        }
Example #2
0
 private void OnQuestHovered(Object p_sender, EventArgs p_args)
 {
     if (p_sender is NewHUDQuestLogEntry)
     {
         NewHUDQuestLogEntry newHUDQuestLogEntry = (NewHUDQuestLogEntry)p_sender;
         m_componentHovered = newHUDQuestLogEntry.IsHovered;
         OnHover(m_componentHovered);
     }
 }
Example #3
0
        private void OnQuestLogChanged(Object p_sender, EventArgs p_args)
        {
            QuestChangedEventArgs questChangedEventArgs = (QuestChangedEventArgs)p_args;

            if (questChangedEventArgs == null)
            {
                return;
            }
            switch (questChangedEventArgs.ChangeType)
            {
            case QuestChangedEventArgs.Type.NEW_QUEST:
                AudioController.Play("QuestRecieved", 1f, Mathf.Max(0f, 0.9f * (m_questCompletedSoundEndTime - Time.realtimeSinceStartup)), 0f);
                AddEntry(questChangedEventArgs.QuestStep);
                break;

            case QuestChangedEventArgs.Type.COMPLETED_QUEST:
            {
                AudioObject audioObject = AudioController.Play("QuestCompleted");
                if (audioObject != null)
                {
                    m_questCompletedSoundEndTime = Time.realtimeSinceStartup + audioObject.clipLength;
                }
                else if (!AudioController.IsValidAudioID("QuestCompleted"))
                {
                    Debug.LogError("Could not play quest completed sound. AudioID=QuestCompleted");
                }
                foreach (NewHUDQuestLogEntry newHUDQuestLogEntry in m_entries)
                {
                    if (questChangedEventArgs.QuestStep.StaticData.StaticID == newHUDQuestLogEntry.QuestStep.StaticData.StaticID)
                    {
                        newHUDQuestLogEntry.UpdateStep();
                        m_currentlyVisibleEntry = newHUDQuestLogEntry;
                    }
                }
                break;
            }

            case QuestChangedEventArgs.Type.COMPLETED_OBJECTIVE:
                if (m_questCompletedSoundEndTime - 0.25f < Time.realtimeSinceStartup)
                {
                    AudioController.Play("QuestObjectiveCompleted");
                }
                foreach (NewHUDQuestLogEntry newHUDQuestLogEntry2 in m_entries)
                {
                    if (questChangedEventArgs.QuestStep.StaticData.StaticID == newHUDQuestLogEntry2.QuestStep.StaticData.StaticID)
                    {
                        newHUDQuestLogEntry2.UpdateObjectives();
                        m_currentlyVisibleEntry = newHUDQuestLogEntry2;
                    }
                }
                RepositionEntries();
                break;
            }
        }
Example #4
0
        private void ScrollToEntry(NewHUDQuestLogEntry p_entry)
        {
            if (p_entry == null)
            {
                return;
            }
            Single scrollPotential = GetScrollPotential(m_questLogPanel.clipRange.w);
            Single num             = -p_entry.transform.localPosition.y;

            if (p_entry.ListIndex > 0 && num == 0f)
            {
                return;
            }
            m_scrollBar.scrollValue = num / scrollPotential;
            m_currentlyVisibleEntry = p_entry;
        }
Example #5
0
        private Single GetNearestEntryPosition(Single p_yPos)
        {
            Single result = p_yPos;

            if (m_entries != null && m_entries.Count > 0)
            {
                foreach (NewHUDQuestLogEntry newHUDQuestLogEntry in m_entries)
                {
                    if (Mathf.Abs(p_yPos) >= Mathf.Abs(newHUDQuestLogEntry.transform.localPosition.y))
                    {
                        result = -newHUDQuestLogEntry.transform.localPosition.y;
                        m_currentlyVisibleEntry = newHUDQuestLogEntry;
                    }
                }
            }
            return(result);
        }
Example #6
0
 private void ClearEntries()
 {
     m_busyEntries = new List <NewHUDQuestLogEntry>();
     if (m_entries != null)
     {
         for (Int32 i = m_entries.Count - 1; i >= 0; i--)
         {
             NewHUDQuestLogEntry newHUDQuestLogEntry = m_entries[i];
             m_entries.RemoveAt(i);
             newHUDQuestLogEntry.BusinessChanged            -= OnBusinessChanged;
             newHUDQuestLogEntry.QuestHovered               -= OnQuestHovered;
             newHUDQuestLogEntry.gameObject.collider.enabled = false;
             Helper.DestroyGO <NewHUDQuestLogEntry>(newHUDQuestLogEntry);
         }
         m_entries.Clear();
     }
     m_entries = new List <NewHUDQuestLogEntry>();
 }
Example #7
0
        private Single GetNextEntryPosition()
        {
            Single result = 0f;

            if (m_entries != null && m_entries.Count > 0)
            {
                Int32 listIndex = m_currentlyVisibleEntry.ListIndex;
                if (listIndex == m_entries.Count - 1)
                {
                    result = -m_currentlyVisibleEntry.transform.localPosition.y;
                }
                else
                {
                    result = -m_entries[listIndex + 1].transform.localPosition.y + 1f;
                    m_currentlyVisibleEntry = m_entries[listIndex + 1];
                }
            }
            return(result);
        }
Example #8
0
        private void OnBusinessChanged(Object p_sender, EventArgs p_args)
        {
            NewHUDQuestLogEntry newHUDQuestLogEntry = (NewHUDQuestLogEntry)p_sender;

            if (newHUDQuestLogEntry == null)
            {
                return;
            }
            if (newHUDQuestLogEntry.IsBusy)
            {
                if (!m_busyEntries.Contains(newHUDQuestLogEntry))
                {
                    m_busyEntries.Add(newHUDQuestLogEntry);
                }
            }
            else if (newHUDQuestLogEntry.CanRemoveEntry)
            {
                if (!m_busyEntries.Contains(newHUDQuestLogEntry))
                {
                    m_busyEntries.Add(newHUDQuestLogEntry);
                }
            }
            else
            {
                m_locked = false;
                for (Int32 i = m_busyEntries.Count - 1; i >= 0; i--)
                {
                    NewHUDQuestLogEntry newHUDQuestLogEntry2 = m_busyEntries[i];
                    if (newHUDQuestLogEntry2.QuestStep.StaticData.StaticID == newHUDQuestLogEntry.QuestStep.StaticData.StaticID)
                    {
                        m_busyEntries.RemoveAt(i);
                        break;
                    }
                }
                ResetWaitTime();
            }
            RepositionEntries();
            if (m_scrollBar.barSize != 1f)
            {
                ScrollToEntry(newHUDQuestLogEntry);
            }
        }
Example #9
0
        private void AddEntry(QuestStep p_newQuest)
        {
            Int32 positionForEntry = GetPositionForEntry(p_newQuest);

            if (positionForEntry < 0)
            {
                return;
            }
            GameObject          gameObject = NGUITools.AddChild(m_entryHook, m_prefabEntry);
            NewHUDQuestLogEntry component  = gameObject.GetComponent <NewHUDQuestLogEntry>();

            component.Init(p_newQuest, positionForEntry, this, false);
            ScrollingHelper.InitScrollListeners(this, gameObject);
            component.BusinessChanged += OnBusinessChanged;
            component.QuestHovered    += OnQuestHovered;
            m_entries.Insert(positionForEntry, component);
            UpdateIndexProperties();
            RepositionEntries();
            OnBusinessChanged(component, EventArgs.Empty);
        }
Example #10
0
        private void RemoveEntry(Int32 p_index)
        {
            m_waitTimeForRemovedEntry = Time.time + m_configFadeDelay;
            NewHUDQuestLogEntry newHUDQuestLogEntry = m_entries[p_index];

            m_entries.RemoveAt(p_index);
            NGUITools.SetActive(newHUDQuestLogEntry.gameObject, false);
            Helper.DestroyGO <NewHUDQuestLogEntry>(newHUDQuestLogEntry);
            UpdateIndexProperties();
            if (m_entries.Count == 0)
            {
                m_currentlyVisibleEntry = null;
            }
            else if (p_index >= m_entries.Count)
            {
                m_currentlyVisibleEntry = m_entries[p_index - 1];
            }
            else if (p_index < m_entries.Count)
            {
                m_currentlyVisibleEntry = m_entries[p_index];
            }
            RepositionEntries();
        }
Example #11
0
 protected override void Update()
 {
     if (m_sizeChangeSaveTimer > 0f)
     {
         m_sizeChangeSaveTimer -= Time.deltaTime;
         if (m_sizeChangeSaveTimer <= 0f)
         {
             Single w = m_questLogPanel.clipRange.w;
             if (w != ConfigManager.Instance.Options.QuestLogSize)
             {
                 ConfigManager.Instance.Options.QuestLogSize = w;
                 ConfigManager.Instance.WriteConfigurations();
             }
         }
     }
     if (!m_configSaysFade)
     {
         if (m_currentAlpha < 1f)
         {
             m_currentAlpha = 1f;
             FadeComponents(m_currentAlpha);
             m_fadeState = EFadeState.WAITING;
             m_locked    = true;
         }
         if (m_busyEntries.Count > 0)
         {
             for (Int32 i = m_busyEntries.Count - 1; i >= 0; i--)
             {
                 NewHUDQuestLogEntry newHUDQuestLogEntry = m_busyEntries[i];
                 newHUDQuestLogEntry.UpdateEntry();
                 if (newHUDQuestLogEntry.CanRemoveEntry)
                 {
                     Int32 listIndex = newHUDQuestLogEntry.ListIndex;
                     RemoveEntry(listIndex);
                     m_busyEntries.Remove(newHUDQuestLogEntry);
                 }
             }
         }
         return;
     }
     if (m_waitForLoadingScreen || LegacyLogic.Instance.ConversationManager.IsOpen)
     {
         return;
     }
     if (m_waitTimeForRemovedEntry > -1f && m_waitTimeForRemovedEntry > Time.time)
     {
         return;
     }
     m_waitTimeForRemovedEntry = -1f;
     if (m_busyEntries != null && m_busyEntries.Count > 0)
     {
         if (m_fadeState == EFadeState.FADE_IN && m_currentAlpha >= 1f)
         {
             m_fadeState = EFadeState.WAITING;
         }
         if (m_fadeState == EFadeState.DONE || m_fadeState == EFadeState.FADE_OUT)
         {
             m_fadeState = EFadeState.FADE_IN;
         }
         else if (m_fadeState == EFadeState.WAITING)
         {
             m_locked = true;
             for (Int32 j = m_busyEntries.Count - 1; j >= 0; j--)
             {
                 NewHUDQuestLogEntry newHUDQuestLogEntry2 = m_busyEntries[j];
                 newHUDQuestLogEntry2.UpdateEntry();
                 if (newHUDQuestLogEntry2.CanRemoveEntry)
                 {
                     Int32 listIndex2 = newHUDQuestLogEntry2.ListIndex;
                     RemoveEntry(listIndex2);
                     m_busyEntries.Remove(newHUDQuestLogEntry2);
                     if (m_busyEntries.Count == 0)
                     {
                         m_locked = false;
                     }
                 }
             }
         }
     }
     if (m_buttonChangeSize.IsPressed && m_fadeState == EFadeState.WAITING)
     {
         m_locked = true;
     }
     base.Update();
 }