Beispiel #1
0
        public void playBGM(string bgmName, float volume = 1.0f, float fadeTime = 0.0f)
        {
            // destory old BGM
            if (fadeOutBGMPlayer != null)
            {
                fadeOutBGMPlayer.destory();
            }

            // change to fade out for current BGM
            if (curBGMPlayer != null)
            {
                curBGMPlayer.stopBGM(fadeTime);
                fadeOutBGMPlayer = curBGMPlayer;
            }

            // play new BGM
            if (bgmClips.ContainsKey(bgmName) == false)
            {
                reserveBGM(bgmName);
                // null BGM
                //curBGMPlayer = new BGMPlayer();
                //return false; // not register
            }

            curBGMPlayer             = new PBGMPlayer(bgmClips[bgmName].resourceName);
            curBGMPlayer.localVolume = volume;
            curBGMPlayer.volume      = bgmVolume;
            curBGMPlayer.playBGM(fadeTime);
        }
Beispiel #2
0
 public void stopBGM(float fadeTime)
 {
     if (curBGMPlayer != null)
     {
         curBGMPlayer.stopBGM(fadeTime);
     }
     if (fadeOutBGMPlayer != null)
     {
         fadeOutBGMPlayer.stopBGM(fadeTime);
     }
 }