public void OnWhispersEvent(PlayerSanityModule.WhisperType type) { if (this.m_Sanity > this.m_WhispersSanityLevel) { return; } if (this.m_LastWhisperTime != 0f) { float proportionalClamp = CJTools.Math.GetProportionalClamp(this.m_MaxWhispersInterval, this.m_MinWhispersInterval, (float)this.m_Sanity, (float)this.m_WhispersSanityLevel, 1f); if (Time.time - this.m_LastWhisperTime < proportionalClamp) { return; } } this.m_WhispersQueue.Clear(); List <AudioClip> list = this.m_WhispersMap[(int)type]; int num = UnityEngine.Random.Range(1, this.m_MaxWhispersQueue + 1); for (int i = 0; i < num; i++) { AudioSource audioSource = this.m_AudioSources[UnityEngine.Random.Range(0, this.m_AudioSources.Count)]; this.m_AudioSources.Remove(audioSource); audioSource.clip = list[UnityEngine.Random.Range(0, list.Count)]; this.m_WhispersQueue.Add(audioSource); } foreach (AudioSource item in this.m_WhispersQueue) { this.m_AudioSources.Add(item); } this.PlayWhisper(); this.m_LastWhisperTime = Time.time; }
private void LoadScript() { TextAsset textAsset = Resources.Load(this.m_SanityScript) as TextAsset; if (!textAsset) { DebugUtils.Assert("Can't load Sanity script - " + this.m_SanityScript, true, DebugUtils.AssertType.Info); return; } TextAssetParser textAssetParser = new TextAssetParser(textAsset); for (int i = 0; i < textAssetParser.GetKeysCount(); i++) { Key key = textAssetParser.GetKey(i); if (key.GetName() == "ItemHallucinationsSanityLevel") { this.m_ItemHallucinationsSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "ItemHallucinationMinInterval") { this.m_ItemHallucinationMinInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "ItemHallucinationMaxInterval") { this.m_ItemHallucinationMaxInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "ItemHallucinationsMinCount") { this.m_ItemHallucinationsMinCount = key.GetVariable(0).IValue; } else if (key.GetName() == "ItemHallucinationsMaxCount") { this.m_ItemHallucinationsMaxCount = key.GetVariable(0).IValue; } else if (key.GetName() == "AIHallucinationsSanityLevel") { this.m_AIHallucinationsSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "AIHallucinationMinInterval") { this.m_AIHallucinationMinInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "AIHallucinationMaxInterval") { this.m_AIHallucinationMaxInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "AIHallucinationsMinCount") { this.m_AIHallucinationsMinCount = key.GetVariable(0).IValue; } else if (key.GetName() == "AIHallucinationsMaxCount") { this.m_AIHallucinationsMaxCount = key.GetVariable(0).IValue; } else if (key.GetName() == "StartEffectSanityLevel") { this.m_StartEffectSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "DisappearChatterChance") { this.m_DisappearChatterChance = key.GetVariable(0).FValue; } else if (key.GetName() == "MinSpawnStalkerInterval") { this.m_MinSpawnStalkerInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MaxSpawnStalkerInterval") { this.m_MaxSpawnStalkerInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "WhispersSanityLevel") { this.m_WhispersSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "MinWhispersInterval") { this.m_MinWhispersInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MaxWhispersInterval") { this.m_MaxWhispersInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MinRandomWhispersInterval") { this.m_MinRandomWhispersInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MaxRandomWhispersInterval") { this.m_MaxRandomWhispersInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MaxWhispersQueue") { this.m_MaxWhispersQueue = key.GetVariable(0).IValue; } else if (key.GetName() == "Event") { string svalue = key.GetVariable(0).SValue; if (Enum.IsDefined(typeof(PlayerSanityModule.SanityEventType), svalue)) { PlayerSanityModule.SanityEventType key2 = (PlayerSanityModule.SanityEventType)Enum.Parse(typeof(PlayerSanityModule.SanityEventType), svalue); this.m_EventsMap[(int)key2].m_SanityChange[0] = key.GetVariable(1).IValue; this.m_EventsMap[(int)key2].m_SanityChange[1] = key.GetVariable(2).IValue; this.m_EventsMap[(int)key2].m_SanityChange[2] = key.GetVariable(3).IValue; this.m_EventsMap[(int)key2].m_Interval = key.GetVariable(4).FValue; this.m_EventsMap[(int)key2].m_TextID = key.GetVariable(5).SValue; } } else if (key.GetName() == "StalkerStalkingSanityLevel") { this.m_StalkerStalkingSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "StalkerAttackSanityLevel") { this.m_StalkerAttackSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "Whisper") { PlayerSanityModule.WhisperType key3 = (PlayerSanityModule.WhisperType)Enum.Parse(typeof(PlayerSanityModule.WhisperType), key.GetVariable(0).SValue); for (int j = 0; j < key.GetKeysCount(); j++) { Key key4 = key.GetKey(j); if (key4.GetName() == "Clip") { AudioClip audioClip = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key4.GetVariable(0).SValue); if (!audioClip) { audioClip = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key4.GetVariable(0).SValue); } if (!audioClip) { DebugUtils.Assert("Can't find clip - " + key4.GetVariable(0).SValue, true, DebugUtils.AssertType.Info); } if (!this.m_WhispersMap.ContainsKey((int)key3)) { List <AudioClip> value = new List <AudioClip>(); this.m_WhispersMap.Add((int)key3, value); } this.m_WhispersMap[(int)key3].Add(audioClip); } } } else if (key.GetName() == "DisappearItemSounds") { for (int k = 0; k < key.GetKeysCount(); k++) { Key key5 = key.GetKey(k); if (key5.GetName() == "Clip") { AudioClip audioClip2 = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key5.GetVariable(0).SValue); if (!audioClip2) { audioClip2 = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key5.GetVariable(0).SValue); } if (!audioClip2) { DebugUtils.Assert("Can't find clip - " + key5.GetVariable(0).SValue, true, DebugUtils.AssertType.Info); } if (!this.m_DisappearItem.Contains(audioClip2)) { this.m_DisappearItem.Add(audioClip2); } } } } else if (key.GetName() == "DisappearAISounds") { for (int l = 0; l < key.GetKeysCount(); l++) { Key key6 = key.GetKey(l); if (key6.GetName() == "Clip") { AudioClip audioClip3 = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key6.GetVariable(0).SValue); if (!audioClip3) { audioClip3 = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key6.GetVariable(0).SValue); } if (!audioClip3) { DebugUtils.Assert("Can't find clip - " + key6.GetVariable(0).SValue, true, DebugUtils.AssertType.Info); } if (!this.m_DisappearAI.Contains(audioClip3)) { this.m_DisappearAI.Add(audioClip3); } } } } else if (key.GetName() == "LowEnegryWhispersLevel") { this.m_LowEnegryWhispersLevel = key.GetVariable(0).FValue; } } Resources.UnloadAsset(textAsset); }