Example #1
0
        public void ApplyDamage(Damageable.DamageMessage msg)
        {
            //TODO : make that more generic, (e.g. move it to the MeleeWeapon code with a boolean to enable shaking of camera on hit?)
            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;
            Controller.AddForce(pushForce.normalized * 5.5f, false);

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

            Controller.animator.SetTrigger(hashHit);

            hitAudio.PlayRandomClip();
        }
Example #2
0
 /// <summary>
 /// Called by animation events.
 /// </summary>
 public void Grunt()
 {
     if (gruntAudio != null)
     {
         gruntAudio.PlayRandomClip();
     }
 }
Example #3
0
 public void Spotted()
 {
     if (spottedAudio != null)
     {
         spottedAudio.PlayRandomClip();
     }
 }
Example #4
0
 /// <summary>
 /// Called by animation events.
 /// </summary>
 /// <param name="frontFoot">Has a value of 1 when it's a front foot stepping and 0 when it's a back foot.</param>
 void PlayStep(int frontFoot)
 {
     if (frontStepAudio != null && frontFoot == 1)
     {
         frontStepAudio.PlayRandomClip();
     }
     else if (backStepAudio != null && frontFoot == 0)
     {
         backStepAudio.PlayRandomClip();
     }
 }
        public void Shoot()
        {
            throwAudioPlayer.PlayRandomClip();

            Vector3 toTarget = m_GrenadeTarget - transform.position;

            //the grenade is launched a couple of meters in "front" of the player, because it bounce and roll, to make it a bit ahrder for the player
            //to avoid it
            Vector3 target = transform.position + (toTarget - toTarget * 0.3f);

            grenadeLauncher.Attack(target);
        }
Example #6
0
        public void Explosion()
        {
            if (explosionPlayer)
            {
                explosionPlayer.transform.SetParent(null);
                explosionPlayer.PlayRandomClip();
            }

            int count = Physics.OverlapSphereNonAlloc(transform.position, explosionRadius, m_ExplosionHitCache,
                                                      damageMask.value);

            Damageable.DamageMessage message = new Damageable.DamageMessage
            {
                amount       = damageAmount,
                damageSource = transform.position,
                damager      = this,
                stopCamera   = false,
                throwing     = true
            };


            for (int i = 0; i < count; ++i)
            {
                Damageable d = m_ExplosionHitCache[i].GetComponentInChildren <Damageable>();

                if (d != null)
                {
                    d.ApplyDamage(message);
                }
            }

            pool.Free(this);

            Vector3 playPosition = transform.position;
            Vector3 playNormal   = Vector3.up;

            if (vfxOnGround)
            {
                RaycastHit hit;
                if (Physics.Raycast(transform.position, Vector3.down, out hit, 100.0f, m_EnvironmentLayer))
                {
                    playPosition = hit.point + hit.normal * 0.1f;
                    playNormal   = hit.normal;
                }
            }

            m_VFXInstance.gameObject.transform.position = playPosition;
            m_VFXInstance.gameObject.transform.up       = playNormal;
            m_VFXInstance.time = 0.0f;
            m_VFXInstance.gameObject.SetActive(true);
            m_VFXInstance.Play(true);
        }
Example #7
0
        // Called each physics step to check if audio should be played and if so instruct the relevant random audio player to do so.
        void PlayAudio()
        {
            float footfallCurve = m_Animator.GetFloat(m_HashFootFall);

            if (footfallCurve > 0.01f && !footstepPlayer.playing && footstepPlayer.canPlay)
            {
                footstepPlayer.playing = true;
                footstepPlayer.canPlay = false;
                footstepPlayer.PlayRandomClip(m_CurrentWalkingSurface, m_ForwardSpeed < 4 ? 0 : 1);
            }
            else if (footstepPlayer.playing)
            {
                footstepPlayer.playing = false;
            }
            else if (footfallCurve < 0.01f && !footstepPlayer.canPlay)
            {
                footstepPlayer.canPlay = true;
            }

            if (m_IsGrounded && !m_PreviouslyGrounded)
            {
                landingPlayer.PlayRandomClip(m_CurrentWalkingSurface, bankId: m_ForwardSpeed < 4 ? 0 : 1);
                emoteLandingPlayer.PlayRandomClip();
            }

            if (!m_IsGrounded && m_PreviouslyGrounded && m_VerticalSpeed > 0f)
            {
                emoteJumpPlayer.PlayRandomClip();
            }

            if (m_CurrentStateInfo.shortNameHash == m_HashHurt && m_PreviousCurrentStateInfo.shortNameHash != m_HashHurt)
            {
                hurtAudioPlayer.PlayRandomClip();
            }

            if (m_CurrentStateInfo.shortNameHash == m_HashEllenDeath && m_PreviousCurrentStateInfo.shortNameHash != m_HashEllenDeath)
            {
                emoteDeathPlayer.PlayRandomClip();
            }

            if (m_CurrentStateInfo.shortNameHash == m_HashEllenCombo1 && m_PreviousCurrentStateInfo.shortNameHash != m_HashEllenCombo1 ||
                m_CurrentStateInfo.shortNameHash == m_HashEllenCombo2 && m_PreviousCurrentStateInfo.shortNameHash != m_HashEllenCombo2 ||
                m_CurrentStateInfo.shortNameHash == m_HashEllenCombo3 && m_PreviousCurrentStateInfo.shortNameHash != m_HashEllenCombo3 ||
                m_CurrentStateInfo.shortNameHash == m_HashEllenCombo4 && m_PreviousCurrentStateInfo.shortNameHash != m_HashEllenCombo4)
            {
                emoteAttackPlayer.PlayRandomClip();
            }
        }
Example #8
0
        public void Death(Damageable.DamageMessage msg)
        {
            Vector3 pushForce = transform.position - msg.damageSource;

            pushForce.y = 0;

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

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

            //We unparent the hit 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);
        }
Example #9
0
        public void BeginAttack(bool thowingAttack)
        {
            if (attackAudio != null)
            {
                attackAudio.PlayRandomClip();
            }
            throwingHit = thowingAttack;

            m_InAttack = true;

            m_PreviousPos = new Vector3[attackPoints.Length];

            for (int i = 0; i < attackPoints.Length; ++i)
            {
                Vector3 worldPos = attackPoints[i].attackRoot.position +
                                   attackPoints[i].attackRoot.TransformVector(attackPoints[i].offset);
                m_PreviousPos[i] = worldPos;

#if UNITY_EDITOR
                attackPoints[i].previousPositions.Clear();
                attackPoints[i].previousPositions.Add(m_PreviousPos[i]);
#endif
            }
        }
Example #10
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();
        }
 public void PlayStep()
 {
     footstepAudioPlayer.PlayRandomClip();
 }
 public void Die()
 {
     deathAudioPlayer.PlayRandomClip();
     m_EnemyController.animator.SetTrigger(hashDeathParam);
 }
 public void Hit()
 {
     damageAudioPlayer.PlayRandomClip();
     m_EnemyController.animator.SetTrigger(hashHitParam);
     m_CoreMaterial.SetColor("_Color2", Color.red);
 }
 void OnEnable()
 {
     player.PlayRandomClip();
 }