예제 #1
0
 private void AddAudio(int audioGuid, AudioActionBase action)
 {
     if (m_AudioDic != null && action != null)
     {
         m_AudioDic[audioGuid] = action;
     }
 }
예제 #2
0
 private void EnqueueAudio(AudioActionBase action)
 {
     if (action != null)
     {
         m_AudioQueue.Enqueue(action);
     }
 }
예제 #3
0
        private AudioActionBase GetAduio(int audioGuid)
        {
            AudioActionBase action = null;

            if (m_AudioDic != null && m_AudioDic.ContainsKey(audioGuid))
            {
                action = m_AudioDic[audioGuid];
            }
            return(action);
        }
예제 #4
0
        private AudioActionBase PeekAudio()
        {
            AudioActionBase action = null;

            if (m_AudioQueue != null && m_AudioQueue.Count > 0)
            {
                action = m_AudioQueue.Peek();
            }
            return(action);
        }
예제 #5
0
 private void OnEndCall(int audioGuid)
 {
     m_NowPlayAudio = null;
     MsgDispatcher.SendMessage(GlobalEventType.AudioPlayEnd, audioGuid);
     if (m_WaitPlayAudio != null)
     {
         m_NowPlayAudio = this.m_WaitPlayAudio;
         this.m_NowPlayAudio.Play();
         this.m_WaitPlayAudio = null;
     }
 }
예제 #6
0
        public void PlayOneAudio(int audioId)
        {
            AudioActionType ptype       = base.getAudioType(audioId);
            AudioActionBase audioAction = null;
            Action <int>    startCall   = delegate(int aid)
            {
                OnStartCall(aid, audioAction);
            };

            audioAction = base.NewAudio(ptype, audioId, startCall, OnEndCall);
            audioAction.Play();
        }
예제 #7
0
 public override void Pause(bool isPause)
 {
     if (m_AudioDic != null && m_AudioDic.Count > 0)
     {
         foreach (KeyValuePair <int, AudioActionBase> pair in m_AudioDic)
         {
             AudioActionBase action = pair.Value;
             if (action != null && action.GetAudioSource() != null)
             {
                 action.Pause(isPause);
             }
         }
     }
 }
예제 #8
0
 private void OnEndCall(int audioGuid)
 {
     if (!m_IsStop)
     {
         DequeueAudio();
     }
     MsgDispatcher.SendMessage(GlobalEventType.AudioPlayEnd, audioGuid);
     if (!m_IsStop)
     {
         AudioActionBase nextAction = PeekAudio();
         if (nextAction != null)
         {
             nextAction.Play();
         }
     }
 }
예제 #9
0
 public override void Stop(int stopType = 0)
 {
     if (m_AudioQueue != null)
     {
         m_IsStop = true;
         AudioActionBase action = null;
         while ((action = DequeueAudio()) != null)
         {
             if (action != null && action.GetAudioSource() != null)
             {
                 action.Stop();
             }
         }
     }
     this.Destroy();
 }
예제 #10
0
        public void PlayOneAudio(int audioId)
        {
            AudioActionType ptype = base.getAudioType(audioId);

            if (ptype == AudioActionType.Loop)
            {
                ptype = AudioActionType.Once;
            }

            AudioActionBase audioAction = null;

            audioAction = base.NewAudio(ptype, audioId, OnStartCall, OnEndCall);
            if (IsCanPlay())
            {
                audioAction.Play();
            }
            EnqueueAudio(audioAction);
        }
예제 #11
0
        protected AudioActionBase NewAudio(AudioActionType ptype, int audioId, Action <int> startCall, Action <int> endCall)
        {
            AudioActionBase action = null;

            if (ptype == AudioActionType.Once)
            {
                action = new AudioOnceAction(this.s_AudioRoot, audioId, startCall, endCall);
            }
            else if (ptype == AudioActionType.Loop)
            {
                action = new AudioLoopAction(this.s_AudioRoot, audioId, startCall, endCall);
            }
            else if (ptype == AudioActionType.Fade)
            {
                action = new AudioFadeAction(this.s_AudioRoot, audioId, startCall, endCall);
            }
            else if (ptype == AudioActionType.LoopFade)
            {
                action = new AudioLoopFadeAction(this.s_AudioRoot, audioId, startCall, endCall);
            }
            return(action);
        }
예제 #12
0
        public override void Play(params int[] audioIds)
        {
            int audioId = 0;

            if (audioIds != null && audioIds.Length > 0)
            {
                audioId = audioIds[0];
            }
            AudioActionType ptype       = base.getAudioType(audioId);
            AudioActionBase audioAction = null;

            audioAction = base.NewAudio(ptype, audioId, OnStartCall, OnEndCall);
            if (m_NowPlayAudio != null)
            {
                this.m_WaitPlayAudio = audioAction;
                m_NowPlayAudio.Stop();
            }
            else
            {
                this.m_NowPlayAudio = audioAction;
                this.m_NowPlayAudio.Play();
            }
        }
예제 #13
0
 private void OnStartCall(int audioGuid, AudioActionBase action)
 {
     this.AddAudio(audioGuid, action);
     MsgDispatcher.SendMessage(GlobalEventType.AudioPlayStart, audioGuid);
 }
예제 #14
0
 public override void Destroy()
 {
     m_NowPlayAudio = null;
     GlobalUnityEngineAPI.Destroy(base.s_AudioRoot);
 }