Exemple #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);
        }
Exemple #2
0
        public bool SetOnFinishListener(int id, Action <int> l)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

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

            unit.SetOnFinishListener(l);
            return(true);
        }
Exemple #3
0
        public bool SetPitch(int id, float pitch)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

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

            unit.SetPitch(pitch);
            return(true);
        }
Exemple #4
0
        public bool SetVolume(int id, float volume)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

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

            unit.SetVolume(volume);
            return(true);
        }
Exemple #5
0
        public bool Stop(int id)
        {
            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

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

            unit.Stop();
            return(true);
        }
Exemple #6
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);
            }
        }
Exemple #7
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);
            }
        }