private void ReceiveDamage(Damage damage) { BeforeBeingDamaged?.Invoke(damage); var defense = GetDefense(damage.Type); damage.Value -= defense; damage.Value = damage.Value < 0 ? 0 : damage.Value; HealthPoints.Value -= damage.Value; AfterBeingDamaged?.Invoke(damage); }
private void ReceiveDamage(Damage damage) { BeforeBeingDamaged?.Invoke(damage); int defense = GetDefense(damage.Type); float reduction = damage.Value * defense / 100f; damage.Value -= (int)reduction; damage.Value = damage.Value < 0 ? 0 : damage.Value; if (Shield.Value >= damage.Value) { Shield.Value -= damage.Value; damage.Value = 0; } else { damage.Value -= Shield.Value; Shield.Value = 0; } HealthPoints.Value -= damage.Value; AfterBeingDamaged?.Invoke(damage); }