public static void InitializeWithDefaultData() { storyDatabase = new StoryDatabase(); storyDatabase.storyData.Clear(); var storyData = Resources.LoadAll <TextAsset>("Story"); foreach (var d in storyData) { storyDatabase.storyData.Add(JsonUtility.FromJson <ProppStoryData>(d.text)); } storyDatabase.backgroundData.Clear(); var bgData = Resources.LoadAll <TextAsset>("Background"); foreach (var d in bgData) { storyDatabase.backgroundData.Add(JsonUtility.FromJson <ProppBackgroundData>(d.text)); } LoadFunctionData("Pair/Interdiction", storyDatabase.interdictionPairs); LoadFunctionData("Pair/Villainy", storyDatabase.villainyPairs); LoadFunctionData("Pair/Complication", storyDatabase.complicationPairs); LoadFunctionData("Pair/Donor", storyDatabase.donorPairs); LoadFunctionData("Pair/Agent", storyDatabase.agentPairs); LoadFunctionData("Pair/Struggle", storyDatabase.strugglePairs); LoadFunctionData("Pair/Pursue", storyDatabase.pursuePairs); LoadFunctionData("Pair/End", storyDatabase.endPairs); SaveData(); }
void Start() { long seed = System.DateTime.Now.Ticks; r = new RandomSeed(seed); r.getBoolean(); database = new StoryDatabase(journeyFiles); print(database.ToString()); }
public static void GetAtlas() { string path = "Assets/Story Data/StoryDatabase.asset"; StoryDatabase storyDatabase = AssetDatabase.LoadAssetAtPath <StoryDatabase>(path); if (storyDatabase == null) { storyDatabase = ScriptableObject.CreateInstance <StoryDatabase>(); AssetDatabase.CreateAsset(storyDatabase, path); AssetDatabase.SaveAssets(); } EditorUtility.FocusProjectWindow(); Selection.activeObject = storyDatabase; }
public static void LoadData() { if (storyDatabase == null) { string path = Application.persistentDataPath + "/storydb.json"; if (File.Exists(path)) { string contents = File.ReadAllText(path); storyDatabase = JsonUtility.FromJson <StoryDatabase>(contents); } else { InitializeWithDefaultData(); } //Debug.Log($"Load Data: {contents}"); } else { Debug.Log("Already data loaded"); } }