Пример #1
0
 public override void OnReceiveAttack(vDamage damage, vIMeleeFighter attacker)
 {
     //character is blocking
     if (!damage.ignoreDefense && isBlocking && meleeManager != null && meleeManager.CanBlockAttack(damage.sender.position))
     {
         var damageReduction = meleeManager.GetDefenseRate();
         if (damageReduction > 0)
         {
             damage.ReduceDamage(damageReduction);
         }
         if (attacker != null && meleeManager != null && meleeManager.CanBreakAttack())
         {
             attacker.BreakAttack(meleeManager.GetDefenseRecoilID());
         }
         meleeManager.OnDefense();
         cc.currentStaminaRecoveryDelay = damage.staminaRecoveryDelay;
         cc.currentStamina -= damage.staminaBlockCost;
     }
     //apply damage
     damage.hitReaction = !isBlocking;
     if (GetComponent <PhotonView>().IsMine == true)
     {
         cc.TakeDamage(damage);
     }
     else
     {
         GetComponent <PhotonView>().RPC("ApplyDamage", RpcTarget.Others, JsonUtility.ToJson(damage));
     }
 }
        public void OnReceiveAttack(vDamage damage, vIMeleeFighter 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 (!passiveToDamage && damage.sender != null)
            {
                SetCurrentTarget(damage.sender);
                currentState = AIStates.Chase;
            }
            damage.hitReaction = !isBlocking;
            if (!passiveToDamage)
            {
                SetAgressive(true);
            }
            TakeDamage(damage);
        }
Пример #3
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;
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Will make the damage zero if you're hitting a teammate and team damage is
 /// set to false in the NetworkManager.
 /// </summary>
 /// <param name="damage">vDamage type, Contains sender and receiver to determine teams.</param>
 public void TeamDamageCheck(vDamage damage)
 {
     if (damage.receiver.GetComponentInParent <SyncPlayer>() &&
         damage.receiver.GetComponentInParent <SyncPlayer>().teamName == damage.sender.GetComponentInParent <SyncPlayer>().teamName&&
         NetworkManager.networkManager.allowTeamDamaging == false)
     {
         damage.hitReaction   = false;
         damage.activeRagdoll = false;
         damage.damageValue   = 0;
         damage.ReduceDamage(100);
     }
 }
Пример #5
0
 public void OnReceiveAttack(vDamage damage, vIMeleeFighter 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
     cc.TakeDamage(damage, !isBlocking);
 }