Esempio n. 1
0
 protected override void TryBlockAttack(vDamage damage)
 {
     base.TryBlockAttack(damage);
     if (MeleeManager && damage.sender)
     {
         if (isBlocking && MeleeManager.CanBlockAttack(damage.sender.position))
         {
             var fighter         = damage.sender.GetComponent <vIMeleeFighter>();
             var damageReduction = MeleeManager.GetDefenseRate();
             if (damageReduction > 0)
             {
                 damage.ReduceDamage(damageReduction);
             }
             if (fighter != null && MeleeManager.CanBreakAttack())
             {
                 fighter.OnRecoil(MeleeManager.GetDefenseRecoilID());
             }
             MeleeManager.OnDefense();
         }
         else
         {
             damage.hitReaction = true;
         }
     }
 }
Esempio n. 2
0
 public void OnReceiveAttack(Damage damage, IMeleeFighter attacker)
 {
     // character is blocking
     if (!damage.ignoreDefense && isBlocking && meleeManager != null && meleeManager.CanBlockAttack(attacker.Character().transform.position))
     {
         var damageReduction = meleeManager.GetDefenseRate();
         if (damageReduction > 0)
         {
             damage.ReduceDamage(damageReduction);
         }
         if (attacker != null && meleeManager != null && meleeManager.CanBreakAttack())
         {
             attacker.OnRecoil(meleeManager.GetDefenseRecoilID());
         }
         meleeManager.OnDefense();
         //cc.currentStaminaRecoveryDelay = damage.staminaRecoveryDelay;
         //cc.currentStamina -= damage.staminaBlockCost;
     }
     // apply damage
     character.TakeDamage(damage, !isBlocking);
 }