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