コード例 #1
0
        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!");
            }
        }
コード例 #2
0
        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!");
            }
        }
コード例 #3
0
 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/"));
 }
コード例 #4
0
 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());
 }
コード例 #5
0
 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/"));
 }
コード例 #6
0
        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/"));
        }