예제 #1
0
        public void SetTrack(string resourceName,
                             bool fadeTracks = true)
        {
            RefreshMusicVolumeFromGameSettings();

            bool hasStartingClip = AudioStorage.GetMusicClip(resourceName, true) != null;

            ResetSourceSettings();

            if (fadeTracks)
            {
                TryEndCurrentCoroutine();

                currentCoroutine = StartCoroutine(FadeTracks(resourceName, musicFadeTime, hasStartingClip));
            }
            else
            {
                if (hasStartingClip)
                {
                    AudioSource.loop = false;
                    AudioSource.clip = AudioStorage.GetMusicClip(resourceName, true);
                    AudioSource.Play();
                    SetNextClip(AudioStorage.GetMusicClip(resourceName, false));
                }
                else
                {
                    AudioSource.loop = true;
                    AudioSource.clip = AudioStorage.GetMusicClip(resourceName, false);
                    AudioSource.Play();
                }
            }
        }
예제 #2
0
        private void Start()
        {
            initiallyLooping = AudioSource.loop;
            SetVolume(GameSettings.singleton.musicVolume);

            AudioStorage.TryLoadAll();
        }
예제 #3
0
        private IEnumerator FadeTracks(string resourceName,
                                       float totalFadeTime,
                                       bool hasStartingClip)
        {
            float singleFadeTime = totalFadeTime / 2;
            float startVolume    = AudioSource.volume;

            yield return(StartCoroutine(FadeVolume(startVolume, 0, singleFadeTime)));

            #region Set New Track

            if (hasStartingClip)
            {
                AudioSource.loop = false;
                AudioSource.clip = AudioStorage.GetMusicClip(resourceName, true);
                AudioSource.Play();
            }
            else
            {
                AudioSource.loop = true;
                AudioSource.clip = AudioStorage.GetMusicClip(resourceName, false);
                AudioSource.Play();
            }

            #endregion

            yield return(StartCoroutine(FadeVolume(0, startVolume, singleFadeTime)));

            if (hasStartingClip)
            {
                SetNextClip(AudioStorage.GetMusicClip(resourceName, false));
            }
        }
예제 #4
0
        public void PlaySound(string resourceName,
                              Action playCompleteAction = null)
        {
            AudioClip clip = AudioStorage.GetFXClip(resourceName);

            if (clip == null)
            {
                Debug.LogWarning("Unable to find sound clip - " + resourceName);
                return;
            }
            else
            {
                GameObject fxSource = Instantiate(soundFXSourcePrefab);
                fxSource.GetComponent <SoundFXSourceController>().PlayClip(clip, playCompleteAction);
            }
        }
예제 #5
0
 public void PlayPokemonCry(int speciesId,
                            Action playCompleteAction = null)
 => PlaySound(AudioStorage.GetPokemonCryClipName(speciesId), playCompleteAction);
예제 #6
0
 private void Start()
 {
     AudioStorage.TryLoadAll();
 }