Beispiel #1
0
        /// <summary>
        /// 在指定位置播放音效
        /// </summary>
        /// <param name="att">声音属性设置</param>
        /// <param name="pos">坐标</param>
        public static AudioHandler PlaySoundAtLocation(AudioAttribute att, Vector3 pos)
        {
            TagHandle(att);
            AudioHandler handler = InstantiateAudioObject(pos);

            AudioEventHandle(att, handler);
            handler.AddQueue(att);
            handler.Play();
            return(handler);
        }
Beispiel #2
0
        /// <summary>
        /// 附加BGM到摄像头
        /// </summary>
        /// <param name="att"></param>
        public static AudioHandler AttackBGMtoCamera(AudioAttribute att)
        {
            att      = TagHandle(att);
            att.loop = true;
            AudioHandler handler = Camera.main.gameObject.AddComponent <AudioHandler>();

            AudioEventHandle(att, handler);
            handler.AddQueue(att);
            handler.Play();
            return(handler);
        }
Beispiel #3
0
 /// <summary>
 /// Event统一处理
 /// </summary>
 /// <param name="att"></param>
 /// <param name="handler"></param>
 private static void AudioEventHandle(AudioAttribute att, AudioHandler handler)
 {
     if (att.OnStartPlay != null)
     {
         handler.OnStartPlay += att.OnStartPlay;
     }
     if (att.OnPausePlay != null)
     {
         handler.OnPausePlay += att.OnPausePlay;
     }
     if (att.OnStopPlay != null)
     {
         handler.OnStopPlay += att.OnStopPlay;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Tag统一处理
 /// </summary>
 /// <param name="att"></param>
 /// <returns></returns>
 private static AudioAttribute TagHandle(AudioAttribute att)
 {
     if (att.tag != string.Empty)
     {
         if (dic_tags.ContainsKey(att.tag))
         {
             att.volume = dic_tags[att.tag];
         }
         else
         {
             dic_tags.Add(att.tag, att.volume);
             Debug.LogWarningFormat("新注册Tag:{0},音量:{1}", att.tag, att.volume);
         }
     }
     return(att);
 }
Beispiel #5
0
 public static AudioHandler PlaySound(AudioAttribute att)
 {
     return(PlaySoundAtLocation(att, Camera.main.transform.position));
 }