Esempio n. 1
0
        // -----------------------------------------------------------------------------------
        // Skill (Constructor)
        // -----------------------------------------------------------------------------------
        public Skill(SkillTemplate tmpl = null, Character ownerobj = null, int lvl = 0)
        {
            if (tmpl != null)
            {
                template = tmpl;
                base.Init(ownerobj);



                defaultValue = lvl;
                Value        = defaultValue;
            }
        }
Esempio n. 2
0
 // -----------------------------------------------------------------------------------
 // getHasSkill
 // -----------------------------------------------------------------------------------
 public bool getHasSkill(SkillTemplate tmpl, int level = 0)
 {
     if (tmpl == null || level == 0)
     {
         return(true);
     }
     foreach (Skill skill in skills)
     {
         if (skill.isValid && skill.template == tmpl && skill.Value >= level)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 3
0
 // -----------------------------------------------------------------------------------
 // getSkill
 // -----------------------------------------------------------------------------------
 public Skill getSkill(SkillTemplate tmpl)
 {
     if (tmpl == null)
     {
         return(null);
     }
     foreach (Skill skill in skills)
     {
         if (skill.isValid && skill.template == tmpl)
         {
             return(skill);
         }
     }
     return(null);
 }
Esempio n. 4
0
 // -----------------------------------------------------------------------------------
 // AddSkill
 // -----------------------------------------------------------------------------------
 public bool AddSkill(SkillTemplate tmpl, int level = 0)
 {
     if (tmpl != null)
     {
         if (!getHasSkill(tmpl, level))
         {
             int index = skills.FindIndex(i => !i.isValid);
             if (index >= 0)
             {
                 skills[index] = new Skill(tmpl, owner, level);
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 5
0
        // -----------------------------------------------------------------------------------
        // skillCheck
        // -----------------------------------------------------------------------------------
        public bool skillCheck(SkillTemplate tmpl, float baseDifficulty)
        {
            if (tmpl == null || baseDifficulty == 0)
            {
                return(true);
            }
            if (baseDifficulty >= 1.0f || !getHasSkill(tmpl))
            {
                return(false);
            }

            Skill skill = getSkill(tmpl);

            float baseChance = baseDifficulty - (skill.MaxValue / skill.Value);

            if (Random.value <= baseChance)
            {
                return(true);
            }

            return(false);
        }