void OnCollisionEnter(Collision coll) { if (Time.time - m_LastPlaySfxTime < m_SfxIntarvalTime) { return; } if (coll.relativeVelocity.sqrMagnitude < m_HitSfxVelThreshold) { return; } if (m_Rigidbody.velocity.sqrMagnitude < m_HitSfxVelThreshold) { return; } Rigidbody rb = coll.gameObject.GetComponent <Rigidbody>(); if (rb == null) { PlaySfx(coll.gameObject.tag); } else if (m_Rigidbody.velocity.sqrMagnitude >= rb.velocity.sqrMagnitude) { SfxManager.Play(SfxName.Hit); } else { return; } m_LastPlaySfxTime = Time.time; }
internal static void Play([NotNull] this SfxManager sfx, [CanBeNull] string fileName, [NotNull, ItemNotNull] IEnumerable <IAudioFormat> formats) { if (fileName == null) { return; } var format = GetFormatForFile(formats, fileName); if (format != null) { sfx.Play(fileName, format); } }
void PlaySfx(string tag) { switch (tag) { case "NonSfx": break; case "Spring": SfxManager.Play(SfxName.Spring); break; default: SfxManager.Play(SfxName.Hit); break; } }
void LaunchBall(float force) { if (IsBallInCamber() == false) { return; } if (m_ChamberBall == null) { return; } m_ChamberBall.transform.position = m_MuzzleT.position; Rigidbody rb = m_ChamberBall.GetComponent <Rigidbody>(); rb.AddForce(m_MuzzleT.forward * force); m_ChamberBall.ballState = Ball.BallState.InBoard; m_ChamberBall = null; SfxManager.Play(SfxName.Shot); }
public void OnHolein() { BallLoader.AddBall(m_AddingBallCount); SfxManager.Play(SfxName.Holein); OpenAnotherGateIfNeeded(); }