public void PlaySFX(SFXProfile sfx, float delayTime) { if (sfx.clip != null) { StartCoroutine(PlaySFXCoroutine(sfx, delayTime)); } }
public void PlayBGM(SFXProfile sfx, float switchTime) { if (sfx.clip != BGMManager.clip && sfx.clip != null) { StartCoroutine(PlayBGMFade(sfx, switchTime)); } }
public void PlayVoiceOver(SFXProfile sfx, float switchTime) { VOManager.Stop(); VOManager.clip = sfx.clip; VOManager.PlayDelayed(switchTime); VOManager.volume = sfx.clipVolume; }
public static void ServerPlay3D(SFXProfile profile, TransformF transform) { SimSet ClientGroup = Sim.FindObject <SimSet>("ClientGroup"); // Play the given sound profile at the given position on every client // The sound will be transmitted as an event, not attached to any object. for (uint i = 0; i < ClientGroup.getCount(); i++) { ClientGroup.getObject(i).As <GameConnectionToClient>().play3D(profile, transform); } }
IEnumerator PlaySFXCoroutine(SFXProfile sfx, float delayTime) { AudioSource go = this.gameObject.AddComponent <AudioSource> (); go.playOnAwake = false; go.Stop(); go.clip = sfx.clip; go.volume = sfx.clipVolume; go.PlayDelayed(delayTime); yield return(new WaitForSeconds(sfx.clip.length + delayTime)); Destroy(go); }
IEnumerator PlayBGMFade(SFXProfile sfx, float fadeDelay) { float currVolume = BGMManager.volume; for (float f = 0.0f; f < fadeDelay / 2.0f; f += Time.deltaTime) { BGMManager.volume = Mathf.Clamp01((1.0f - (f / (fadeDelay / 2.0f))) * currVolume); yield return(null); } BGMManager.volume = 0.0f; BGMManager.Stop(); BGMManager.clip = sfx.clip; BGMManager.PlayDelayed(0.0f); for (float f = 0.0f; f < fadeDelay / 2.0f; f += Time.deltaTime) { BGMManager.volume = Mathf.Clamp01(f / (fadeDelay / 2.0f) * sfx.clipVolume); yield return(null); } BGMManager.volume = sfx.clipVolume; }