using UnityEngine; using System.Collections; public enum BoomType : int { None = 0, /// /// 爆炸类型 /// Expolsion = 1, /// /// 变形类型 /// Twist = 2 } /// /// 声音控制类 /// public class AudioManager { /// /// 单例 /// private static AudioManager instance; private static AudioSource audio; public static AudioManager Instance { get { if (null == instance || null == audio) { instance = new AudioManager(); GameObject obj = new GameObject(); obj.hideFlags = HideFlags.HideAndDontSave; audio = obj.AddComponent(); } return instance; } } /// /// 播放声音 /// /// 音源 public void Play(BoomType type) { switch (type) { case BoomType.Expolsion: var exp = Resources.Load("Audio/explosion"); audio.clip = exp; break; case BoomType.Twist: var twist = Resources.Load("Audio/twist"); audio.clip = twist; break; default: break; } audio.Play(); } }