Пример #1
0
    public void OnReceiveAttack(Damage damage, IMeleeFighter attacker)
    {
        StartCoroutine(CheckChanceToBlock(chanceToBlockAttack, 0));

        var attackPos = (attacker != null && attacker.Character() != null) ? attacker.Character().transform.position : damage.hitPosition;

        if (!damage.ignoreDefense && isBlocking && meleeManager != null && meleeManager.CanBlockAttack(attackPos))
        {
            var damageReduction = meleeManager != null?meleeManager.GetDefenseRate() : 0;

            if (damageReduction > 0)
            {
                damage.ReduceDamage(damageReduction);
            }
            if (attacker != null && meleeManager != null && meleeManager.CanBreakAttack())
            {
                attacker.OnRecoil(meleeManager.GetDefenseRecoilID());
            }
            meleeManager.OnDefense();
        }
        // apply tag from the character that hit you and start chase
        if (!sphereSensor.passiveToDamage && damage.sender != null)
        {
            target       = damage.sender;
            currentState = AIStates.Chase;
            sphereSensor.SetTagToDetect(damage.sender);
        }
        if (!passiveToDamage)
        {
            SetAgressive(true);
        }
        TakeDamage(damage, !isBlocking);
    }
Пример #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);
 }