public virtual void CancelReload(vDamage damage)
 {
     if (!ignoreReacionIDList.Contains(damage.reaction_id) && isReloading)
     {
         StartCoroutine(CancelReloadRoutine());
     }
 }
Beispiel #2
0
        // active ragdoll - call this method to turn the ragdoll on
        public void ActivateRagdoll(vDamage damage)
        {
            if (isActive || (damage != null && !damage.activeRagdoll))
            {
                return;
            }

            inApplyDamage = true;
            isActive      = true;

            if (transform.parent != null && !transform.parent.gameObject.isStatic)
            {
                transform.parent = null;
            }

            iChar.EnableRagdoll();

            var isDead = !(iChar.currentHealth > 0);

            // turn ragdoll on
            inStabilize = true;
            ragdolled   = true;

            // start to check if the ragdoll is stable
            StartCoroutine(RagdollStabilizer(2f));

            if (!isDead)
            {
                characterHips.SetParent(_ragdollContainer.transform);// = null;
            }
            Invoke("ResetDamage", 0.2f);
        }
Beispiel #3
0
        /// <summary>
        /// TAKE DAMAGE - you can override the take damage method from the vCharacter and add your own calls
        /// </summary>
        /// <param name="damage"> damage to apply </param>
        public override void TakeDamage(vDamage damage, bool hitReaction)
        {
            // don't apply damage if the character is rolling, you can add more conditions here
            if (isDead)
            {
                return;
            }

            // reduce the current health by the damage amount.
            currentHealth -= damage.damageValue;
            currentHealthRecoveryDelay = healthRecoveryDelay;
            // update the HUD display
            if (healthSlider != null)
            {
                healthSlider.Damage(damage.damageValue);
            }
            // apply vibration on the gamepad
            vInput.instance.GamepadVibration(0.25f);
            // call OnReceiveDamage Event
            onReceiveDamage.Invoke(damage);
            if (currentHealth <= 0)
            {
                onDead.Invoke(gameObject);
            }
        }
Beispiel #4
0
 protected override void TriggerDamageReaction(vDamage damage)
 {
     if (!isRolling)
     {
         base.TriggerDamageReaction(damage);
     }
 }
Beispiel #5
0
        protected virtual void NetworkOnReceiveDamage(string Damage)
        {
            vDamage _recievedDamage = JsonUtility.FromJson <vDamage>(Damage);

            waitingResponse = true;
            hc.TakeDamage(_recievedDamage);
        }
Beispiel #6
0
 public void OnReceiveAttack(vDamage damage, vIMeleeFighter attacker)
 {
     if (overrideReactionID)
     {
         damage.reaction_id = reactionID;
     }
     if (ragdoll && !ragdoll.iChar.isDead)
     {
         var _damage = new vDamage(damage);
         var value   = (float)_damage.damageValue;
         _damage.damageValue = (int)(value * damageMultiplier);
         ragdoll.gameObject.ApplyDamage(_damage, attacker);
     }
     else
     {
         if (!iChar)
         {
             iChar = GetComponentInParent <vCharacter>();
         }
         if (iChar)
         {
             var _damage = new vDamage(damage);
             var value   = (float)_damage.damageValue;
             _damage.damageValue = (int)(value * damageMultiplier);
             iChar.gameObject.ApplyDamage(_damage, attacker);
         }
     }
 }
        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);
        }
Beispiel #8
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));
     }
 }
Beispiel #9
0
    protected virtual void Explode()
    {
        onExplode.Invoke();
        var colliders = Physics.OverlapSphere(transform.position, maxExplosionRadius, applyDamageLayer);

        for (int i = 0; i < colliders.Length; ++i)
        {
            if (!collidersReached.Contains(colliders[i].gameObject))
            {
                collidersReached.Add(colliders[i].gameObject);
                var _damage = new vDamage(damage);
                _damage.sender      = transform;
                _damage.hitPosition = colliders[i].ClosestPointOnBounds(transform.position);
                _damage.receiver    = colliders[i].transform;
                var distance    = Vector3.Distance(transform.position, _damage.hitPosition);
                var damageValue = distance <= minExplosionRadius ? damage.damageValue : GetPercentageForce(distance, damage.damageValue);
                _damage.damageValue = (int)damageValue;
                if (colliders[i].gameObject.IsAMeleeFighter())
                {
                    colliders[i].gameObject.GetMeleeFighter().OnReceiveAttack(_damage, null);
                }
                else
                {
                    colliders[i].gameObject.ApplyDamage(_damage);
                }
            }
        }
        StartCoroutine(ApplyExplosionForce());
        StartCoroutine(DestroyBomb());
    }
