예제 #1
0
 public PassiveSkillBoostPowerUp(SkillEntry skillEntry)
 {
     this.Value                  = skillEntry.CalculateValue();
     this.AggregateType          = skillEntry.Skill.MasterDefinition.Aggregation;
     skillEntry.PropertyChanged += (sender, eventArgs) =>
     {
         if (eventArgs.PropertyName == nameof(SkillEntry.Level))
         {
             this.Value = skillEntry.CalculateValue();
             this.ValueChanged?.Invoke(this, EventArgs.Empty);
         }
     };
 }
예제 #2
0
        private static int GetDamage(this SkillEntry skill)
        {
            var result = skill.Skill.AttackDamage;

            if (skill.Skill.MasterDefinition != null)
            {
                result += (int)skill.CalculateValue();
            }

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Applies the regeneration of the players skill to the target.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="player">The player.</param>
        /// <param name="skillEntry">The skill entry.</param>
        public static void ApplyRegeneration(this IAttackable target, Player player, SkillEntry skillEntry)
        {
            var skill             = skillEntry.Skill;
            var regenerationValue = player.Attributes.CreateElement(skill.MagicEffectDef.PowerUpDefinition.Boost);
            var regeneration      = Stats.IntervalRegenerationAttributes.FirstOrDefault(r =>
                                                                                        r.CurrentAttribute == skill.MagicEffectDef.PowerUpDefinition.TargetAttribute);

            if (regeneration != null)
            {
                var value = skillEntry.Level == 0 ? regenerationValue.Value : regenerationValue.Value + skillEntry.CalculateValue();
                target.Attributes[regeneration.CurrentAttribute] = Math.Min(
                    target.Attributes[regeneration.CurrentAttribute] + value,
                    target.Attributes[regeneration.MaximumAttribute]);
            }
            else
            {
                Log.Warn(
                    $"Regeneration skill {skill.Name} is configured to regenerate a non-regeneration-able target attribute {skill.MagicEffectDef.PowerUpDefinition.TargetAttribute}.");
            }
        }
예제 #4
0
        /// <summary>
        /// Applies the regeneration of the players skill to the target.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="player">The player.</param>
        /// <param name="skillEntry">The skill entry.</param>
        public static void ApplyRegeneration(this IAttackable target, Player player, SkillEntry skillEntry)
        {
            if (player.Attributes is null)
            {
                return;
            }

            skillEntry.ThrowNotInitializedProperty(skillEntry.Skill is null, nameof(skillEntry.Skill));

            var skill        = skillEntry.Skill;
            var regeneration = Stats.IntervalRegenerationAttributes.FirstOrDefault(r => r.CurrentAttribute == skill.MagicEffectDef?.PowerUpDefinition?.TargetAttribute);

            if (regeneration != null)
            {
                var powerUpDefinition = skill.MagicEffectDef !.PowerUpDefinition !;
                var regenerationValue = player.Attributes.CreateElement(powerUpDefinition.Boost ?? throw Error.NotInitializedProperty(powerUpDefinition, nameof(powerUpDefinition.Boost)));
                var value             = skillEntry.Level == 0 ? regenerationValue.Value : regenerationValue.Value + skillEntry.CalculateValue();
                target.Attributes[regeneration.CurrentAttribute] = Math.Min(
                    target.Attributes[regeneration.CurrentAttribute] + value,
                    target.Attributes[regeneration.MaximumAttribute]);
            }
            else
            {
                player.Logger.LogWarning(
                    $"Regeneration skill {skill.Name} is configured to regenerate a non-regeneration-able target attribute {skill.MagicEffectDef?.PowerUpDefinition?.TargetAttribute}.");
            }
        }