Пример #1
0
    void SaveNewSkill()
    {
        Skill newSkill = new Skill();

        newSkill.SkillName      = skillName;
        newSkill.SkillID        = skillID;
        newSkill.SkillShortDesc = skillShortDesc;
        newSkill.SkillLongDesc  = skillLongDesc;

        // Set the model and icon
        newSkill.SetIcon(skillIcon);

        // Find model path
        skillIconPath          = AssetDatabase.GetAssetPath(skillIcon);
        skillIconPath          = GameUtility.CleanItemResourcePath(skillIconPath, "Assets/Resources/");
        skillIconPath          = GameUtility.CleanItemResourcePath(skillIconPath, ".png");
        newSkill.SkillIconPath = skillIconPath;

        newSkill.perkIDs = skillPerkIDs;

        // Check that the given ID isn't already in the database.
        if (RequirementsMet(skillID))
        {
            skillDatabase.AddSkill(newSkill);
        }
        else
        {
            Debug.LogError("A skill with that ID (" + newSkill.SkillID + ") already exists.");
        }
    }
Пример #2
0
    public static void SetObtainSkill(int id)
    {
        Skill userSkill = userSkills.Find(x => x.id == id || x.id.Equals(id));

        if (userSkill != null)
        {
            userSkill.level += 1;
            SkillDatabase.SaveSkill(id);
        }
        else
        {
            Skill skill = skills.Find(s => s.id == id || s.id.Equals(id));
            if (skill != null)
            {
                skill.level = 1;
                userSkills.Add(skill);
                SkillDatabase.AddSkill(id);
            }
        }
    }