Ejemplo n.º 1
0
        public IAudioSource PlayMusic(Music newMusic)
        {
            // Debug.Log("PlayMusic " + newMusic);
            if (currentMusic != newMusic)
            {
                currentMusic = newMusic;
                musicGroup.Stop();
                customMusic = null;
                var musicClip = GetAudioClip(currentMusic);

                if (currentMusic == Music.Silence || musicClip == null)
                {
                    StopMusic();
                }
                else
                {
                    if (musicEnabled)
                    {
                        var source = musicGroup.Play(musicClip, 1, 1, true);
                        return(new AudioSourceWrapper(source, musicGroup, this));
                    }
                    else
                    {
                        musicGroup.Stop();
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// default values play Letter Phoneme
        /// </summary>
        /// <returns>The letter AudioClip</returns>
        /// <param name="data">Letter Data</param>
        /// <param name="exclusive">stops other letters?</param>
        /// <param name="soundType">Phoneme or Name?</param>
        public IAudioSource PlayLetter(LetterData data, bool exclusive = true, LetterDataSoundType soundType = LetterDataSoundType.Phoneme)
        {
            if (exclusive)
            {
                StopVocabularyGroup();
            }

            AudioClip clip = GetAudioClip(data, soundType);

            return(new AudioSourceWrapper(vocabularyGroup.Play(clip), vocabularyGroup, this));
        }
Ejemplo n.º 3
0
        public IAudioSource PlayLearningBlock(string AudioFile, bool clearPreviousCallback = false)
        {
            if (clearPreviousCallback)
            {
                dialogueEndedCallbacks.Clear();
            }

            if (!string.IsNullOrEmpty(AudioFile))
            {
                AudioClip clip = GetLearningBlockAudioClip(AudioFile);
                return(new AudioSourceWrapper(dialogueGroup.Play(clip), dialogueGroup, this));
            }
            return(null);
        }
Ejemplo 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);
        }
Ejemplo n.º 5
0
        public IAudioSource PlaySound(Sfx sfx)
        {
            AudioClip clip = AudioManager.I.GetAudioClip(sfx);

            if (sfxGroup == null)
            {
                sfxGroup            = DeAudioManager.GetAudioGroup(DeAudioGroupId.FX);
                sfxGroup.mixerGroup = AudioManager.I.sfxGroup;
            }

            var source = sfxGroup.Play(clip);

            return(new SampleAudioSource(source, sfxGroup, this));
        }
Ejemplo n.º 6
0
        public IAudioSource PlayMusic(AudioClip clip)
        {
            StopMusic();

            if (musicGroup == null)
            {
                musicGroup            = DeAudioManager.GetAudioGroup(DeAudioGroupId.Music);
                musicGroup.mixerGroup = AudioManager.I.musicGroup;
            }

            var source = musicGroup.Play(clip);

            return(new SampleAudioSource(source, musicGroup, this));
        }
        public void Play()
        {
            if (paused && source != null)
            {
                source.Resume();
            }
            else
            {
                paused = false;

                source        = group.Play(clip);
                source.locked = true;

                source.pitch  = pitch;
                source.volume = volume;
                source.loop   = loop;
                manager.OnAudioStarted(this);
            }
        }
Ejemplo n.º 8
0
        public IAudioSource PlayLetterData(ILivingLetterData id, bool stopAllLetters = false)
        {
            AudioClip clip = AudioManager.I.GetAudioClip(id);

            if (wordsLettersGroup == null)
            {
                wordsLettersGroup            = DeAudioManager.GetAudioGroup(DeAudioGroupId.Custom0);
                wordsLettersGroup.mixerGroup = AudioManager.I.lettersGroup;
            }

            if (stopAllLetters)
            {
                wordsLettersGroup.Stop();
            }

            var source = wordsLettersGroup.Play(clip);

            return(new SampleAudioSource(source, wordsLettersGroup, this));
        }