Esempio n. 1
0
        public int PlaySoundSingleton(string name, bool replace)
        {
            if (m_SingletonSoundMap.ContainsKey(name))
            {
                if (replace)
                {
                    m_SingletonSoundMap[name].Stop();
                    m_SingletonSoundMap.Remove(name);
                }
                else
                {
                    return(-1);
                }
            }

            int id = PlaySound(name, false);

            if (id < 0)
            {
                return(id);
            }

            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

            unit.SetOnStopListener(OnSingleAudioFinish);
            m_SingletonSoundMap.Add(name, unit);
            return(unit.id);
        }
Esempio n. 2
0
        public override void OnSingletonInit()
        {
            ObjectPool <AudioUnit> .S.Init(m_MaxSoundCount, 1);

            m_MainUnit           = new AudioUnit();
            m_MainUnit.usedCache = false;
        }
Esempio n. 3
0
 private void OnSingleAudioFinish(AudioUnit unit)
 {
     if (m_SingletonSoundMap.ContainsKey(unit.audioName))
     {
         m_SingletonSoundMap.Remove(unit.audioName);
     }
 }
Esempio n. 4
0
 private static void UnRegisterActiveAudioUnit(AudioUnit unit)
 {
     if (s_AudioUnitMap.ContainsKey(unit.id))
     {
         s_AudioUnitMap.Remove(unit.id);
     }
     unit.id = -1;
 }
Esempio n. 5
0
 private void OnAoundPlayFinish(AudioUnit unit)
 {
     m_AudioUnit = null;
     if (m_FinishStep)
     {
         FinishStep();
     }
 }
Esempio n. 6
0
 protected override void OnFinish(bool forceClean)
 {
     if (m_AudioUnit != null)
     {
         m_AudioUnit.Stop();
         m_AudioUnit = null;
     }
 }
Esempio n. 7
0
        public override void OnSingletonInit()
        {
            m_IsSoundEnable = PlayerPrefs.GetInt(SOUND_STATE_RECORD_KEY, 1) > 0;
            m_IsMusicEnable = PlayerPrefs.GetInt(MUSIC_STATE_RECORD_KEY, 1) > 0;

            ObjectPool <AudioUnit> .S.Init(m_MaxCacheSoundCount, 1);

            m_MainUnit           = AudioUnit.Allocate();
            m_MainUnit.usedCache = false;
        }
Esempio n. 8
0
        public bool Stop(int id)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

            if (unit == null)
            {
                return(false);
            }

            unit.Stop();
            return(true);
        }
Esempio n. 9
0
        public bool SetOnFinishListener(int id, Action <int> l)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

            if (unit == null)
            {
                return(false);
            }

            unit.SetOnFinishListener(l);
            return(true);
        }
Esempio n. 10
0
        public bool SetPitch(int id, float pitch)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

            if (unit == null)
            {
                return(false);
            }

            unit.SetPitch(pitch);
            return(true);
        }
Esempio n. 11
0
        public bool SetVolume(int id, float volume)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

            if (unit == null)
            {
                return(false);
            }

            unit.SetVolume(volume);
            return(true);
        }
Esempio n. 12
0
        public int PlaySound(string name, bool loop = false, Action <int> callBack = null, int customEventID = -1)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(-1);
            }

            AudioUnit unit = AudioUnit.Allocate();

            unit.SetAudio(gameObject, name, loop, m_IsSoundEnable);
            unit.SetOnFinishListener(callBack);
            unit.customEventID = customEventID;
            return(unit.id);
        }
Esempio n. 13
0
        public AudioUnit PlaySound(string name, bool loop = false, Action <AudioUnit> callBack = null, int customEventID = -1)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

            AudioUnit unit = ObjectPool <AudioUnit> .S.Allocate();

            unit.SetAudio(gameObject, name, loop);
            unit.SetOnFinishListener(callBack);
            unit.customEventID = customEventID;
            return(unit);
        }
Esempio n. 14
0
        private void OnSingleAudioFinish(int id)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

            if (unit == null)
            {
                Log.e("WTF! Not Impossible.");
                return;
            }

            if (m_SingletonSoundMap.ContainsKey(unit.audioName))
            {
                m_SingletonSoundMap.Remove(unit.audioName);
            }
        }
Esempio n. 15
0
        public AudioUnit PlaySoundSingleton(string name, bool replace)
        {
            if (m_SingletonSoundMap.ContainsKey(name))
            {
                if (replace)
                {
                    m_SingletonSoundMap[name].Stop();
                    m_SingletonSoundMap.Remove(name);
                }
                else
                {
                    return(null);
                }
            }

            AudioUnit unit = PlaySound(name, false, OnSingleAudioFinish);

            m_SingletonSoundMap.Add(name, unit);
            return(unit);
        }
Esempio n. 16
0
        public int PlaySoundShoot(string name)
        {
            if (m_SingletonSoundMap.ContainsKey(name))
            {
                var unit = m_SingletonSoundMap[name];
                unit.PlayShoot();
                return(unit.id);
            }
            else
            {
                int id = PlaySound(name, false);

                if (id < 0)
                {
                    return(id);
                }

                AudioUnit unit = AudioUnit.GetAudioUnitByID(id);
                unit.SetOnStopListener(OnSingleAudioFinish);
                m_SingletonSoundMap.Add(name, unit);
                return(unit.id);
            }
        }
Esempio n. 17
0
 protected override void OnStart()
 {
     m_AudioUnit = AudioMgr.S.PlaySound(m_AudioName, false, OnAoundPlayFinish);
 }
Esempio n. 18
0
 private static void RegisterActiveAudioUnit(AudioUnit unit)
 {
     unit.id = ++s_NextID;
     s_AudioUnitMap.Add(unit.id, unit);
 }
Esempio n. 19
0
            public static AudioUnit Allocate()
            {
                AudioUnit unit = ObjectPool <AudioUnit> .S.Allocate();

                return(unit);
            }