public void StopAll() { m_looping = false; StopAllCoroutines(); IDictionaryEnumerator enumerator = m_childComponents.GetEnumerator(); try { while (enumerator.MoveNext()) { DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.Current; if (dictionaryEntry.Value is AudioComponent) { AudioComponent audioComponent = dictionaryEntry.Value as AudioComponent; audioComponent.StopAll(); } if (dictionaryEntry.Value is AudioRandomComponent) { AudioRandomComponent audioRandomComponent = dictionaryEntry.Value as AudioRandomComponent; audioRandomComponent.StopAll(); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } }
private void Update() { m_realVolume = Mathf.Clamp(m_volume * m_parentVolume * m_setVolume, 0f, 1f); m_realPitch = Mathf.Clamp(m_pitch * m_parentPitch * m_setPitch, -3f, 3f); for (int i = 0; i < m_hashKeys.Count; i++) { object obj = m_childComponents[m_hashKeys[i]]; if (obj is AudioComponent) { AudioComponent audioComponent = obj as AudioComponent; audioComponent.m_parentVolume = m_realVolume; audioComponent.m_parentPitch = m_realPitch; } if (obj is AudioRandomComponent) { AudioRandomComponent audioRandomComponent = obj as AudioRandomComponent; audioRandomComponent.m_parentVolume = m_realVolume; audioRandomComponent.m_parentPitch = m_realPitch; } if (obj is AudioRandomSimpleComponent) { AudioRandomSimpleComponent audioRandomSimpleComponent = obj as AudioRandomSimpleComponent; audioRandomSimpleComponent.m_parentVolume = m_realVolume; audioRandomSimpleComponent.m_parentPitch = m_realPitch; } if (obj is AudioGroupComponent) { AudioGroupComponent audioGroupComponent = obj as AudioGroupComponent; audioGroupComponent.m_parentVolume = m_realVolume; audioGroupComponent.m_parentPitch = m_realPitch; } } }
private void RegisterWithParent() { m_parentGroupComponent = base.transform.parent.gameObject.GetComponent <AudioGroupComponent>(); if ((bool)m_parentGroupComponent && m_parentGroupComponent.RegisterComponent(base.gameObject)) { m_registeredWithParent = true; } m_parentRandomComponent = base.transform.parent.gameObject.GetComponent <AudioRandomComponent>(); if ((bool)m_parentRandomComponent && m_parentRandomComponent.RegisterComponent(base.gameObject)) { m_registeredWithParent = true; } }
private void PlayComponent(GameObject _parentGameObject) { if (m_hashKeys.Count > 0) { object key = m_hashKeys[UnityEngine.Random.Range(0, m_hashKeys.Count)]; object obj = m_childComponents[key]; if (obj is AudioComponent) { AudioComponent audioComponent = obj as AudioComponent; audioComponent.Play(_parentGameObject); m_timesPlayed++; } if (obj is AudioRandomComponent) { AudioRandomComponent audioRandomComponent = obj as AudioRandomComponent; audioRandomComponent.Play(_parentGameObject); m_timesPlayed++; } } }
public bool RegisterComponent(GameObject _gameObject) { AudioComponent component = _gameObject.GetComponent <AudioComponent>(); if ((bool)component) { m_childComponents.Add(_gameObject, component); m_hashKeys.Add(_gameObject); if (!component.m_overrideParentOutput) { component.m_output = m_output; } if (!component.m_overrideParentPositioning) { component.m_positioning = m_positioning; } return(true); } AudioRandomComponent component2 = _gameObject.GetComponent <AudioRandomComponent>(); if ((bool)component2) { m_childComponents.Add(_gameObject, component2); m_hashKeys.Add(_gameObject); if (!component2.m_overrideParentOutput) { component2.m_output = m_output; } if (!component2.m_overrideParentPositioning) { component2.m_positioning = m_positioning; } return(true); } return(false); }