Beispiel #1
0
    void Update()
    {
        GameObject player = Player.player;

        if (!player)
        {
            return;
        }

        PlayerQuests playerQuests = player.GetComponent <PlayerQuests>();

        // only show active quests, no completed ones
        List <Quest> activeQuests = playerQuests.quests.Where(q => !q.completed).ToList();

        // instantiate/destroy enough slots
        UIUtils.BalancePrefabs(slotPrefab.gameObject, activeQuests.Count, content);

        // refresh all
        for (int i = 0; i < activeQuests.Count; ++i)
        {
            UIQuestSlot slot  = content.GetChild(i).GetComponent <UIQuestSlot>();
            Quest       quest = activeQuests[i];

            // name button
            GameObject descriptionPanel = slot.descriptionText.gameObject;
            string     prefix           = descriptionPanel.activeSelf ? hidePrefix : expandPrefix;
            slot.nameButton.GetComponentInChildren <Text>().text = prefix + quest.name;
            slot.nameButton.onClick.SetListener(() => {
                descriptionPanel.SetActive(!descriptionPanel.activeSelf);
            });

            // description
            slot.descriptionText.text = quest.ToolTip(player);
        }
    }
    void Update()
    {
        Player player = Utils.ClientLocalPlayer();

        if (!player)
        {
            return;
        }

        // hotkey (not while typing in chat, etc.)
        if (Input.GetKeyDown(hotKey) && !UIUtils.AnyInputActive())
        {
            panel.SetActive(!panel.activeSelf);
        }

        // only update the panel if it's active
        if (panel.activeSelf)
        {
            // only show active quests, no completed ones
            List <Quest> activeQuests = player.quests.Where(q => !q.completed).ToList();

            // instantiate/destroy enough slots
            UIUtils.BalancePrefabs(slotPrefab.gameObject, activeQuests.Count, content);

            // refresh all
            for (int i = 0; i < activeQuests.Count; ++i)
            {
                UIQuestSlot slot  = content.GetChild(i).GetComponent <UIQuestSlot>();
                Quest       quest = activeQuests[i];

                // name button
                GameObject descriptionPanel = slot.descriptionText.gameObject;
                string     prefix           = descriptionPanel.activeSelf ? hidePrefix : expandPrefix;
                slot.nameButton.GetComponentInChildren <Text>().text = prefix + quest.name;
                slot.nameButton.onClick.SetListener(() => {
                    descriptionPanel.SetActive(!descriptionPanel.activeSelf);
                });

                // description
                int gathered = quest.gatherItem != null?player.InventoryCount(new Item(quest.gatherItem)) : 0;

                slot.descriptionText.text = quest.ToolTip(gathered);
            }
        }
    }
Beispiel #3
0
    void Update()
    {
        Player player = Utils.ClientLocalPlayer();

        if (!player)
        {
            return;
        }

        // hotkey (not while typing in chat, etc.)
        if (Input.GetKeyDown(hotKey) && !UIUtils.AnyInputActive())
        {
            panel.SetActive(!panel.activeSelf);
        }

        // only update the panel if it's active
        if (panel.activeSelf)
        {
            // only show active quests, no completed ones
            List <Quest> activeQuests = player.quests.Where(q => !q.completed).ToList();

            // instantiate/destroy enough slots
            UIUtils.BalancePrefabs(slotPrefab.gameObject, activeQuests.Count, content);

            // refresh all
            for (int i = 0; i < activeQuests.Count; ++i)
            {
                UIQuestSlot slot     = content.GetChild(i).GetComponent <UIQuestSlot>();
                Quest       quest    = activeQuests[i];
                int         gathered = quest.gatherItem != null?player.InventoryCount(new Item(quest.gatherItem)) : 0;

                slot.descriptionText.text = quest.ToolTip(gathered);
            }
        }

        // addon system hooks
        Utils.InvokeMany(typeof(UIQuests), this, "Update_");
    }