Ejemplo n.º 1
0
    public void Setup()
    {
        questName.text      = quest.Name;
        unlock.interactable = quest.CheckUnlockable(GameManager.Instance.Game.Center);

        foreach (KeyValuePair <StatType, int> cost in quest.Costs)
        {
            GameObject costItem = Instantiate(Resources.Load("UI/UI-Quest-Stat")) as GameObject;
            costItem.transform.SetParent(costsPanel);
            costItem.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;
            costItem.GetComponent <RectTransform>().localScale       = Vector3.one;
            UIQuestStat ui   = costItem.GetComponent <UIQuestStat>();
            string      path = "Icons/stat-" + cost.Key.ToString();
            ui._icon.overrideSprite = Resources.Load <Sprite>(path);
            ui._stat.text           = cost.Value.ToString();
        }
    }
Ejemplo n.º 2
0
    public void QuestVictory()
    {
        //sequence[sequenceIndex].gameObject.SetActive(false);
        for (int i = 0; i < sequence.Length; i++)
        {
            sequence[i].gameObject.SetActive(false);
        }
        backToQuests.gameObject.SetActive(false);
        questCompletePanel.gameObject.SetActive(true);
        questCompletePanel.gameObject.transform.SetAsLastSibling();
        questDescription.text = quest.Summary;

        GameManager.Instance.Log(quest.Name + ": Quest complete!");
        GameManager.Instance.Log(quest.Summary);

        foreach (KeyValuePair <StatType, int> reward in quest.Rewards)
        {
            GameObject rewardItem = Instantiate(Resources.Load("UI/UI-Quest-Stat")) as GameObject;
            rewardItem.transform.SetParent(questRewardsPanel);
            rewardItem.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;
            rewardItem.GetComponent <RectTransform>().localScale       = Vector3.one;
            UIQuestStat ui   = rewardItem.GetComponent <UIQuestStat>();
            string      path = "Icons/stat-" + reward.Key.ToString();
            ui._icon.overrideSprite = Resources.Load <Sprite>(path);
            ui._stat.text           = reward.Value.ToString();

            if (reward.Key == StatType.XP)
            {
                Debug.Log("Rewarding XP");
                Debug.Log("Before: " + GameManager.Instance.Game.Center.XP);
                GameManager.Instance.Game.Center.AddXp(reward.Value);
                Debug.Log("After: " + GameManager.Instance.Game.Center.XP);
            }
            else
            {
                GameManager.Instance.Game.Center.Stats[reward.Key].BaseValue += reward.Value;
            }
        }
    }
Ejemplo n.º 3
0
    public void SetupPanel()
    {
        // Clean up all previous panel content
        foreach (Transform child in _skillPanel)
        {
            Destroy(child.gameObject);
        }
        foreach (Transform child in _statsPanel)
        {
            Destroy(child.gameObject);
        }
        foreach (Transform child in _costsPanel)
        {
            Destroy(child.gameObject);
        }
        foreach (Transform child in _rewardsPanel)
        {
            Destroy(child.gameObject);
        }

        _name.text = _quest.Name;

        // Skill Tasks
        foreach (KeyValuePair <SkillType, Req> req in _quest.Reqs)
        {
            GameObject skillItem = Instantiate(Resources.Load("Quest-Skill")) as GameObject;
            skillItem.transform.SetParent(_skillPanel);
            skillItem.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;
            skillItem.GetComponent <RectTransform>().localScale       = Vector3.one;
            UIReqProgress ui   = skillItem.GetComponent <UIReqProgress>();
            string        path = "Icons/skill-" + req.Value.Skill.ToString();
            ui.icon.overrideSprite    = Resources.Load <Sprite>(path);
            ui.label.text             = req.Value.Skill.ToString();
            ui.label.text             = req.Value.Skill.ToString();
            ui.currentValueText.text  = req.Value.CurrentValue.ToString();
            ui.requiredValueText.text = req.Value.RequiredValue.ToString();
            ui.slider.minValue        = 0;
            ui.slider.maxValue        = req.Value.RequiredValue;
            ui.slider.value           = req.Value.CurrentValue;
        }

        // Prereqs
        foreach (KeyValuePair <StatType, int> prereq in _quest.Prereqs)
        {
            GameObject costItem = Instantiate(Resources.Load("UI/UI-Quest-Stat")) as GameObject;
            costItem.transform.SetParent(_statsPanel);
            costItem.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;
            costItem.GetComponent <RectTransform>().localScale       = Vector3.one;
            UIQuestStat ui   = costItem.GetComponent <UIQuestStat>();
            string      path = "Icons/stat-" + prereq.Key.ToString();
            ui._icon.overrideSprite = Resources.Load <Sprite>(path);
            ui._stat.text           = prereq.Value.ToString();
        }

        // Costs
        foreach (KeyValuePair <StatType, int> cost in _quest.Costs)
        {
            GameObject costItem = Instantiate(Resources.Load("UI/UI-Quest-Stat")) as GameObject;
            costItem.transform.SetParent(_costsPanel);
            costItem.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;
            costItem.GetComponent <RectTransform>().localScale       = Vector3.one;
            UIQuestStat ui   = costItem.GetComponent <UIQuestStat>();
            string      path = "Icons/stat-" + cost.Key.ToString();
            ui._icon.overrideSprite = Resources.Load <Sprite>(path);
            ui._stat.text           = cost.Value.ToString();
        }

        // Rewards
        foreach (KeyValuePair <StatType, int> reward in _quest.Rewards)
        {
            GameObject rewardItem = Instantiate(Resources.Load("UI/UI-Quest-Stat")) as GameObject;
            rewardItem.transform.SetParent(_rewardsPanel);
            rewardItem.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;
            rewardItem.GetComponent <RectTransform>().localScale       = Vector3.one;
            UIQuestStat ui   = rewardItem.GetComponent <UIQuestStat>();
            string      path = "Icons/stat-" + reward.Key.ToString();
            ui._icon.overrideSprite = Resources.Load <Sprite>(path);
            ui._stat.text           = reward.Value.ToString();
        }

        unlock.interactable = _quest.CheckUnlockable(GameManager.Instance.Game.Center);
        if (_quest.Unlocked)
        {
            unlock.gameObject.SetActive(false);
        }
        else
        {
            unlock.gameObject.SetActive(true);
        }
        // accept.interactable = CheckAcceptConditions();
    }