public bool CanDamage(Damage damage) { if (!mIsInvul) { float amt = damage.amount; if (damageReduction > 0.0f) { amt -= amt * damageReduction; } DamageMod damageAmpByType = GetDamageMod(damageTypeAmp, damage.type); if (damageAmpByType != null) { amt += damage.amount * damageAmpByType.val; } else { DamageMod damageReduceByType = GetDamageMod(damageTypeReduction, damage.type); if (damageReduceByType != null) { amt -= amt * damageReduceByType.val; } } return(amt > 0.0f); } return(false); }
protected float CalculateDamageAmount(Damage damage) { float amt = damage.amount; if (damageAmp > 0.0f) { amt += amt * damageAmp; } if (damageReduction > 0.0f) { amt -= amt * damageReduction; } DamageMod damageAmpByType = GetDamageMod(damageTypeAmp, damage.type); if (damageAmpByType != null) { amt += damage.amount * damageAmpByType.val; } else { DamageMod damageReduceByType = GetDamageMod(damageTypeReduction, damage.type); if (damageReduceByType != null) { amt -= amt * damageReduceByType.val; } } return(amt); }
public DamageMod GetDamageMod(DamageMod[] dat, Damage.Type type) { if(dat != null) { for(int i = 0, max = dat.Length; i < max; i++) { if(dat[i].type == type) { return dat[i]; } } } return null; }
public bool ApplyDamage(Damage damage, Vector3 hitPos, Vector3 hitNorm) { mLastDamage = damage; mLastDamagePos = hitPos; mLastDamageNorm = hitNorm; if (!mIsInvul) { float amt = damage.amount; if (damageReduction > 0.0f) { amt -= amt * damageReduction; } DamageMod damageAmpByType = GetDamageMod(damageTypeAmp, damage.type); if (damageAmpByType != null) { amt += damage.amount * damageAmpByType.val; } else { DamageMod damageReduceByType = GetDamageMod(damageTypeReduction, damage.type); if (damageReduceByType != null) { amt -= amt * damageReduceByType.val; } } if (amt > 0.0f) { if (curHP - amt <= 0.0f && itemDropIndex >= 0) { //Debug.Log("drop?"); ItemDropManager.instance.DoDrop(itemDropIndex, transform.localToWorldMatrix.MultiplyPoint(itemDropOfs)); } curHP -= amt; return(true); } } return(false); }