Esempio n. 1
0
        public override int calculateChance(CreatureContainer user, CreatureContainer target)
        {
            int chance;

            bool skip = true;

            if (target.Creature.getEquip("Off-Hand") != null)
            {
                if (target.Creature.getEquip("Off-Hand").GetType() == typeof(ItemShield))
                {
                    defenderAttr  = target.Stats.Strength * (100 + ((ItemShield)target.Creature.getEquip("Off-Hand")).getBlock()) / 100;
                    resultMessage = "Block";
                    skip          = false;
                }
            }
            if (skip)
            {
                defenderAttr  = target.Stats.Dexterity;
                resultMessage = "Dodge";
            }

            chance = user.Stats.Dexterity * 100 / 2 / defenderAttr;

            if (chance > 99)
            {
                chance = 99;
            }
            else if (chance < 1)
            {
                chance = 1;
            }

            return(chance);
        }
 // Use this for initialization
 void Start()
 {
     human_Creatures  = CreatureContainer.LoadHumanCreatures(humanCreaturesPath);
     undead_Creatures = CreatureContainer.LoadHumanCreatures(undeadCreaturesPath);
     foreach (Creature c in human_Creatures.creatures)
     {
         Debug.Log(c.name + " > " + c.healthPerUnit);
     }
     Debug.Log("------------------------------------");
     foreach (Creature c in undead_Creatures.creatures)
     {
         Debug.Log(c.name + " > " + c.healthPerUnit);
     }
 }
Esempio n. 3
0
    public static CreatureContainer LoadHumanCreatures(string path)
    {
        TextAsset _xml = Resources.Load <TextAsset>(path);

        if (_xml == null)
        {
            Debug.Log("LOL");
        }

        XmlSerializer serializer = new XmlSerializer(typeof(CreatureContainer));

        StringReader reader = new StringReader(_xml.text);

        CreatureContainer creatures = serializer.Deserialize(reader) as CreatureContainer;

        reader.Close();

        return(creatures);
    }
Esempio n. 4
0
 //Here you code the chance to hit
 public abstract int calculateChance(CreatureContainer user, CreatureContainer target);
Esempio n. 5
0
 //Here you code what the ability does
 public abstract Result runAbility(CreatureContainer user, CreatureContainer target);
Esempio n. 6
0
        public override Result runAbility(CreatureContainer user, CreatureContainer target)
        {
            int chance = calculateChance(user, target);

            int hit = (ConstantLib.RANDOM.Next(100) + 1);

            if (!(chance < hit))
            {
                int  damage;
                bool equipNull = false;

                if (user.Creature.getEquip("Main-Hand") == null)
                {
                    damage    = 1;
                    equipNull = true;
                }
                else
                {
                    damage = ((ItemWeapon)user.Creature.getEquip("Main-Hand")).getDamage();
                }

                if (hit == 1)
                {
                    if (equipNull)
                    {
                        hit = 2;
                    }
                    else
                    {
                        hit = ((ItemWeapon)user.Creature.getEquip("Main-Hand")).getCritMod();
                    }
                }
                else
                {
                    hit = 1;
                }

                damage = (int)(damage * damageMod + user.Stats.DamageModMelee) * hit;

                foreach (var item in this.damageTypes)
                {
                    if (target.Creature.getResistance().ContainsKey(item.Key))
                    {
                        damage -= damage * item.Value * target.Creature.getResistance()[item.Key] / 10000;
                    }
                }

                //Needs to figure out how to implement damage type on weapon into damage resistance

                /*if (user.getEquip("RightArm") != null)
                 * {
                 *  foreach (var item in ((ItemWeapon)user.getEquip("RightArm")).getDamageType())
                 *  {
                 *      if (target.getResistance().ContainsKey(item))
                 *      {
                 *          damage = damage * (100-target.getResistance()[item]) / 100;
                 *      }
                 *  }
                 * }*/

                if (damage < 1)
                {
                    resultMessage = "Immune";
                }
                else
                {
                    resultMessage    = "Hit " + damage;
                    target.Stats.HP -= damage;
                }
            }

            return(new Result(user, resultMessage, target));
        }
Esempio n. 7
0
 public Result(CreatureContainer user, string result, CreatureContainer target)
 {
     this.result = result;
     this.user   = user;
     this.target = target;
 }