Exemple #1
0
        public void Death(Damageable.DamageMessage msg)
        {
            Vector3 pushForce = transform.position - msg.damageSource;

            pushForce.y = 0;

            transform.forward = -pushForce.normalized;
            m_EnemyController.AddForce(pushForce.normalized * 7.0f - Physics.gravity * 0.6f);

            m_EnemyController.animator.SetTrigger(hashHit);
            m_EnemyController.animator.SetTrigger(hashThrown);

            //We unparent the deathAudio source, as it would destroy it with the gameobject when it get replaced by the ragdol otherwise
            deathAudio.transform.SetParent(null, true);
            deathAudio.PlayRandomClip();

            GameObject.Destroy(deathAudio, deathAudio.clip == null ? 0.0f : deathAudio.clip.length + 0.5f);
        }
Exemple #2
0
        private void OnTriggerStay(Collider other)
        {
            var d = other.GetComponent <Damageable>();

            if (d == null)
            {
                return;
            }

            var msg = new Damageable.DamageMessage()
            {
                amount     = damageAmount,
                damager    = this,
                direction  = Vector3.up,
                stopCamera = stopCamera
            };

            d.ApplyDamage(msg);
        }
Exemple #3
0
        void SendDamageMessage(GameObject other)
        {
            var d = other.GetComponent <Damageable>();

            if (d == null)
            {
                return;
            }

            var msg = new Damageable.DamageMessage()
            {
                amount     = damageAmount,
                damager    = this,
                direction  = Vector3.up,
                stopCamera = false
            };

            d.ApplyDamage(msg);
        }
        private void OnTriggerStay(Collider other)
        {
            if ((damagedLayers.value & 1 << other.gameObject.layer) == 0)
            {
                return;
            }

            Damageable d = other.GetComponentInChildren <Damageable>();

            if (d != null && !d.IsInvulnerable)
            {
                Damageable.DamageMessage message = new Damageable.DamageMessage
                {
                    damageSource = transform.position,
                    damager      = this,
                    amount       = amount,
                    direction    = (other.transform.position - transform.position).normalized,
                    throwing     = false
                };

                d.ApplyDamage(message);
            }
        }
Exemple #5
0
        public void ApplyDamage(Damageable.DamageMessage msg)
        {
            if (msg.damager.name == "Staff")
            {
                CameraShake.Shake(0.06f, 0.1f);
            }

            float verticalDot   = Vector3.Dot(Vector3.up, msg.direction);
            float horizontalDot = Vector3.Dot(transform.right, msg.direction);

            Vector3 pushForce = transform.position - msg.damageSource;

            pushForce.y = 0;

            transform.forward = -pushForce.normalized;
            m_EnemyController.AddForce(pushForce.normalized * 5.5f, false);

            m_EnemyController.animator.SetFloat(hashVerticalDot, verticalDot);
            m_EnemyController.animator.SetFloat(hashHorizontalDot, horizontalDot);

            m_EnemyController.animator.SetTrigger(hashHit);

            hitAudio.PlayRandomClip();
        }