private static void CheckRepeatedCharacter(Character character, Options options, List <Character> characters) { bool canAdd = true; foreach (string characterName in options.characterList) { if (characterName == character.name) { canAdd = false; break; } } if (canAdd) { characters.Add(character); if (characters.Count == 1) { options.playerCharacterName = character.name; } options.characterList = ArrayHelper.Add(options.characterList, character.name); OptionsController.Save(options, options.jsonPrettyPrint); JSONHelper.Create(character, character.name, options.jsonPrettyPrint, "Diplomata/Characters/"); } else { Debug.LogError("This name already exists!"); } }
private static void CheckRepeatedInteractable(Interactable interactable, Options options, List <Interactable> interactables) { bool canAdd = true; foreach (string interactableName in options.interactableList) { if (interactableName == interactable.name) { canAdd = false; break; } } if (canAdd) { interactables.Add(interactable); options.interactableList = ArrayHelper.Add(options.interactableList, interactable.name); OptionsController.Save(options, options.jsonPrettyPrint); JSONHelper.Create(interactable, interactable.name, options.jsonPrettyPrint, "Diplomata/Interactables/"); } else { Debug.LogError("This name already exists!"); } }
public static Inventory GetInventory(bool prettyPrint = false) { JSONHelper.CreateFolder("Diplomata/"); if (!JSONHelper.Exists("inventory", "Diplomata/")) { JSONHelper.Create(new Inventory(), "inventory", prettyPrint, "Diplomata/"); } return(JSONHelper.Read <Inventory>("inventory", "Diplomata/")); }
public static Quest[] GetQuests(bool prettyPrint = false) { JSONHelper.CreateFolder("Diplomata/"); if (!JSONHelper.Exists("quests", "Diplomata/")) { JSONHelper.Create(new Quests(), "quests", prettyPrint, "Diplomata/"); } return(JSONHelper.Read <Quests>("quests", "Diplomata/").GetQuests()); }
public static Options GetOptions() { JSONHelper.CreateFolder("Diplomata/"); if (!JSONHelper.Exists("preferences", "Diplomata/")) { JSONHelper.Create(new Options(), "preferences", false, "Diplomata/"); } return(JSONHelper.Read <Options>("preferences", "Diplomata/")); }
public static GlobalFlags GetGlobalFlags(bool prettyPrint = false) { JSONHelper.CreateFolder("Diplomata/"); // Rename legacy custom flags files. if (JSONHelper.Exists("customFlags", "Diplomata/")) { var globalFlags = JSONHelper.Read <GlobalFlags>("customFlags", "Diplomata/"); JSONHelper.Create(globalFlags, "globalFlags", prettyPrint, "Diplomata/"); JSONHelper.Delete("customFlags", "Diplomata/"); } // Create global flags file if don't exists. if (!JSONHelper.Exists("globalFlags", "Diplomata/")) { JSONHelper.Create(new GlobalFlags(), "globalFlags", prettyPrint, "Diplomata/"); } // Return the global flags file. return(JSONHelper.Read <GlobalFlags>("globalFlags", "Diplomata/")); }