public int TakeDamage(int damage, eDamageTypes damagetype, MobState source = null) { // returns the actual amount of damage taken damage = HandleResistances(damage, damagetype, source); Health.AddCurrent(-1 * damage); int newhp = Health.GetCurrent(); if (newhp <= 0) { Die(source); } return(damage); }
protected int HandleResistances(int damage, eDamageTypes damagetype, MobState source = null) { if (damagetype == eDamageTypes.NONE) { return(damage); } if (Immunities.Contains(damagetype)) { return(0); } if (!Resistances.ContainsKey(damagetype)) { return(damage); } // TODO: need to verify 1) is damage integer? and 2) if so, how is this rounding down? // e.g. is it always 'round down' / 'round up' or does it use 'math.round' damage = (int)(damage * Resistances[damagetype].GetCurrent()); return(damage); }
public void Die(MobState source = null) { // TODO: how do we want to tackle this? Alive = false; }