コード例 #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;
         }
     }
 }
コード例 #2
0
 protected virtual void TryApplyRecoil(vIMeleeFighter fighter)
 {
     if (MeleeManager && fighter != null)
     {
         if (isBlocking && MeleeManager.CanBlockAttack(fighter.transform.position))
         {
             if (MeleeManager.CanBreakAttack())
             {
                 fighter.OnRecoil(MeleeManager.GetDefenseRecoilID());
             }
         }
     }
 }
コード例 #3
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);
 }