Exemplo n.º 1
0
 /// <summary>
 /// Used by AudioSourceWrappers.
 /// </summary>
 /// <param name="source"></param>
 public void OnAudioStarted(AudioSourceWrapper source)
 {
     if (!playingAudio.Contains(source))
     {
         playingAudio.Add(source);
     }
 }
Exemplo n.º 2
0
        public IAudioSource PlayLearningBlock(string AudioFile, System.Action callback, bool clearPreviousCallback = false)
        {
            if (clearPreviousCallback)
            {
                dialogueEndedCallbacks.Clear();
            }

            if (!string.IsNullOrEmpty(AudioFile))
            {
                AudioClip clip    = GetLearningBlockAudioClip(AudioFile);
                var       wrapper = new AudioSourceWrapper(dialogueGroup.Play(clip), dialogueGroup, this);
                if (callback != null)
                {
                    dialogueEndedCallbacks[wrapper] = callback;
                }
                return(wrapper);
            }
            else
            {
                if (callback != null)
                {
                    callback();
                }
            }
            return(null);
        }
Exemplo n.º 3
0
        public IAudioSource PlayDialogue(LocalizationData data, System.Action callback, bool clearPreviousCallback = false)
        {
            if (clearPreviousCallback)
            {
                dialogueEndedCallbacks.Clear();
            }

            if (!string.IsNullOrEmpty(LocalizationManager.GetLocalizedAudioFileName(data.Id)))
            {
                AudioClip clip    = GetAudioClip(data);
                var       wrapper = new AudioSourceWrapper(dialogueGroup.Play(clip), dialogueGroup, this);
                if (callback != null)
                {
                    dialogueEndedCallbacks[wrapper] = callback;
                }
                return(wrapper);
            }
            else
            {
                if (callback != null)
                {
                    callback();
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Play a soundFX
        /// </summary>
        /// <param name="sfx">Sfx.</param>
        public IAudioSource PlaySound(Sfx sfx)
        {
            AudioClip clip   = GetAudioClip(sfx);
            var       source = new AudioSourceWrapper(sfxGroup.Play(clip), sfxGroup, this);
            var       conf   = GetConfiguration(sfx);

            if (conf != null)
            {
                source.Pitch  = 1 + ((UnityEngine.Random.value - 0.5f) * conf.randomPitchOffset) * 2;
                source.Volume = conf.volume;
            }

            return(source);
        }