Пример #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);
        }
Пример #2
0
 public Playing(PBGMPlayer bgmPlayer) : base(bgmPlayer)
 {
     if (bgmPlayer.source.isPlaying == false)
     {
         bgmPlayer.source.volume = bgmPlayer.baseVolume;
         bgmPlayer.source.Play();
     }
 }
Пример #3
0
 public void clearBGM()
 {
     stopBGM(0.0f);
     if (curBGMPlayer != null)
     {
         curBGMPlayer.destory();
         curBGMPlayer = null;
     }
     if (fadeOutBGMPlayer != null)
     {
         fadeOutBGMPlayer.destory();
         fadeOutBGMPlayer = null;
     }
     foreach (KeyValuePair <string, AudioClipInfo> pair in bgmClips)
     {
         //GameObject.Destroy( pair.Value.clip );
         Resources.UnloadAsset(pair.Value.clip);
     }
     bgmClips.Clear();
 }
Пример #4
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 );
        }
Пример #5
0
 public void clearBGM()
 {
     stopBGM(0.0f);
     if(curBGMPlayer!=null) {
         curBGMPlayer.destory();
         curBGMPlayer = null;
     }
     if(fadeOutBGMPlayer!=null) {
         fadeOutBGMPlayer.destory();
         fadeOutBGMPlayer = null;
     }
     foreach(KeyValuePair<string, AudioClipInfo> pair in bgmClips) {
         //GameObject.Destroy( pair.Value.clip );
         Resources.UnloadAsset(pair.Value.clip);
     }
     bgmClips.Clear();
 }
Пример #6
0
 public Wait( PBGMPlayer bgmPlayer )
     : base(bgmPlayer)
 {
 }
Пример #7
0
 public State( PBGMPlayer bgmPlayer )
 {
     this.bgmPlayer = bgmPlayer;
 }
Пример #8
0
 public Playing( PBGMPlayer bgmPlayer )
     : base(bgmPlayer)
 {
     if ( bgmPlayer.source.isPlaying == false ) {
         bgmPlayer.source.volume = bgmPlayer.baseVolume;
         bgmPlayer.source.Play();
     }
 }
Пример #9
0
 public Pause( PBGMPlayer bgmPlayer, State preState )
     : base(bgmPlayer)
 {
     this.preState = preState;
     bgmPlayer.source.Pause();
 }
Пример #10
0
 public FadeOut( PBGMPlayer bgmPlayer )
     : base(bgmPlayer)
 {
     initVolume = bgmPlayer.source.volume;
     bgmPlayer.isFinishFadeOut = false;
 }
Пример #11
0
 public FadeIn( PBGMPlayer bgmPlayer )
     : base(bgmPlayer)
 {
     bgmPlayer.source.Play();
     bgmPlayer.source.volume = 0.0f;
 }
Пример #12
0
 public FadeOut(PBGMPlayer bgmPlayer) : base(bgmPlayer)
 {
     initVolume = bgmPlayer.source.volume;
     bgmPlayer.isFinishFadeOut = false;
 }
Пример #13
0
 public Pause(PBGMPlayer bgmPlayer, State preState) : base(bgmPlayer)
 {
     this.preState = preState;
     bgmPlayer.source.Pause();
 }
Пример #14
0
 public FadeIn(PBGMPlayer bgmPlayer) : base(bgmPlayer)
 {
     bgmPlayer.source.Play();
     bgmPlayer.source.volume = 0.0f;
 }
Пример #15
0
 public Wait(PBGMPlayer bgmPlayer) : base(bgmPlayer)
 {
 }
Пример #16
0
 public State(PBGMPlayer bgmPlayer)
 {
     this.bgmPlayer = bgmPlayer;
 }