Exemplo n.º 1
0
        //! Public Member functions
        public void DealDamage(Character other, uint damagesAmount)
        {
            if (MathUtilility.GetDistance(WorldPosition, other.WorldPosition) > _maxRange ||
                ReferenceEquals(this, other) || AreWeAlly(other))
            {
                return;
            }
            bool IsLevelBehindByMaxLevelDifference() => (int)other.Level - (int)Level >= MaxLevelDifference;
            bool IsLevelAboveByMaxLevelDifference() => (int)Level - (int)other.Level >= MaxLevelDifference;

            if (IsLevelAboveByMaxLevelDifference())
            {
                damagesAmount += damagesAmount / 2;
            }
            else if (IsLevelBehindByMaxLevelDifference())
            {
                damagesAmount -= damagesAmount / 2;
            }
            if (IsDamagesExceedOtherHealth(damagesAmount, other.Health))
            {
                other.Health = 0;
                other.State  = CharacterState.Dead;
            }
            else
            {
                other.Health -= damagesAmount;
            }
        }
Exemplo n.º 2
0
 public void DealDamage(IPropsTarget target, uint damagesAmount)
 {
     if (MathUtilility.GetDistance(WorldPosition, target.WorldPosition) > _maxRange)
     {
         return;
     }
     if (IsDamagesExceedOtherHealth(damagesAmount, target.Health))
     {
         target.Health = 0;
         target.State  = PropsTargetState.Destroyed;
     }
     else
     {
         target.Health -= damagesAmount;
     }
 }