Exemple #1
0
 //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);
        }
    }
Exemple #3
0
    public static void ChangeBackground(SoundBank.Background type)
    {
        var f = SoundBank.GetSound(type);


        if (Instance.BackgroundAudioSource.clip != f)
        {
            Instance.BackgroundAudioSource.clip = f;
            Instance.BackgroundAudioSource.Play();
        }
    }
Exemple #4
0
    //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();
        }
    }
Exemple #5
0
 public static void PlayStinger(SoundBank.Stinger type)
 {
     Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(type));
 }
Exemple #6
0
 public static void PlayGameLoss()
 {
     Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.Stinger.GameLoss));
 }
Exemple #7
0
 public static void PlayGameStart()
 {
     Instance.StingerAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.Stinger.GameStart));
 }
Exemple #8
0
 public static void PlayMenuPopup()
 {
     Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.PopUpOption));
 }
Exemple #9
0
 public static void PlayEvent()
 {
     Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.Event));
 }
Exemple #10
0
 public static void PlayLevelup()
 {
     Instance.UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.LevelUp));
 }
Exemple #11
0
 public void PlayMapCLick()
 {
     UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.MapClick));
 }
Exemple #12
0
 public void PlayButtonClick()
 {
     UiAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.UiSound.ButtonClick));
 }
Exemple #13
0
 public static void PlayShopBell()
 {
     Instance.FxAudioSource.PlayOneShot(SoundBank.GetSound(SoundBank.FXSound.DoorBell));
 }