//播放背景音 public void PlayBGM() { GameModel gm = MVC.GetModle <GameModel>(); m_Bg.UnPause(); gm.IsBgmPlay = true; }
//暂停背景音 public void PauseBGM() { GameModel gm = MVC.GetModle <GameModel>(); m_Bg.Pause(); gm.IsBgmPlay = false; }
//切换播放背景音 public void PlayBG(string clipName) { GameModel gm = MVC.GetModle <GameModel>(); if (!gm.IsBgmPlay) { return; } string oldName; if (m_Bg.clip == null) { oldName = ""; } else { oldName = m_Bg.clip.name; } if (oldName != clipName) { AudioClip clip = null; if (!m_BgClips.ContainsKey(clipName)) { string path = ResourcesSoundPath + "/" + clipName; clip = Resources.Load <AudioClip>(path); m_BgClips.Add(clipName, clip); } clip = m_BgClips[clipName]; if (clip != null) { m_Bg.clip = clip; m_Bg.Play(); } } PlayBGM(); }
protected override void Awake() { base.Awake(); anim = GetComponentInChildren <Animation>(); gm = MVC.GetModle <GameModel>(); }
//获取Model protected T GetModel <T>() where T : Model { return(MVC.GetModle <T>() as T); }
protected override void Awake() { base.Awake(); gm = MVC.GetModle <GameModel>(); }