private void OnEnable() { Instance = this; BombActive = true; EnableDisableInput(); Leaderboard.Instance.ClearSolo(); LogUploader.Instance.Clear(); callsNeeded = 1; CallingPlayers.Clear(); _bombStarted = false; ParentService.GetComponent <KMGameInfo>().OnLightsChange += OnLightsChange; StartCoroutine(CheckForBomb()); try { string path = Path.Combine(Application.persistentDataPath, "TwitchPlaysLastClaimed.json"); LastClaimedModule = SettingsConverter.Deserialize <Dictionary <string, Dictionary <string, double> > >(File.ReadAllText(path)); } catch (Exception ex) { DebugHelper.LogException(ex, "Couldn't read TwitchPlaysLastClaimed.json:"); LastClaimedModule = new Dictionary <string, Dictionary <string, double> >(); } }
public static bool LoadDataFromFile() { string path = Path.Combine(Application.persistentDataPath, usersSavePath); try { DebugHelper.Log("TwitchPlayStrings: Loading Custom strings data from file: {0}", path); data = SettingsConverter.Deserialize <TwitchPlaySettingsData>(File.ReadAllText(path)); //JsonConvert.DeserializeObject<TwitchPlaySettingsData>(File.ReadAllText(path)); data.ValidateStrings(); WriteDataToFile(); } catch (FileNotFoundException) { DebugHelper.LogWarning("TwitchPlayStrings: File {0} was not found.", path); data = new TwitchPlaySettingsData(); WriteDataToFile(); return(false); } catch (Exception ex) { data = new TwitchPlaySettingsData(); DebugHelper.LogException(ex); return(false); } return(true); }
public static bool LoadDataFromFile() { ModuleInformation[] modInfo; string path = Path.Combine(Application.persistentDataPath, usersSavePath); try { DebugHelper.Log($"ModuleData: Loading Module information data from file: {path}"); modInfo = SettingsConverter.Deserialize <ModuleInformation[]>(File.ReadAllText(path)); //JsonConvert.DeserializeObject<ModuleInformation[]>(File.ReadAllText(path)); } catch (FileNotFoundException) { DebugHelper.LogWarning($"ModuleData: File {path} was not found."); return(false); } catch (Exception ex) { DebugHelper.LogException(ex); return(false); } foreach (ModuleInformation info in modInfo) { ComponentSolverFactory.AddModuleInformation(info); } return(true); }
public static bool LoadDataFromFile() { FileModuleInformation[] modInfo; string path = Path.Combine(Application.persistentDataPath, usersSavePath); try { DebugHelper.Log($"Loading Module information data from file: {path}"); modInfo = SettingsConverter.Deserialize<FileModuleInformation[]>(File.ReadAllText(path)); lastRead = modInfo; } catch (FileNotFoundException) { DebugHelper.LogWarning($"File {path} was not found."); return false; } catch (Exception ex) { DebugHelper.LogException(ex); return false; } foreach (var fileInfo in modInfo) { ModuleInformation defaultInfo = null; if (fileInfo.moduleID != null) { defaultInfo = ComponentSolverFactory.GetDefaultInformation(fileInfo.moduleID); } var info = new ModuleInformation(); foreach (FieldInfo fileFieldInfo in fileInfoFields) { if (fileFieldInfo.DeclaringType == typeof(ModuleInformation)) { if (fileInfoFields.Any(field => field.DeclaringType == typeof(FileModuleInformation) && field.Name == fileFieldInfo.Name)) continue; fileFieldInfo.SetValue(info, fileFieldInfo.GetValue(fileInfo)); } else { var baseFieldInfo = Array.Find(infoFields, field => field.Name == fileFieldInfo.Name); if (baseFieldInfo == null) throw new NotSupportedException("Superclass isn't overriding only base fields."); var value = fileFieldInfo.GetValue(fileInfo); if (value == null && defaultInfo != null) { value = baseFieldInfo.GetValue(defaultInfo); } baseFieldInfo.SetValue(info, value); } } ComponentSolverFactory.AddModuleInformation(info); } return true; }
private void OnEnable() { Instance = this; BombActive = true; EnableDisableInput(); Leaderboard.Instance.ClearSolo(); LogUploader.Instance.Clear(); callsNeeded = 1; CallingPlayers.Clear(); callWaiting = false; VoteDetonateAttempted = false; ProcessingClaimQueue = false; VoteSolveCount = 0; FindClaimPlayers.Clear(); MysteryModuleShim.CoveredModules.Clear(); RetryAllowed = true; _bombStarted = false; ParentService.GetComponent <KMGameInfo>().OnLightsChange += OnLightsChange; StartCoroutine(CheckForBomb()); StartCoroutine(new WaitForSeconds(TwitchPlaySettings.data.InstantModuleClaimCooldown).Yield(() => ClaimCooldown = false)); FindClaimUse = TwitchPlaySettings.data.FindClaimLimit; alertSound = gameObject.Traverse <AudioSource>("AlertSound"); StartCoroutine(AdjustFindClaimLimit()); if (OtherModes.TrainingModeOn) { StartCoroutine(EndTrainingModeBomb()); } try { string path = Path.Combine(Application.persistentDataPath, "TwitchPlaysLastClaimed.json"); LastClaimedModule = SettingsConverter.Deserialize <Dictionary <string, Dictionary <string, double> > >(File.ReadAllText(path)); } catch (Exception ex) { DebugHelper.LogException(ex, "Couldn't read TwitchPlaysLastClaimed.json:"); LastClaimedModule = new Dictionary <string, Dictionary <string, double> >(); } }