Ejemplo n.º 1
0
 public Cooldown(AbstractAttacker sender, CooldownTypes type, int span)
 {
     Owner   = sender;
     Type    = type;
     Span    = span;
     Created = DateTime.Now;
 }
Ejemplo n.º 2
0
 public PendingAttack(AbstractAttacker from, AbstractAttackable to, AttackTypes attackType, string lootId, int amount)
 {
     From       = from;
     To         = to;
     AttackType = attackType;
     LootId     = lootId;
     Amount     = amount;
 }
Ejemplo n.º 3
0
        public bool Exists(AbstractAttacker sender, CooldownTypes cooldownType)
        {
            if (sender == null)
            {
                return(false);
            }

            return(ServerController.Get <CooldownController>().Exists(sender, cooldownType));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Getting the cooldown
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="cooldownType"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public Cooldown Get(AbstractAttacker sender, CooldownTypes cooldownType)
        {
            if (sender == null)
            {
                Out.QuickLog("Something went wrong while getting the cooldown", LogKeys.ERROR_LOG);
                throw new Exception("Sender is null, something went wrong while getting cooldown");
            }

            return(_cooldowns.FirstOrDefault(x => x.Owner == sender && x.Type == cooldownType));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Checking if it exists
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="cooldownType"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public bool Exists(AbstractAttacker sender, CooldownTypes cooldownType)
        {
            if (sender == null)
            {
                Out.QuickLog("Something went wrong while checking the cooldown", LogKeys.ERROR_LOG);
                throw new Exception("Sender is null, something went wrong while checking cooldown");
            }

            return(_cooldowns.Any(x => x.Owner == sender && x.Type == cooldownType));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Getting the cooldown
        /// </summary>
        /// <param name="sender">Person who needs to have the cooldown</param>
        /// <param name="type">Type of cooldown</param>
        /// <returns>Cooldown</returns>
        /// <exception cref="Exception">Sender is invalid</exception>
        /// <exception cref="NullReferenceException">Cooldown is not found</exception>
        public Cooldown Get(AbstractAttacker sender, CooldownTypes type)
        {
            if (sender == null)
            {
                Out.QuickLog("Something is wrong with CooldownManager's sender on Get", LogKeys.ERROR_LOG);
                throw new Exception("Something is wrong with sender");
            }

            var cooldown = ServerController.Get <CooldownController>().Get(sender, type);

            if (cooldown == null)
            {
                Out.QuickLog("Failed getting a cooldown from type " + type, LogKeys.ERROR_LOG);
                throw new NullReferenceException("Cooldown is null, failed getting");
            }
            return(cooldown);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Enforcing a damage where the attacker exists
        /// </summary>
        /// <param name="target">Target</param>
        /// <param name="attacker">Attacker</param>
        /// <param name="damage">Damage (if percentage 1-100)</param>
        /// <param name="absorbDamage">Damage absorb = shield transfer (if percentage 1-100)</param>
        /// <param name="calculationType">Calculation type (defined or percentage)</param>
        /// <param name="attackType">Type of attack</param>
        public void EnforceDamage(AbstractAttackable target, AbstractAttacker attacker, int damage, int absorbDamage,
                                  DamageCalculationTypes calculationType, AttackTypes attackType)
        {
            if (target == null)
            {
                Out.QuickLog("Something went wrong enforcing damage, target is null", LogKeys.ERROR_LOG);
                throw new Exception("Target is null, cannot damage");
            }

            if (attacker == null)
            {
                Out.QuickLog("Something went wrong enforcing damage, attacker is null", LogKeys.ERROR_LOG);
                throw new Exception("Attacker is null, cannot damage");
            }

            if (damage == 0 && absorbDamage == 0)
            {
                // damage finished
                return;
            }

            _pendingDamages.Enqueue(new PendingDamage(target, attacker, damage, absorbDamage, calculationType, attackType));
        }
Ejemplo n.º 8
0
 public PendingAttack[] GetActiveCombatsForAttacker(AbstractAttacker attacker)
 {
     return(ServerController.Get <AttackController>().GetActiveAttacksByAttacker(attacker));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creating an attack for every sort of entity
 /// </summary>
 /// <param name="attacker">Attacker</param>
 /// <param name="target">Target</param>
 /// <param name="type">Type</param>
 /// <param name="lootId">Optional</param>
 /// <param name="amount">Optional</param>
 public void CreateCombat(AbstractAttacker attacker, AbstractAttackable target, AttackTypes type, string lootId = "",
                          int amount = 0)
 {
     CreateAttackCombat(new PendingAttack(attacker, target, type, lootId, amount));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Secondary constructor
 /// </summary>
 /// <param name="target"></param>
 /// <param name="attacker"></param>
 /// <param name="damage"></param>
 /// <param name="absorbDamage"></param>
 /// <param name="calculationType"></param>
 /// <param name="attackType"></param>
 public PendingDamage(AbstractAttackable target, AbstractAttacker attacker, int damage, int absorbDamage,
                      DamageCalculationTypes calculationType, AttackTypes attackType) :
     this(target, damage, absorbDamage, calculationType, attackType)
 {
     Attacker = attacker;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Secondary constructor
 /// </summary>
 /// <param name="attacker"></param>
 /// <param name="affectedDistance"></param>
 /// <param name="damage"></param>
 /// <param name="absorbDamage"></param>
 /// <param name="calculationType"></param>
 /// <param name="attackType"></param>
 public PendingDamage(AbstractAttacker attacker, int affectedDistance, int damage, int absorbDamage,
                      DamageCalculationTypes calculationType, AttackTypes attackType) : this(affectedDistance, damage, absorbDamage, calculationType, attackType)
 {
     Attacker = attacker;
 }
Ejemplo n.º 12
0
 private Cooldown(AbstractAttacker sender, CooldownTypes type, int span, Action onStartAction, Action onFinishAction) :
     this(sender, type, span, onFinishAction)
 {
     OnStartAction = onStartAction;
 }
Ejemplo n.º 13
0
 public Cooldown(AbstractAttacker sender, CooldownTypes type, int span, Action onCooldownFinish) : this(sender, type, span)
 {
     OnCompleteAction = onCooldownFinish;
 }
Ejemplo n.º 14
0
 public PendingAttack[] GetActiveAttacksByAttacker(AbstractAttacker attacker)
 {
     return(_pendingAttacksQueue.Where(x => x.From == attacker).ToArray());
 }
Ejemplo n.º 15
0
        private void DamageAttackable(AbstractAttackable target, AbstractAttacker attacker, int hpDamage,
                                      int shieldDamage)
        {
            if (target.CurrentShield > 0)
            {
                //if (totalAbsDamage > 0)
                //    totalDamage += totalAbsDamage;
                //For example => Target has 80% abs but you' have moth (+20% penetration) :> damage * 0.6

                var totalAbs = Math.Abs(attacker.ShieldPenetration - target.ShieldAbsorption);

                if (totalAbs > 0)
                {
                    var _absDmg = (int)(totalAbs * shieldDamage);
                    target.CurrentShield -= _absDmg;
                    if (target.CurrentShield < 0)
                    {
                        target.CurrentShield = 0;
                    }
                    if (attacker != null)
                    {
                        attacker.CurrentShield += _absDmg;
                    }
                }

                int healthDamage;
                if (target.CurrentShield <= hpDamage || target.CurrentShield <= shieldDamage)
                {
                    healthDamage          = Math.Abs(target.CurrentShield - hpDamage);
                    target.CurrentShield  = 0;
                    target.CurrentHealth -= healthDamage;
                }
                else
                {
                    target.CurrentShield -= (int)shieldDamage;  //Correspondent shield damage
                    healthDamage          = (int)(hpDamage * (1 - totalAbs));
                }

                if (target.CurrentNanoHull > 0)
                {
                    //If the player can receive some damage on the nanohull
                    if (target.CurrentNanoHull - healthDamage < 0)
                    {
                        var nanoDamage = healthDamage - target.CurrentNanoHull;
                        target.CurrentNanoHull = 0;
                        target.CurrentHealth  -= nanoDamage;
                    }
                    else
                    {
                        target.CurrentNanoHull -= healthDamage;
                    }
                }
                else
                {
                    target.CurrentHealth -= healthDamage; //80% shield abs => 20% life
                }
            }
            else //NO SHIELD
            {
                if (target.CurrentNanoHull > 0)
                {
                    //If the player can receive some damage on the nanohull
                    if (target.CurrentNanoHull - hpDamage < 0)
                    {
                        var nanoDamage = hpDamage - target.CurrentNanoHull;
                        target.CurrentNanoHull = 0;
                        target.CurrentHealth  -= nanoDamage;
                    }
                    else
                    {
                        target.CurrentNanoHull -= hpDamage; //Full dmg to nanohull
                    }
                }
                else
                {
                    target.CurrentHealth -= hpDamage; //Full dmg to health
                }
            }
        }