private void SetKnownSkills()
    {
        foreach (var skill in player.knownSkills)
        {
            SkillSlot skillSlot = Instantiate(skillPrefab, availableSkillsList.transform).GetComponent <SkillSlot>();

            //Set icon
            foreach (var skillIcon in skillIcons)
            {
                if (skillIcon.skillID == skill.SkillID)
                {
                    skillSlot.icon = skillIcon.GetComponent <Image>();
                    skillSlot.GetComponentInChildren <Image>().sprite = skillSlot.icon.sprite;
                }
            }

            skillSlot.GetComponent <Button>().interactable = true;
            skillSlot.OnSkillClicked += KnownSkillClicked;

            skillSlot.skill = skill;
            Skill newSkill = skillSlot.skill;

            newSkill.SkillID        = skill.SkillID;
            newSkill.SkillName      = skill.SkillName;
            newSkill.SkillType      = skill.SkillType;
            newSkill.DamageModifier = skill.DamageModifier;
            newSkill.EnergyCost     = skill.EnergyCost;
        }
    }
    private void SetEquippedSkills()
    {
        foreach (var skill in player.equippedSkills)
        {
            SkillSlot skillSlot = Instantiate(skillPrefab, equippedSkillsList.transform).GetComponent <SkillSlot>();

            //Set icon
            foreach (var skillIcon in skillIcons)
            {
                if (skillIcon.skillID == skill.SkillID)
                {
                    skillSlot.icon = skillIcon.GetComponent <Image>();
                    skillSlot.GetComponentInChildren <Image>().sprite = skillSlot.icon.sprite;
                }
            }

            skillSlot.skill = skill;
            Skill newSkill = skillSlot.skill;

            newSkill.SkillID        = skill.SkillID;
            newSkill.SkillName      = skill.SkillName;
            newSkill.SkillType      = skill.SkillType;
            newSkill.DamageModifier = skill.DamageModifier;
            newSkill.EnergyCost     = skill.EnergyCost;

            playerEquippedSkills.Add(skillSlot);
        }
    }
    private void KnownSkillClicked(object sender, Skill skill)
    {
        if (player.equippedSkills.Count >= 3)
        {
            //set up a popup to indicate this
            return;
        }

        if (player.equippedSkills.Contains(skill))
        {
            //identify skill is already equipped
            return;
        }
        else
        {
            SkillSlot skillSlot = Instantiate(skillPrefab, equippedSkillsList.transform).GetComponent <SkillSlot>();

            //Set icon
            foreach (var skillIcon in skillIcons)
            {
                if (skillIcon.skillID == skill.SkillID)
                {
                    skillSlot.icon = skillIcon.GetComponent <Image>();
                    skillSlot.GetComponentInChildren <Image>().sprite = skillSlot.icon.sprite;
                }
            }

            skillSlot.skill = skill;
            Skill newSkill = skillSlot.skill;

            newSkill.SkillID        = skill.SkillID;
            newSkill.SkillName      = skill.SkillName;
            newSkill.SkillType      = skill.SkillType;
            newSkill.DamageModifier = skill.DamageModifier;
            newSkill.EnergyCost     = skill.EnergyCost;

            player.equippedSkills.Add(newSkill);

            playerEquippedSkills.Add(skillSlot);
        }
    }
示例#4
0
    public void UpdateUI()
    {
        availableSkillPointsText.text = $"Skill Points: {player.availableSkillPoints}";

        var skillSlots = availableSkillsList.GetComponentsInChildren <SkillSlot>();

        foreach (var skill in skillSlots)
        {
            Destroy(skill.gameObject);
        }

        foreach (var skill in SkillFactory.GameSkills)
        {
            SkillSlot skillSlot = Instantiate(skillSlotPrefab, availableSkillsList.transform).GetComponent <SkillSlot>();

            //Set icon
            foreach (var skillIcon in skillIcons)
            {
                if (skillIcon.skillID == skill.SkillID)
                {
                    skillSlot.icon = skillIcon.GetComponent <Image>();
                    skillSlot.GetComponentInChildren <Image>().sprite = skillSlot.icon.sprite;
                }
            }

            skillSlot.GetComponent <Button>().interactable = true;
            skillSlot.OnSkillClicked += NewSkillClicked;

            skillSlot.skill = skill;
            Skill newSkill = skillSlot.skill;

            newSkill.SkillID        = skill.SkillID;
            newSkill.SkillName      = skill.SkillName;
            newSkill.SkillType      = skill.SkillType;
            newSkill.DamageModifier = skill.DamageModifier;
            newSkill.EnergyCost     = skill.EnergyCost;
        }
    }