private void UpdateVolume(float volume_mul) { float num = 1f; foreach (KeyValuePair <MSCurveData, AnimationCurve> keyValuePair in this.m_Curves) { MSCurveData key = keyValuePair.Key; if (key.m_Volume) { AnimationCurve animationCurve = this.m_Curves[key]; num *= animationCurve.Evaluate(this.m_MultiSample.m_ParamsMap[key.m_Hash]); } } num = Mathf.Clamp01(num); this.m_AudioSource.volume = num * volume_mul; if (this.m_AudioSource.isPlaying && this.m_AudioSource.volume <= 0f) { this.m_AudioSource.Stop(); return; } if (!MainLevel.Instance.IsPause() && Time.deltaTime > 0f && !this.m_AudioSource.isPlaying && this.m_AudioSource.volume > 0f) { this.m_AudioSource.Play(); } }
private void UpdatePitchShift() { float num = 1f; foreach (KeyValuePair <MSCurveData, AnimationCurve> keyValuePair in this.m_Curves) { MSCurveData key = keyValuePair.Key; if (key.m_Pitch) { AnimationCurve animationCurve = this.m_Curves[key]; num *= animationCurve.Evaluate(this.m_MultiSample.m_ParamsMap[key.m_Hash]); } } this.m_AudioSource.pitch = num; }
private void UpdateVolume(float volume_mul) { float num = 1f; foreach (KeyValuePair <MSCurveData, AnimationCurve> keyValuePair in this.m_Curves) { MSCurveData key = keyValuePair.Key; if (key.m_Volume) { AnimationCurve animationCurve = this.m_Curves[key]; num *= animationCurve.Evaluate(this.m_MultiSample.m_ParamsMap[key.m_Hash]); } } num = Mathf.Clamp01(num); this.m_AudioSource.volume = num * volume_mul; }
public void Load(Key key) { this.m_WavName = key.GetVariable(0).SValue; if (Application.isPlaying) { this.m_AudioSource = MainLevel.Instance.gameObject.AddComponent <AudioSource>(); this.m_AudioSource.outputAudioMixerGroup = GreenHellGame.Instance.GetAudioMixerGroup(AudioMixerGroupGame.Enviro); this.m_AudioSource.clip = (Resources.Load(MSSample.s_SamplesPath + this.m_WavName) as AudioClip); this.m_AudioSource.loop = true; } for (int i = 0; i < key.GetKeysCount(); i++) { Key key2 = key.GetKey(i); if (key2.GetName() == "Curve") { string svalue = key2.GetVariable(0).SValue; AnimationCurve animationCurve = MSSample.MSCurveDataGetCurve(this.m_Curves, svalue); if (animationCurve == null) { animationCurve = new AnimationCurve(); } else { DebugUtils.Assert(DebugUtils.AssertType.Info); } animationCurve.preWrapMode = (WrapMode)Enum.Parse(typeof(WrapMode), key2.GetVariable(1).SValue); animationCurve.postWrapMode = (WrapMode)Enum.Parse(typeof(WrapMode), key2.GetVariable(2).SValue); for (int j = 0; j < key2.GetKeysCount(); j++) { Key key3 = key2.GetKey(j); if (key3.GetName() == "Key") { animationCurve.AddKey(new Keyframe(key3.GetVariable(0).FValue, key3.GetVariable(1).FValue, key3.GetVariable(2).FValue, key3.GetVariable(3).FValue)); } } MSCurveData mscurveData = new MSCurveData(); mscurveData.m_Name = svalue; mscurveData.m_Hash = Animator.StringToHash(mscurveData.m_Name); mscurveData.m_Volume = mscurveData.m_Name.EndsWith("_Vol"); mscurveData.m_Pitch = mscurveData.m_Name.EndsWith("_Pitch"); this.m_Curves.Add(mscurveData, animationCurve); } } }