protected virtual void OnCollisionEnter(Collision other) { if (bouncePlayer != null) { bouncePlayer.PlayRandomClip(); } }
/// <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); }
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); //远程攻击目标点 }
// 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() { if (!IsMine) { return; } 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(); } }
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); }
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); deathAudio.transform.SetParent(null, true); deathAudio.PlayRandomClip(); GameObject.Destroy(deathAudio, deathAudio.clip == null ? 0.0f : deathAudio.clip.length + 0.5f); }
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); }
public void ApplyDamage(Damageable.DamageMessage msg) { //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.SetTrigger(GetHit); HitAudio.PlayRandomClip(); MagicDamage(msg); }
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); m_VFXInstance.gameObject.transform.position = transform.position; m_VFXInstance.time = 0.0f; m_VFXInstance.gameObject.SetActive(true); m_VFXInstance.Play(true); }
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(); }
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(Die); if (HealOnDeath && Target != null) { Target.gameObject.GetComponent <Damageable>().Heal(1, 1); } //We unparent the hit source, as it would destroy it with the gameobject when it get replaced by the ragdol otherwise if (DeathAudio != null) { DeathAudio.transform.SetParent(null, true); DeathAudio.PlayRandomClip(); Destroy(DeathAudio, DeathAudio.clip == null ? 0.0f : DeathAudio.clip.length + 0.5f); } }
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; controller.AddForce(pushForce.normalized * 5.5f, false); controller.animator.SetFloat(hashVerticalDot, verticalDot); controller.animator.SetFloat(hashHorizontalDot, horizontalDot); controller.animator.SetTrigger(hashHit); hitAudio.PlayRandomClip(); }
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 } }
public void PlayStep() { footstepAudioPlayer.PlayRandomClip(); }
void OnEnable() { player.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); }
public void Hit() //击打 { damageAudioPlayer.PlayRandomClip(); //将伤害音效打开 m_EnemyController.animator.SetTrigger(hashHitParam); //将击打动画打开 m_CoreMaterial.SetColor("_Color2", Color.red); //把核心材质颜色设置为红色 }
public void Die() //死亡 { deathAudioPlayer.PlayRandomClip(); //播放死亡时的音效 m_EnemyController.animator.SetTrigger(hashDeathParam); //开启死亡动画 }
public void PlayStep() //开始走动 { footstepAudioPlayer.PlayRandomClip(); //脚步声开启 }