public void UpdateStats() { Damage.Value = Damage.Base + Damage.Gain * (Level - 1); Range.Value = Range.Base + Range.Gain * (Level - 1); AttackSpeed.Value = AttackSpeed.Base + AttackSpeed.Gain * (Level - 1); ProjectileSpeed.Value = ProjectileSpeed.Base + ProjectileSpeed.Gain * (Level - 1); SellCost.Value = SellCost.Base + SellCost.Gain * (Level - 1); var attributeEffects = Items.SelectMany(item => item.Effects).OfType <AttributeEffect>().ToArray(); foreach (var effect in attributeEffects.Where(effect => !effect.IsMultiply)) { effect.Apply(); } foreach (var upgrade in Upgrades) { upgrade.Apply(); } var damageAmounts = AllEffects.OfType <AreaDamageEffect>() .Where(effect => effect.Amount != null) .Select(effect => effect.Amount.Value) .ToArray(); var damageIncreaseAmount = damageAmounts.Where(amount => amount > 0f).Prepend(0f).Max(); var damageDecreaseAmount = damageAmounts.Where(amount => amount < 0f).Prepend(0f).Min(); Damage.Value *= 1f + (damageIncreaseAmount + damageDecreaseAmount) / 100f; var attackSpeedIncreaseAmount = AllEffects.OfType <AreaAttackSpeedEffect>().Select(effect => effect.Amount.Value).Prepend(0f).Max(); AttackSpeed.Value /= 1f + attackSpeedIncreaseAmount / 100f; foreach (var effect in attributeEffects.Where(effect => effect.IsMultiply)) { effect.Apply(); } SellCost.Value = (float)Math.Round(SellCost.Value); _collider.radius = Range.Value; }