Beispiel #10
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;
         }
     }
 }
Beispiel #11
0
        /// <summary>
        /// Listener of Damage Event
        /// </summary>
        /// <param name="hitInfo"></param>
        public virtual void OnDamageHit(vHitInfo hitInfo)
        {
            vDamage damage = new vDamage(hitInfo.attackObject.damage);

            damage.sender      = transform;
            damage.reaction_id = currentReactionID;
            damage.recoil_id   = currentRecoilID;
            if (this.activeRagdoll)
            {
                damage.activeRagdoll = this.activeRagdoll;
            }
            if (this.attackName != string.Empty)
            {
                damage.damageType = this.attackName;
            }
            if (this.ignoreDefense)
            {
                damage.ignoreDefense = this.ignoreDefense;
            }
            /// Calc damage with multiplier
            /// and Call ApplyDamage of attackObject
            damage.damageValue *= damageMultiplier > 1 ? damageMultiplier : 1;
            hitInfo.attackObject.ApplyDamage(hitInfo.hitBox, hitInfo.targetCollider, damage);
            onDamageHit.Invoke(hitInfo);
        }
 protected override void TriggerDamageReaction(vDamage damage)
 {
     if (!customAction)
         base.TriggerDamageReaction(damage);
     else if (damage.activeRagdoll)
         onActiveRagdoll.Invoke();
 }
Beispiel #13
0
        public void TakeDamage(vDamage damage)
        {
            var point         = damage.hitPosition;
            var relativePoint = transform.position;

            relativePoint.y = point.y;
            var forceForward = relativePoint - point;

            if (character != null && joint != null && character.currentHealth < 0)
            {
                joint.connectedBody = null;
                if (character.removeComponentsAfterDie)
                {
                    foreach (MonoBehaviour mono in character.gameObject.GetComponentsInChildren <MonoBehaviour>())
                    {
                        if (mono != this)
                        {
                            Destroy(mono);
                        }
                    }
                }
            }

            if (_rigidbody != null)
            {
                _rigidbody.AddForce(forceForward * (damage.damageValue * forceMultipler), ForceMode.Impulse);
            }
        }
Beispiel #14
0
    public void TakeDamage(vDamage damage)
    {
        var damageAmount = damage.damageValue;

        // Do your damage code here
        Debug.Log("Took " + damageAmount + " damage.");
    }
Beispiel #15
0
        protected virtual void SendNetworkBreakObject()
        {
            if (isBroken == true)
            {
                return;
            }
            isBroken = true;

            if (GetComponent <PhotonRigidbodyView>())
            {
                Destroy(GetComponent <PhotonRigidbodyView>());
            }
            if (GetComponent <Rigidbody>())
            {
                Destroy(GetComponent <Rigidbody>());
            }
            vDamage breakableDamage = new vDamage();

            breakableDamage.damageValue = 100000;

            if (dropPrefab == true)
            {
                DropObject();
            }
            GetComponent <vBreakableObject>().TakeDamage(breakableDamage);
        }
    /// <summary>
    /// APPLY DAMAGE - call this method by a SendMessage with the damage value
    /// </summary>
    /// <param name="damage"> damage to apply </param>
    public override void TakeDamage(vDamage damage, bool hitReaction)
    {
        // don't apply damage if the character is rolling, you can add more conditions here
        if (isDead)
        {
            return;
        }

        // instantiate the hitDamage particle - check if your character has a HitDamageParticle component
        var hitrotation = Quaternion.LookRotation(new Vector3(transform.position.x, damage.hitPosition.y, transform.position.z) - damage.hitPosition);

        SendMessage("TriggerHitParticle", new vHittEffectInfo(new Vector3(transform.position.x, damage.hitPosition.y, transform.position.z), hitrotation, damage.attackName), SendMessageOptions.DontRequireReceiver);

        // reduce the current health by the damage amount.
        currentHealth -= damage.damageValue;
        currentHealthRecoveryDelay = healthRecoveryDelay;

        // update the HUD display
        if (healthSlider != null)
        {
            healthSlider.Damage(damage.damageValue);
        }

        // trigger the hit sound
        if (damage.sender != null)
        {
            damage.sender.SendMessage("PlayHitSound", SendMessageOptions.DontRequireReceiver);
        }

        // apply vibration on the gamepad
        transform.SendMessage("GamepadVibration", 0.25f, SendMessageOptions.DontRequireReceiver);
        onReceiveDamage.Invoke(damage);
    }
Beispiel #17
0
 public void EnableDamageSprite(vDamage damage)
 {
     if (damageImage != null)
     {
         damageImage.enabled = true;
     }
     damaged = true;
 }
