Exemplo n.º 1
0
        public AFSound Add(string name, AudioClip audioClip, Transform emitter = null, float volume = 1.0f, float pitch = 1.0f, bool loop = false)
        {
            AFSound audio;

            if (name != null && name.Length > 0)
            {
                if (m_audios.ContainsKey(name))
                {
                    audio = m_audios[name];
                    UnityEngine.Debug.LogWarning("The audio was not added, because the name already in list of audios");
                }
                else
                {
                    audio          = new AFSound(name, audioClip, emitter, volume, pitch, loop);
                    m_audios[name] = audio;

                    OnAudioAdd.Dispatch(audio);
                }
            }
            else
            {
                throw new Exception("The name of sound was not valid");
            }

            audiosInList++;

            return(audio);
        }
Exemplo n.º 2
0
        private AudioSource Pause(AFSound sound)
        {
            if (sound.IsNull())
            {
                throw new Exception("Audio not exists");
            }

            OnAudioPause.Dispatch(sound);
            return(sound.Pause());
        }
Exemplo n.º 3
0
        private AudioSource Pause(AFSound sound)
        {
            if (!m_audios.ContainsKey(name))
            {
                throw new Exception("Audio not exists");
            }

            OnAudioPause.Dispatch(sound);
            return(sound.Pause());
        }
Exemplo n.º 4
0
        public AFSound Add(string name, string path, Transform emitter = null, float volume = 1.0f, float pitch = 1.0f, bool loop = false, bool playOncePertime = true)
        {
            if (Exists(name))
            {
                AFDebug.LogWarning("Audio already registered: " + name);
                return(m_audios[name]);
            }

            return(Put(AFSound.Create(path, name, emitter, volume, pitch, loop, playOncePertime)));
        }
Exemplo n.º 5
0
        public AFSound Add(AFSound sound)
        {
            if (Exists(sound.GetName()))
            {
                AFDebug.LogWarning("Audio already registered: " + name);
                return(m_audios[sound.GetName()]);
            }

            return(Put(sound));
        }
Exemplo n.º 6
0
        internal AFSound Put(AFSound sound)
        {
            m_audios[sound.GetName()] = sound;
            OnAudioAdd.Dispatch(sound);
            audiosInList++;

            sound.gameObject.transform.SetParent(this.gameObject.transform);

            return(sound);
        }
Exemplo n.º 7
0
        public AudioSource Play(string name)
        {
            if (!m_audios.ContainsKey(name))
            {
                throw new Exception("Audio not exists");
            }

            AFSound audio = m_audios[name];

            OnAudioPlay.Dispatch(audio);

            return(audio.Play());
        }
Exemplo n.º 8
0
        public static AFSound Create(
            string name,
            AudioClip audio,
            Transform emitter    = null,
            float volume         = 1.0f,
            float pitch          = 1.0f,
            bool loop            = false,
            bool playOncePertime = true)
        {
            AFSound L_sound = AFObject.Create <AFSound>(name);

            L_sound.Initialize(name, audio, emitter, volume, pitch, loop, playOncePertime);
            return(L_sound);
        }
Exemplo n.º 9
0
        internal AFSound Put(AFSound sound)
        {
            if (Exists(sound.GetName()))
            {
                AFDebug.LogWarning("Audio already registered: " + sound.GetName());
                return(m_audios[sound.GetName()]);
            }

            m_audios[sound.GetName()] = sound;
            OnAudioAdd.Dispatch(sound);
            audiosInList++;

            sound.gameObject.transform.SetParent(this.gameObject.transform);

            return(sound);
        }
Exemplo n.º 10
0
        public static AFSound Create(
            string path,
            string name          = "",
            Transform emitter    = null,
            float volume         = 1.0f,
            float pitch          = 1.0f,
            bool loop            = false,
            bool playOncePertime = true)
        {
            if (name.Equals(""))
            {
                name = path;
            }

            AFSound   L_sound     = AFObject.Create <AFSound>(name);
            AudioClip L_audioClip = AFAssetManager.Instance.Load <AudioClip>(path);

            L_sound.Initialize(name, L_audioClip, emitter, volume, pitch, loop, playOncePertime);
            return(L_sound);
        }
Exemplo n.º 11
0
 public void Add(AFSound audio)
 {
     //TODO: Add audio to a list and verify if it is valid
 }
Exemplo n.º 12
0
 public void Add(AFSound sound)
 {
     m_audios[sound.GetName()] = sound;
 }
Exemplo n.º 13
0
 public AFSound Add(string name, string path, Transform emitter = null, float volume = 1.0f, float pitch = 1.0f, bool loop = false, bool playOncePertime = true)
 {
     return(Put(AFSound.Create(path, name, emitter, volume, pitch, loop, playOncePertime)));
 }
Exemplo n.º 14
0
 public AFSound Add(AFSound sound)
 {
     return(Put(sound));
 }
Exemplo n.º 15
0
 public AudioSource Stop(AFSound sound)
 {
     OnAudioStop.Dispatch(sound);
     return(sound.Stop());
 }
Exemplo n.º 16
0
 public void Remove(AFSound audio)
 {
     audio.Destroy();
     m_audios.Remove(audio.GetName());
     audiosInList--;
 }