예제 #1
0
        public void PlayBGM(string name, float volume)
        {
            if (!this.CanPlayBackSound())
            {
                return;
            }
            string audioClipPath = this.GetAudioClipPath(name, 0);

            if (this.bgm != null && this.bgm.path != audioClipPath)
            {
                this.bgm.Destory();
                this.bgm = null;
            }
            if (this.bgm == null)
            {
                this.bgm = new SoundManager.AudioData(audioClipPath, SoundManager.SoundType.BGM, true, this.SoundParent.transform, Vector3.zero, 128, 1f, 1f, (volume <= 1f) ? volume : 1f);
                base.StartCoroutine(Util.LoadBGMAudioAsync(this.bgm.go, audioClipPath, "ogg", delegate(AudioClip clip, string str)
                {
                    if (clip != null)
                    {
                        this.bgm.audio.clip   = clip;
                        this.bgm.audio.volume = volume;
                        this.bgm.Play(0f);
                    }
                }));
            }
            else
            {
                this.bgm.audio.volume = volume;
                if (!this.bgm.audio.isPlaying)
                {
                    this.bgm.Play(0f);
                }
            }
        }
예제 #2
0
        private void LoadAudioClip(string name, int type, float volume, Vector3 position, float delay, string extension = "ogg", int priority = 128, bool loop = false, float minPitch = 0f, float maxPitch = 3f)
        {
            string path = this.GetAudioClipPath(name, type);

            if (this.sounds[path] != null)
            {
                SoundManager.AudioData audioData = this.sounds[path];
                if (audioData != null && audioData.audio != null)
                {
                    audioData.audio.volume          = volume;
                    audioData.go.transform.position = position;
                    audioData.Play(delay);
                }
                else
                {
                    this.sounds.RemoveKey(path);
                }
            }
            else
            {
                SoundManager.AudioData data = new SoundManager.AudioData(path, (SoundManager.SoundType)type, loop, this.SoundParent.transform, position, priority, minPitch, maxPitch, volume);
                base.StartCoroutine(Util.LoadAudioClipAsync(data.go, path, extension, delegate(AudioClip clip, string str)
                {
                    if (clip != null)
                    {
                        data.audio.clip   = clip;
                        data.audio.volume = volume;
                        data.Play(delay);
                        this.sounds.Put(path, data, 1);
                    }
                }));
            }
        }
예제 #3
0
 public void StopBGM()
 {
     if (this.bgm != null)
     {
         this.bgm.Stop();
         this.bgm.Destory();
         this.bgm = null;
     }
 }
예제 #4
0
        public void StopEffectSound(string name, int type)
        {
            string audioClipPath = this.GetAudioClipPath(name, type);

            if (this.sounds.ContainsKey(audioClipPath))
            {
                SoundManager.AudioData audioData = this.sounds[audioClipPath];
                audioData.Stop();
            }
        }