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