public CSoundSlot DoPlaySoundEffect_OrNull(string strSound, float fVolume = 1f) { if (_bIsMute) { return(null); } CSoundSlot pSoundSlot = FindDisableSlot_OrMakeSlot(); if (pSoundSlot == null) { return(null); } if (_mapSoundVolume.ContainsKey(strSound)) { pSoundSlot.DoPlaySound(GetAudioClip(strSound), _mapSoundVolume[strSound] * fVolume * _fVolumeEffect); } else { pSoundSlot.DoPlaySound(GetAudioClip(strSound), fVolume * _fVolumeEffect); } return(pSoundSlot); }
// ========================================================================== // /* public - [Do] Function * 외부 객체가 호출 */ public void DoPlayAnimation(string strLabelContent, float fDurationSec, CSoundSlot pSoundSlot_OnChangeText = null) { if (_bIsExcuteAwake == false) { OnAwake(); } if (strLabelContent == null || strLabelContent.Length == 0) { Debug.LogWarning("라벨의 길이가 0입니다."); return; } if (pSoundSlot_OnChangeText != null) { _pSoundSlot_OnChangeText = pSoundSlot_OnChangeText; pSoundSlot_OnChangeText.DoPlaySound(); } _strLabelContent = strLabelContent; _fCharPerSec = fDurationSec / _strLabelContent.Length; ProcEditText(""); _iCharLengthIndex = 0; _fPrevTime = _bIgnoreTimeScale ? RealTime.time : Time.time; StartCoroutine(CoPlayUILabelAnimation()); }
private CSoundSlot ProcPlaySound_GetSlot() { if (_pSlotCurrentPlaying != null) { _pManagerSound.EventOnSlotFinishClip(_pSlotCurrentPlaying); } CSoundSlot pSlot = null; if (_arrPlayAudioClip != null) { AudioClip pClipRandom = _arrPlayAudioClip.GetRandom(); pSlot = _pManagerSound.DoPlaySoundEffect_OrNull(pClipRandom, _fSoundVolume); } if (pSlot != null && _pAudioSource != null) { AudioSource pSlotSource = pSlot.p_pAudioSource; pSlotSource.rolloffMode = _pAudioSource.rolloffMode; for (int i = 0; i < 3; i++) { AnimationCurve pCurve = _pAudioSource.GetCustomCurve((AudioSourceCurveType)i); pSlotSource.SetCustomCurve((AudioSourceCurveType)i, pCurve); } } return(pSlot); }
public CSoundSlot DoPlaySoundEffect_Loop(ENUM_SOUND_NAME eSound) { CSoundSlot pSoundSlot = DoPlaySoundEffect(eSound); pSoundSlot.DoPlaySoundLoop(); return(pSoundSlot); }
private CSoundSlot ProcPlaySound_GetSlot(string strSoundEvent) { if (_bStop_OnPlaySound && _listSlotCurrentPlaying.Count != 0) { for (int i = 0; i < _listSlotCurrentPlaying.Count; i++) { CManagerSound.instance.EventOnSlotFinishClip(_listSlotCurrentPlaying[i]); } _listSlotCurrentPlaying.Clear(); } CSoundSlot pSlot = null; if (_listSoundPlayInfo != null) { SSoundPlayInfo pPlayInfo = string.IsNullOrEmpty(strSoundEvent) == false && _mapSoundPlayEventWrapper.ContainsKey(strSoundEvent) ? _mapSoundPlayEventWrapper[strSoundEvent].GetRandom().p_pSoundPlayInfo : _listSoundPlayInfo.GetRandom(); if (pPlayInfo == null) { Debug.LogError(name + "pPlayInfo == null strSoundEvent : " + strSoundEvent, this); } else { if (pPlayInfo.p_pAudioClip != null) { pSlot = CManagerSound.instance.DoPlaySoundEffect_OrNull(pPlayInfo.p_pAudioClip, _fSoundVolume * pPlayInfo.p_fLocalVolume); } else { if (string.IsNullOrEmpty(pPlayInfo.p_strAudioKey) == false) { pSlot = CManagerSound.instance.DoPlaySoundEffect_OrNull(pPlayInfo.p_strAudioKey, _fSoundVolume * pPlayInfo.p_fLocalVolume); } else { Debug.LogError(name + "SoundPlayInfo 가 잘못되었습니다", this); } } } } if (pSlot != null && _pAudioSource != null) { AudioSource pSlotSource = pSlot.p_pAudioSource; pSlotSource.rolloffMode = _pAudioSource.rolloffMode; for (int i = 0; i < 3; i++) { AnimationCurve pCurve = _pAudioSource.GetCustomCurve((AudioSourceCurveType)i); pSlotSource.SetCustomCurve((AudioSourceCurveType)i, pCurve); } } _bIsPlaying = pSlot != null; return(pSlot); }
public CSoundSlot DoPlaySoundEffect_Loop(string eSound, float fVolume) { CSoundSlot pSoundSlot = DoPlaySoundEffect_OrNull(eSound, fVolume); if (pSoundSlot != null) { pSoundSlot.DoPlaySoundLoop(); } return(pSoundSlot); }
// ========================================================================== // // ===================================== // // protected - Unity API // // ===================================== // protected override void OnMakeClass(MonoBehaviour pBaseClass, ref bool bIsMultipleResource) { base.OnMakeClass(pBaseClass, ref bIsMultipleResource); for (int i = 0; i < _iSlotPoolingCount; i++) { MakeSoundSlot(); } _pSlotBGM = FindDisableSlot_OrNull(); EventOnSlotPlayClip(_pSlotBGM); }
// ========================================================================== // // ===================================== // // protected - Unity API // // ===================================== // protected override void OnAwake() { base.OnAwake(); _pAudioGetter = new CResourceGetter <AudioClip>("Sound"); for (int i = 0; i < const_iDefault_SoundSlot_PoolingCount; i++) { MakeSoundSlot(); } _pSlotBGM = FindDisableSlot_OrMakeSlot(); EventOnSlotPlayClip(_pSlotBGM); }
// ===================================== // // private - [Other] Function // // 찾기, 계산 등의 비교적 단순 로직 // // ===================================== // private CSoundSlot FindDisableSlot_OrNull() { CSoundSlot pFindSlot = null; IEnumerator <CSoundSlot> pEnum = _queueNotUseSlot.GetEnumerator(); if (pEnum.MoveNext()) { pFindSlot = pEnum.Current; _queueNotUseSlot.Remove(pFindSlot); } return(pFindSlot); }
private void ProcPlaySound() { _pSlotCurrentPlaying = ProcPlaySound_GetSlot(); if (_pSlotCurrentPlaying == null) { return; } _pSlotCurrentPlaying.DoSetFinishEvent_OneShot(ProcFinishSound); if (_bIs3DSound) { _pSlotCurrentPlaying.DoSet3DSound(transform.position, _fMinDistance_On3DSound, _fMaxDistance_On3DSound); } }
// ========================================================================== // // ===================================== // // private - [Proc] Function // // 중요 로직을 처리 // // ===================================== // private void MakeSoundSlot() { GameObject pObject = new GameObject(string.Format("SoundSlot_{0}", _listSoundSlotAll.Count)); Transform pTrans = pObject.transform; pTrans.SetParent(_pBase.transform); pTrans.localRotation = Quaternion.identity; pTrans.gameObject.SetActive(false); CSoundSlot pSlot = pObject.AddComponent <CSoundSlot>(); pSlot.EventInitSoundSlot(_pBase, EventOnSlotPlayClip, EventOnSlotFinishClip); _listSoundSlotAll.Add(pSlot); _queueNotUseSlot.Add(pSlot); }
private void PlaySound() { CSoundSlot pSlot = ProcPlaySound_GetSlot(null); if (pSlot == null) { return; } if (_listSlotCurrentPlaying.Contains(pSlot) == false) { _listSlotCurrentPlaying.Add(pSlot); } pSlot.DoSetFinishEvent_OneShot(ProcFinishSound); if (_bIs3DSound) { pSlot.DoSet3DSound(transform.position, _fMinDistance_On3DSound, _fMaxDistance_On3DSound); } }
public CSoundSlot DoPlaySoundEffect(ENUM_SOUND_NAME eSound, float fVolume = 1f) { string strSoundName = eSound.ToString(); if (_mapCurrentPlayingSound.ContainsKey(strSoundName)) { CSoundSlot pSlotCurrentPlaying = _mapCurrentPlayingSound[strSoundName]; //pSlotCurrentPlaying.DoStopSound(); pSlotCurrentPlaying.DoPlaySound(); return(pSlotCurrentPlaying); } //Debug.Log("Play Sound : " + eSound); CSoundSlot pSoundSlot = FindDisableSlot_OrNull(); if (pSoundSlot == null) { return(null); } //{ // MakeSoundSlot(); // pSoundSlot = FindDisableSlot(); //} if (pSoundSlot != null) { if (_mapSoundVolume.ContainsKey(eSound)) { pSoundSlot.DoPlaySound(DoGetResource_Origin(eSound), _mapSoundVolume[eSound] * fVolume * _fVolumeEffect); } else { pSoundSlot.DoPlaySound(DoGetResource_Origin(eSound), fVolume * _fVolumeEffect); } _mapCurrentPlayingSound.Add(strSoundName, pSoundSlot); } return(pSoundSlot); }
// ========================================================================== // /* private - [Proc] Function * 중요 로직을 처리 */ private void ProcFinishSound() { if (_iLoopCount != 0 && _iLoopCountCurrent-- > 0) // 반복 횟수가 0이 아니고 반복 횟수가 아직 0이 아니라면.. { EventDelayExcuteCallBack(ProcPlaySound, _fLoopDelay); } else { // 반복 횟수가 0이거나 반복 횟수가 다 끝났다면.. p_listEvent_FinishSound.Invoke(); _bIsPlaying = false; if (_bIsLoop) { if (_fLoopDelay != 0f) { EventDelayExcuteCallBack(DoPlayEventTrigger, _fLoopDelay); } else { DoPlayEventTrigger(); } } else { if (_pSlotCurrentPlaying != null) { _pManagerSound.EventOnSlotFinishClip(_pSlotCurrentPlaying); _pSlotCurrentPlaying = null; } #if UNITY_EDITOR if (this != null) { name = _strOriginName; } #endif } } }
// ========================================================================== // /* private - [Proc] Function * 중요 로직을 처리 */ private void ProcFinishSound(CSoundSlot pSlot) { if (_iLoopCount != 0 && _iLoopCountCurrent-- > 0) // 반복 횟수가 0이 아니고 반복 횟수가 아직 0이 아니라면.. { EventExcuteDelay(PlaySound, _fLoopDelay); } else { // 반복 횟수가 0이거나 반복 횟수가 다 끝났다면.. p_listEvent_FinishSound.Invoke(); _bIsPlaying = false; if (_bIsLoop) { if (_fLoopDelay != 0f) { EventExcuteDelay(DoPlayEventTrigger, _fLoopDelay); } else { DoPlayEventTrigger(); } } else { if (_listSlotCurrentPlaying.Contains(pSlot)) { CManagerSound.instance.EventOnSlotFinishClip(pSlot); _listSlotCurrentPlaying.Remove(pSlot); } #if UNITY_EDITOR if (this != null) { name = _strOriginName; } #endif } } }
public CSoundSlot DoPlaySoundEffect_OrNull(AudioClip pClip, float fVolume = 1f) { if (_bIsMute) { return(null); } //Debug.Log("Play Sound : " + eSound); CSoundSlot pSoundSlot = FindDisableSlot_OrMakeSlot(); if (pSoundSlot == null) { return(null); } if (pSoundSlot != null) { pSoundSlot.DoPlaySound(pClip, fVolume * _fVolumeEffect); } return(pSoundSlot); }
public void DoPlayAnimation_Number(int iStartNubmer, int iDestNumber, string strNumberFormat, float fDurationSec, CSoundSlot pSoundSlot_OnChangeText = null, float fStartDelaySec = 0f) { if (_bIsExcuteAwake == false) { OnAwake(); } if (pSoundSlot_OnChangeText != null) { _pSoundSlot_OnChangeText = pSoundSlot_OnChangeText; pSoundSlot_OnChangeText.DoPlaySound(); } _strLabelContent = strNumberFormat; _iCharLengthIndex = iStartNubmer; ProcEditText(string.Format(strNumberFormat, iStartNubmer)); _iStartNumber = iStartNubmer; _iDestNumber = iDestNumber; _fCharPerSec = fDurationSec; StartCoroutine(CoPlayUILabelAnimation_Number(fStartDelaySec)); }
public CSoundSlot DoPlaySoundEffect_OnlySinglePlay_OrNull(string strSound, float fVolume = 1f) { if (_bIsMute) { return(null); } string strSoundName = strSound; if (_mapCurrentPlayingSound.ContainsKey(strSoundName)) { CSoundSlot pSlotCurrentPlaying = _mapCurrentPlayingSound[strSoundName]; pSlotCurrentPlaying.DoPlaySound(); return(pSlotCurrentPlaying); } CSoundSlot pSoundSlot = FindDisableSlot_OrMakeSlot(); if (pSoundSlot == null) { return(null); } if (_mapSoundVolume.ContainsKey(strSound)) { pSoundSlot.DoPlaySound(GetAudioClip(strSound), _mapSoundVolume[strSound] * fVolume * _fVolumeEffect); } else { pSoundSlot.DoPlaySound(GetAudioClip(strSound), fVolume * _fVolumeEffect); } _mapCurrentPlayingSound.Add(strSoundName, pSoundSlot); return(pSoundSlot); }
public void EventOnSlotFinishClip(CSoundSlot pSlot) { if (pSlot == _pSlotBGM) { if (_CallBackOnFinishBGM != null) { var OnFinishBackup = _CallBackOnFinishBGM; _CallBackOnFinishBGM = null; OnFinishBackup(); } } else { _queueNotUseSlot.Add(pSlot); if (pSlot.p_pAudioSource.clip != null) { string strClipName = pSlot.p_pAudioSource.clip.name; if (_mapCurrentPlayingSound.ContainsKey(strClipName)) { _mapCurrentPlayingSound.Remove(strClipName); } } } }
public void EventOnSlotPlayClip(CSoundSlot pSlot) { _queueNotUseSlot.Remove(pSlot); }