//TODO: inherit this for each type of character to differentiate sound sets public void Speak(SoundBank.GoblinSound soundtype, bool overridePlaying = false) { if (InArea.Visible() && Voice && Voice.isActiveAndEnabled && (overridePlaying || !Voice.isPlaying)) { Voice.PlayOneShot(SoundBank.GetSound(soundtype)); } }
IEnumerator PlayQueue() { while (true) { bool areThereClipsHighPriority = false; foreach (string clip in audioQueue.ToArray()) { if (clip.Substring(0, 1) != "[") { if (clip.Substring(0, 1) != "*") { areThereClipsHighPriority = true; break; } } } if (audioQueue.Count != 0 && (!source.isPlaying || (lowPriority && areThereClipsHighPriority))) { if (source.isPlaying) { source.Stop(); } string nextSound = audioQueue.Dequeue(); switch (nextSound) { case "[front]": Position = AudioPosition.Front; break; case "[left]": Position = AudioPosition.Left;; break; case "[right]": Position = AudioPosition.Right; break; case "[center]": Position = AudioPosition.Center; break; case "[space]": yield return(new WaitForSeconds(0.1f)); break; default: lowPriority = (nextSound.Substring(0, 1) == "*"); // if the clip is low priority any other not low-priority clip can interrupt it automatically if (lowPriority) { nextSound = nextSound.Substring(1); } source.clip = SoundBank.GetSound(nextSound); if (source.clip != null) { source.Play(); //if (!lowPriority) { // yield return new WaitForSeconds(source.clip.length); //} } break; } } yield return(null); } }
public static void ChangeBackground(SoundBank.Background type) { var f = SoundBank.GetSound(type); if (Instance.BackgroundAudioSource.clip != f) { Instance.BackgroundAudioSource.clip = f; Instance.BackgroundAudioSource.Play(); } }
//TODO: create fade public static void ChangeMusic(SoundBank.Music type) { if (type == SoundBank.Music.NoMusic) { Instance.MusicAudioSource.clip = null; Instance.MusicAudioSource.Stop(); } var f = SoundBank.GetSound(type); if (Instance.MusicAudioSource.clip != f) { Instance.MusicAudioSource.clip = f; Instance.MusicAudioSource.Play(); } }
public static void PlayStinger(SoundBank.Stinger type) { Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(type)); }
public static void PlayGameLoss() { Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.Stinger.GameLoss)); }
public static void PlayGameStart() { Instance.StingerAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.Stinger.GameStart)); }
public static void PlayMenuPopup() { Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.PopUpOption)); }
public static void PlayEvent() { Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.Event)); }
public static void PlayLevelup() { Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.LevelUp)); }
public void PlayMapCLick() { UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.MapClick)); }
public void PlayButtonClick() { UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.ButtonClick)); }
public static void PlayShopBell() { Instance.FxAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.FXSound.DoorBell)); }