private void AddAudio(int audioGuid, AudioActionBase action) { if (m_AudioDic != null && action != null) { m_AudioDic[audioGuid] = action; } }
private void EnqueueAudio(AudioActionBase action) { if (action != null) { m_AudioQueue.Enqueue(action); } }
private AudioActionBase GetAduio(int audioGuid) { AudioActionBase action = null; if (m_AudioDic != null && m_AudioDic.ContainsKey(audioGuid)) { action = m_AudioDic[audioGuid]; } return(action); }
private AudioActionBase PeekAudio() { AudioActionBase action = null; if (m_AudioQueue != null && m_AudioQueue.Count > 0) { action = m_AudioQueue.Peek(); } return(action); }
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; } }
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(); }
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); } } } }
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(); } } }
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(); }
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); }
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); }
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(); } }
private void OnStartCall(int audioGuid, AudioActionBase action) { this.AddAudio(audioGuid, action); MsgDispatcher.SendMessage(GlobalEventType.AudioPlayStart, audioGuid); }
public override void Destroy() { m_NowPlayAudio = null; GlobalUnityEngineAPI.Destroy(base.s_AudioRoot); }