Esempio n. 1
0
    //播放背景音
    public void PlayBGM()
    {
        GameModel gm = MVC.GetModle <GameModel>();

        m_Bg.UnPause();
        gm.IsBgmPlay = true;
    }
Esempio n. 2
0
    //暂停背景音
    public void PauseBGM()
    {
        GameModel gm = MVC.GetModle <GameModel>();

        m_Bg.Pause();
        gm.IsBgmPlay = false;
    }
Esempio n. 3
0
    //切换播放背景音
    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();
    }
Esempio n. 4
0
 protected override void Awake()
 {
     base.Awake();
     anim = GetComponentInChildren <Animation>();
     gm   = MVC.GetModle <GameModel>();
 }
Esempio n. 5
0
 //获取Model
 protected T GetModel <T>() where T : Model
 {
     return(MVC.GetModle <T>() as T);
 }
Esempio n. 6
0
 protected override void Awake()
 {
     base.Awake();
     gm = MVC.GetModle <GameModel>();
 }