Пример #1
0
 void OnQuestItemClick(UINpcQuestItem item)
 {
     if (onQuestItemClick != null)
     {
         onQuestItemClick(item);
     }
 }
    void OnQuestItemClick(UINpcQuestItem item)
    {
        if (item.index < 0 || item.index >= _dialogs.Count)
        {
            Debug.LogWarning("The index is out of range");
            return;
        }

        int world_index = CustomGameData.Mgr.Instance.curGameData.WorldIndex;
        int quest_id    = PeCustomScene.Self.scenario.dialogMgr.GetQuestId(world_index, npoId, item.index);

        if (quest_id != -1)
        {
            if (onQuestClick != null)
            {
                onQuestClick(world_index, npoId, quest_id);
            }

            Debug.Log("Click the Quest id [" + quest_id.ToString() + "]");
        }
        else
        {
            Debug.LogWarning("cant find the quest id");
        }
    }
    void OnQuestItemClick(UINpcQuestItem item)
    {
        if (item.index < 0 || item.index >= _choices.Count)
        {
            Debug.LogWarning("The index is out of range");
            return;
        }

        int choice_id = PeCustomScene.Self.scenario.dialogMgr.GetChoiceId(item.index);

        if (choice_id != -1)
        {
            if (onChoiceClickForward != null)
            {
                onChoiceClickForward(choice_id);
            }

            if (onChoiceClick != null)
            {
                onChoiceClick(choice_id);
            }

            Debug.Log("Click the choice id [" + choice_id.ToString() + "]");
        }
        else
        {
            Debug.LogWarning("cant find the quest id");
        }
    }
Пример #4
0
    public void UpdateTable(int count)
    {
        count = count < 0 ? 0 : count;

        if (count > m_QuestItems.Count)
        {
            for (int i = 0; i < m_QuestItems.Count; i++)
            {
                m_QuestItems[i].index = i;
                if (onSetItemContent != null)
                {
                    onSetItemContent(m_QuestItems[i]);
                }
            }

            int cnt = count;
            for (int i = m_QuestItems.Count; i < cnt; i++)
            {
                UINpcQuestItem item = CreateQuestItem();
                item.index = i;
                m_QuestItems.Add(item);
                item.onClick += OnQuestItemClick;

                if (onSetItemContent != null)
                {
                    onSetItemContent(m_QuestItems[i]);
                }
            }
        }
        else
        {
            for (int i = 0; i < count; i++)
            {
                m_QuestItems[i].index = i;
                if (onSetItemContent != null)
                {
                    onSetItemContent(m_QuestItems[i]);
                }
            }

            for (int i = m_QuestItems.Count - 1; i >= count; i--)
            {
                m_QuestItems[i].onClick -= OnQuestItemClick;
                Destroy(m_QuestItems[i].gameObject);
                m_QuestItems[i].transform.parent = null;
                m_QuestItems.RemoveAt(i);
            }
        }

        defaultQuest.transform.SetAsLastSibling();

        questTable.repositionNow = true;
    }
Пример #5
0
    UINpcQuestItem CreateQuestItem()
    {
        UINpcQuestItem item  = Instantiate <UINpcQuestItem>(questItemPrefab);
        Transform      trans = item.transform;

        item.transform.parent = chooseTable.transform;
        trans.localPosition   = Vector3.zero;
        trans.localRotation   = Quaternion.identity;
        trans.localScale      = Vector3.one;
        trans.gameObject.SetActive(true);

        return(item);
    }
    void OnSetQuestItemContent(UINpcQuestItem item)
    {
        if (_dialogs == null)
        {
            Debug.LogWarning("The giving dialog is null");
            return;
        }

        if (item.index < 0 || item.index >= _dialogs.Count)
        {
            Debug.LogWarning("The index is out of range");
            return;
        }

        item.test = _dialogs[item.index];
    }
Пример #7
0
    public void SetContent(int choose_num)
    {
        int count = choose_num < 0 ? 0 : choose_num;

        if (!chooseTable.gameObject.activeSelf)
        {
            chooseTable.gameObject.SetActive(true);
        }

        if (contentLabel.gameObject.activeSelf)
        {
            contentLabel.gameObject.SetActive(false);
        }

        if (count > m_QuestItems.Count)
        {
            for (int i = 0; i < m_QuestItems.Count; i++)
            {
                m_QuestItems[i].index = i;
                if (onSetItemContent != null)
                {
                    onSetItemContent(m_QuestItems[i]);
                }
            }

            int cnt = count;
            for (int i = m_QuestItems.Count; i < cnt; i++)
            {
                UINpcQuestItem item = CreateQuestItem();
                item.index = i;
                m_QuestItems.Add(item);
                item.onClick += OnQuestItemClick;

                if (onSetItemContent != null)
                {
                    onSetItemContent(m_QuestItems[i]);
                }
            }
        }
        else
        {
            for (int i = 0; i < count; i++)
            {
                m_QuestItems[i].index = i;
                if (onSetItemContent != null)
                {
                    onSetItemContent(m_QuestItems[i]);
                }
            }

            for (int i = m_QuestItems.Count - 1; i >= count; i--)
            {
                m_QuestItems[i].onClick -= OnQuestItemClick;
                Destroy(m_QuestItems[i].gameObject);
                m_QuestItems[i].transform.parent = null;
                m_QuestItems.RemoveAt(i);
            }
        }

        chooseTable.repositionNow = true;
    }