public void Play(Component requester, float fade_in = 0f) { this.m_Requesters.Add(requester); if (requester is IMSMultisampleController) { this.m_RequesterControllers.Add(requester as IMSMultisampleController); } if (this.m_State == MSState.FadeIn || this.m_State == MSState.Playing) { return; } if (this.m_FirstTimeUse) { this.m_VolumeMul = 0f; this.m_FirstTimeUse = false; } this.m_VolumeMulOnStartFade = this.m_VolumeMul; this.m_State = MSState.FadeIn; this.m_PlayTime = Time.time; this.m_FadeInTime = fade_in; this.m_Playing = true; for (int i = 0; i < this.m_Samples.Count; i++) { MSSample mssample = this.m_Samples[i]; if (mssample != null) { mssample.Play(); } } }
public MSSample AddSample() { MSSample mssample = new MSSample(); mssample.m_MultiSample = this; this.m_Samples.Add(mssample); return(mssample); }
public void Stop() { this.m_Playing = false; for (int i = 0; i < this.m_Samples.Count; i++) { MSSample mssample = this.m_Samples[i]; if (mssample != null) { mssample.Stop(); } } this.m_StopTime = float.MaxValue; }
public void Update() { if (this.m_State == MSState.FadeOut && Time.time > this.m_StopTime + this.m_FadeOutTime) { this.Stop(); return; } this.UpdateParams(); this.UpdateSpatialBlend(); float num = 1f; if (this.m_RainForestAmbient) { num = MSMultiSample.s_RainforestWantedAmbientVolume; } else if (this.m_State == MSState.FadeIn) { if (this.m_ChangeRainforestAmbientVolume) { Mathf.Clamp01((Time.time - this.m_PlayTime) / this.m_PlayTime + this.m_FadeInTime); MSMultiSample.s_RainforestWantedAmbientVolume = CJTools.Math.GetProportionalClamp(1f, this.m_RainforestAmbientVolume, Time.time, this.m_PlayTime, this.m_PlayTime + this.m_FadeInTime); } num = CJTools.Math.GetProportionalClamp(this.m_VolumeMulOnStartFade, 1f, Time.time, this.m_PlayTime, this.m_PlayTime + this.m_FadeInTime); if (num >= 1f) { this.m_State = MSState.Playing; } } else if (this.m_State == MSState.FadeOut) { if (this.m_ChangeRainforestAmbientVolume) { Mathf.Clamp01((Time.time - this.m_StopTime) / this.m_StopTime + this.m_FadeInTime); MSMultiSample.s_RainforestWantedAmbientVolume = CJTools.Math.GetProportionalClamp(this.m_RainforestAmbientVolume, 1f, Time.time, this.m_StopTime, this.m_StopTime + this.m_FadeOutTime); } num = CJTools.Math.GetProportionalClamp(this.m_VolumeMulOnStartFade, 0f, Time.time, this.m_StopTime, this.m_StopTime + this.m_FadeOutTime); } else if (this.m_State == MSState.Playing && this.m_ChangeRainforestAmbientVolume) { MSMultiSample.s_RainforestWantedAmbientVolume = this.m_RainforestAmbientVolume; } this.m_VolumeMul = num; for (int i = 0; i < this.m_Samples.Count; i++) { MSSample mssample = this.m_Samples[i]; if (mssample != null) { mssample.Update(num); } } }
public void Play(float fade_in = 0f) { this.m_PlayTime = Time.time; this.m_FadeInTime = fade_in; this.m_Playing = true; for (int i = 0; i < this.m_Samples.Count; i++) { MSSample mssample = this.m_Samples[i]; if (mssample != null) { mssample.Play(); } } }
private void Stop() { this.m_Playing = false; for (int i = 0; i < this.m_Samples.Count; i++) { MSSample mssample = this.m_Samples[i]; if (mssample != null) { mssample.Stop(); } } this.m_StopTime = float.MaxValue; this.m_State = MSState.None; this.m_ChangeRainforestAmbientVolume = false; this.m_RainforestAmbientVolume = 1f; }
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); } } }
public void Load(Key key) { this.m_Name = key.GetVariable(0).SValue; this.m_Params.Clear(); this.m_Samples.Clear(); for (int i = 0; i < key.GetKeysCount(); i++) { Key key2 = key.GetKey(i); if (key2.GetName() == "Param") { MSCurveHash mscurveHash = new MSCurveHash(); mscurveHash.m_Name = key2.GetVariable(0).SValue; mscurveHash.m_Hash = Animator.StringToHash(mscurveHash.m_Name); this.m_Params.Add(mscurveHash); } else if (key2.GetName() == "Sample") { MSSample mssample = this.AddSample(); mssample.Load(key2); } } }
public void Update() { if (Time.time > this.m_StopTime + this.m_FadeOutTime) { this.Stop(); return; } this.UpdateParams(); float proportionalClamp = CJTools.Math.GetProportionalClamp(0f, 1f, Time.time, this.m_PlayTime, this.m_PlayTime + this.m_FadeInTime); if (Time.time > this.m_StopTime) { proportionalClamp = CJTools.Math.GetProportionalClamp(1f, 0f, Time.time, this.m_StopTime, this.m_StopTime - this.m_FadeOutTime); } for (int i = 0; i < this.m_Samples.Count; i++) { MSSample mssample = this.m_Samples[i]; if (mssample != null) { mssample.Update(proportionalClamp); } } }