Ejemplo n.º 1
0
        /// <summary>
        /// Applies the effects of the ability being used on all of it's targets.
        /// </summary>
        /// <param name="attacker">The entity performing the ability.</param>
        /// <param name="ability">The ability to apply the effects of.</param>
        /// <param name="targets">The targets of the ability.</param>
        private void ApplyEffects(CombatEntity attacker, Ability ability, IEnumerable <CombatEntity> targets)
        {
            bool isCrit = IsCritical(attacker, ability);

            foreach (var target in targets)
            {
                var damage  = DamageCalculator.GetTotalDamage(attacker, target, ability, isCrit);
                var healing = DamageCalculator.GetHeal(attacker, ability, isCrit);
                healing += target.Resources.MaxHealth * ability.PercentHeal / 100;

                target.Resources.CurrentHealth += healing;
                target.Resources.CurrentHealth -= DamageCalculator.GetDamageTypesAsInt(damage);
                if (target.Resources.CurrentHealth > 0)
                {
                    _statusEffectManager.Apply(target, attacker, ability.AppliedStatusEffects, isCrit);
                    if (target.Resources.CurrentHealth > target.Resources.MaxHealth)
                    {
                        target.Resources.CurrentHealth = target.Resources.MaxHealth;
                    }
                }
                else
                {
                    _statusEffectManager.RemoveAll(target);
                    target.Resources.CurrentHealth = 0;
                }
            }

            if (ability.SelfAppliedStatusEffects.Any())
            {
                _statusEffectManager.Apply(attacker, attacker, ability.SelfAppliedStatusEffects, isCrit);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Removes all combat effects from all CombatEntities in a formation to prepare to exit combat.
 /// </summary>
 /// <param name="formation">The Formation to sanitize.</param>
 private void SanitizeFormation(Formation formation)
 {
     lock (_key)
     {
         foreach (var row in formation.Positions)
         {
             foreach (var entity in row)
             {
                 if (entity == null)
                 {
                     continue;
                 }
                 entity.Resources.CurrentActionPoints = 0;
                 _statusEffectManager.RemoveAll(entity);
             }
         }
     }
 }