Beispiel #18
0
 public void ApplyDamage(string amount)
 {
     if (GetComponent <PhotonView>().IsMine == true)
     {
         vDamage damage = JsonUtility.FromJson <vDamage>(amount);
         GetComponent <vThirdPersonController>().TakeDamage(damage);
     }
 }
        public override void TakeDamage(vDamage damage)
        {
            // don't apply damage if the character is rolling, you can add more conditions here
            if (currentHealth <= 0 || (!damage.ignoreDefense && isRolling))
                return;

            base.TakeDamage(damage);
        }
 public void TakeDamage(vDamage damage, bool hitReaction)
 {
     if (!isBroken)
     {
         isBroken = true;
         StartCoroutine(BreakObjet());
     }
 }
Beispiel #21
0
 public override void TakeDamage(vDamage damage)
 {
     base.TakeDamage(damage);
     if (damage.damageValue > 0)
     {
         TriggerDamageRection(damage);
     }
 }
Beispiel #22
0
 /// <summary>
 /// This makes this action only callable by the owner and networked
 /// players will not react to the input of the owner players.
 /// </summary>
 public override void OnReceiveAttack(vDamage damage, vIMeleeFighter attacker)
 {
     if (GetComponent <PhotonView>().IsMine == false)
     {
         return;
     }
     base.OnReceiveAttack(damage, attacker);
 }
Beispiel #23
0
 /// <summary>
 /// Add Damage to vCharacter every 0.1 seconds
 /// </summary>
 /// <param name="damage"></param>
 public void ApplyDamage(vDamage damage)
 {
     if (isActive && ragdolled && !inApplyDamage && iChar)
     {
         inApplyDamage = true;
         iChar.TakeDamage(damage);
         Invoke("ResetDamage", 0.2f);
     }
 }
        protected override void TriggerDamageRection(vDamage damage)
        {
            var hitReactionConditions = !actions || !customAction;

            if (hitReactionConditions)
            {
                base.TriggerDamageRection(damage);
            }
        }
Beispiel #25
0
 /// <summary>
 /// Used to send the `NetworkOnReceiveDamage` RPC. This has this damage
 /// be received by all networked versions across the network.
 /// </summary>
 /// <param name="damage"></param>
 public virtual void SendDamageOverNetwork(vDamage damage)
 {
     if (waitingResponse)
     {
         waitingResponse = false;
         return;
     }
     GetComponent <PhotonView>().RPC("NetworkOnReceiveDamage", RpcTarget.OthersBuffered, JsonUtility.ToJson(damage));
 }
Beispiel #26
0
        /// <summary>
        /// Apply damage to target collider (TakeDamage, damage))
        /// </summary>
        /// <param name="hitBox">vHitBox object</param>
        /// <param name="other">collider target</param>
        /// <param name="damage"> damage</param>
        public void ApplyDamage(vHitBox hitBox, Collider other, vDamage damage)
        {
            vDamage _damage = new vDamage(damage);

            _damage.receiver    = other.transform;
            _damage.damageValue = (int)Mathf.RoundToInt(((float)(damage.damageValue + damageModifier) * (((float)hitBox.damagePercentage) * 0.01f)));
            _damage.hitPosition = hitBox.transform.position;
            other.gameObject.ApplyDamage(_damage, meleeManager.fighter);
        }
 public override void TakeDamage(vDamage damage)
 {
     // don't apply damage if the character is rolling, you can add more conditions here
     if (currentHealth <= 0 || (!damage.ignoreDefense && isRolling))
     {
         return;
     }
     base.TakeDamage(damage);
     vInput.instance.GamepadVibration(0.25f);
 }
Beispiel #28
0
        protected virtual void TryBlockAttack(vDamage damage)
        {
            var canBlock = !ignoreDefenseDamageTypes.Contains(damage.damageType) && !damage.ignoreDefense;

            if (string.IsNullOrEmpty(damage.damageType) && canBlock)
            {
                ImmediateBlocking();
            }
            damage.hitReaction = !isBlocking || !canBlock;
        }
Beispiel #29
0
 protected override void TryBlockAttack(vDamage damage)
 {
     if (shooterManager.currentWeapon != null)
     {
         isBlocking = false;
     }
     else
     {
         base.TryBlockAttack(damage);
     }
 }
Beispiel #30
0
 public virtual void TakeDamage(vDamage damage, bool hitReaction = true)
 {
     if (damage != null)
     {
         currentHealth -= damage.damageValue;
         if (damage.activeRagdoll)
         {
             EnableRagdoll();
         }
     }
 }