Esempio n. 1
0
    // detailed damage applied to specific stat
    public virtual float DoDamage(float damage, MFnum.StatType apply, MFnum.DamageType damType, Vector3 loc, AudioSource audio, float multS, float multA, float multH, float multE, float multPen, float addReduce)
    {
        float d = damage;

        if (apply == MFnum.StatType.General)
        {
            d = ApplyDamage(MFnum.StatType.Shield, d, damType, loc, audio, multS, multA, multH, multE, multPen, addReduce);
            d = ApplyDamage(MFnum.StatType.Armor, d, damType, loc, audio, multS, multA, multH, multE, multPen, addReduce);
            d = ApplyDamage(MFnum.StatType.Health, d, damType, loc, audio, multS, multA, multH, multE, multPen, addReduce);
            // energy not in succession for normal damage
        }
        else if (apply == MFnum.StatType.Shield)
        {
            d = ApplyDamage(MFnum.StatType.Shield, damage, damType, loc, audio, multS, multA, multH, multE, multPen, addReduce);
        }
        else if (apply == MFnum.StatType.Armor)
        {
            d = ApplyDamage(MFnum.StatType.Armor, damage, damType, loc, audio, multS, multA, multH, multE, multPen, addReduce);
        }
        else if (apply == MFnum.StatType.Health)
        {
            d = ApplyDamage(MFnum.StatType.Health, damage, damType, loc, audio, multS, multA, multH, multE, multPen, addReduce);
        }
        else if (apply == MFnum.StatType.Energy)
        {
            d = ApplyDamage(MFnum.StatType.Energy, damage, damType, loc, audio, multS, multA, multH, multE, multPen, addReduce);
        }
        return(d);
    }
Esempio n. 2
0
    public override float ApplyDamage(MFnum.StatType stat, float damage, MFnum.DamageType damType, Vector3 loc, AudioSource audio, float multS, float multA, float multH, float multE, float multPen, float addReduce)
    {
        if (damage == 0)
        {
            return(0f);
        }                                         // early out

        float strength    = 0;
        float maxStrength = 0f;

        if (stat == MFnum.StatType.Shield)
        {
            strength = shield; maxStrength = shieldMax;
        }
        else if (stat == MFnum.StatType.Armor)
        {
            strength = armor; maxStrength = armorMax;
        }
        else if (stat == MFnum.StatType.Health)
        {
            strength = health; maxStrength = healthMax;
        }
        else if (stat == MFnum.StatType.Energy)
        {
            strength = energy; maxStrength = energyMax;
        }

        if (strength <= 0 && damage > 0)
        {
            return(damage);
        }                                                             // is damage, and health is at min
        if (strength >= maxStrength && damage < 0)
        {
            return(damage);
        }                                                      // is heal, and health is at max

        float d = damage;                                      // damage to strength
        float r = damage;                                      // damage to pass along

        d = Mathf.Clamp(d, -maxStrength + strength, strength); // damage can't do more than available strength, heals can't do more than available missing strength
        r = damage - d;

        if (stat == MFnum.StatType.Shield)
        {
            shield -= d;
        }
        else if (stat == MFnum.StatType.Armor)
        {
            armor -= d;
        }
        else if (stat == MFnum.StatType.Health)
        {
            health -= d;
        }
        else if (stat == MFnum.StatType.Energy)
        {
            energy -= d;
        }

        return(r);
    }
Esempio n. 3
0
 public virtual float ApplyDamage(MFnum.StatType stat, float damage, MFnum.DamageType damType, Vector3 loc, AudioSource audio, float multS, float multA, float multH, float multE, float multPen, float addReduce)
 {
     // indended to be overridden - insert rules for how damage is handled
     return(damage);
 }
Esempio n. 4
0
 // apply generalized damage to specific stat
 public virtual float DoDamage(float damage, MFnum.StatType apply)
 {
     return(DoDamage(damage, apply, MFnum.DamageType.General, Vector3.zero, null, 1f, 1f, 1f, 1f, 1f, 0f));
 }