protected void LateUpdate() { if (Trembling && Limping && !m_PlayerHealthSource.IsPlaying) { m_PlayerHealthSource.Play(m_CoughSound, m_CoughVolume); } }
public override void Play(AudioEmitter emitter) { if (clips.Length == 0 || emitter == null) { return; } var clip = clips[Random.Range(0, clips.Length)]; var volume = Random.Range(volumeRange.minValue, volumeRange.maxValue); var pitch = Random.Range(pitchRange.minValue, pitchRange.maxValue); emitter.Play(clip, volume, pitch); }
protected virtual void Update() { // Movement animation m_MotionAnimation.MovementAnimation(m_FPController); // Breath animation m_MotionAnimation.BreathingAnimation(((m_BreathAnimationMode == BreathAnimationMode.EnableWhenAim && m_FPController.IsAiming) || m_BreathAnimationMode == BreathAnimationMode.Unrestricted || m_BreathAnimationMode == BreathAnimationMode.DisableWhenAim && !m_FPController.IsAiming) && Math.Abs(m_HoldBreathDuration) < Mathf.Epsilon ? 1 : 0); if (HoldBreath) { //Hold breath if (InputManager.GetButton(m_RunButton) && m_NextHoldBreathTime < Time.time && m_FPController.IsAiming && !m_FPController.TremorTrauma) { if (Math.Abs(m_HoldBreathDuration) < Mathf.Epsilon) { m_PlayerGenericSource.Play(m_HoldBreath, m_HoldBreathVolume); } m_HoldBreathDuration += Time.deltaTime; if (m_HoldBreathDuration > m_HoldBreath.length) { m_NextHoldBreathTime = Time.time + 3 + m_HoldBreathDuration; m_HoldBreathDuration = 0; m_PlayerGenericSource.Play(m_Exhale, m_HoldBreathVolume); } } //Release the breath else { if (m_HoldBreathDuration > 0) { m_PlayerGenericSource.Stop(); } if (m_HoldBreathDuration > m_HoldBreath.length * 0.7f) { m_NextHoldBreathTime = Time.time + 3 + m_HoldBreathDuration; m_PlayerGenericSource.Play(m_Exhale, m_HoldBreathVolume); } m_HoldBreathDuration = 0; } } // Leaning animations if (!m_MotionAnimation.Lean) { return; } if (m_FPController.State != MotionState.Flying && m_FPController.State != MotionState.Running && m_FPController.State != MotionState.Climbing) { // Lean by holding the button if (GameplayManager.Instance.LeanStyle == ActionMode.Hold) { if (InputManager.GetButton(m_LeanLeft) && !InputManager.GetButton(m_LeanRight)) { LeanDirection = CanLean(Vector3.left) ? -1 : 0; } if (InputManager.GetButton(m_LeanRight) && !InputManager.GetButton(m_LeanLeft)) { LeanDirection = CanLean(Vector3.right) ? 1 : 0; } if (!InputManager.GetButton(m_LeanLeft) && !InputManager.GetButton(m_LeanRight)) { LeanDirection = 0; } m_MotionAnimation.LeanAnimation(LeanDirection); } else { // Lean by tapping the button if (InputManager.GetButtonDown(m_LeanLeft) && LeanDirection != -1) { LeanDirection = LeanDirection == 1 ? 0 : -1; } else if (InputManager.GetButtonDown(m_LeanLeft) && LeanDirection == -1) { LeanDirection = 0; } if (InputManager.GetButtonDown(m_LeanRight) && LeanDirection != 1) { LeanDirection = LeanDirection == -1 ? 0 : 1; } else if (InputManager.GetButtonDown(m_LeanRight) && LeanDirection == 1) { LeanDirection = 0; } if ((LeanDirection == -1 && !CanLean(Vector3.left)) || (LeanDirection == 1 && !CanLean(Vector3.right))) { LeanDirection = 0; } m_MotionAnimation.LeanAnimation(LeanDirection); } } else { LeanDirection = 0; m_MotionAnimation.LeanAnimation(0); } }