public static void SaveData(this ISaveAsJson source, JSON mainData) { JSON saveData = source.Save(); saveData.AddOrReplace(VersionKey, source.Version); mainData.Add(source.Key, saveData); }
// this has to be called per scenario at start of the scenario, as it creates the basic Empty object for a scenario with its key structures // better to be called after the PlayerID is set from GameManager, as this attempts to find an existing User file with same date to modify , or else it create a new one public bool SetScenarioMasterLogObject(string key) { if (LogData == null) { Init(); } if (key != null && key != "") { currentSecnarioMasterKey = key; currentTAS = 0; if (currentSecnarioMasterKey != "") { // initiate basics Log object Arrays JArray TASData = new JArray(); JArray PlayerLookingAtData = new JArray(); JArray PlayerMovedToData = new JArray(); JArray PlayerSelectedStudentData = new JArray(); JArray StudentLookingAtData = new JArray(); JArray StudentAnimationsData = new JArray(); JArray StudentSetupData = new JArray(); JSON ScenarioMasterObject = new JSON(); JSON TeacherActionsObject = new JSON(); JSON PlayerActionsObject = new JSON(); JSON StudentActionsObject = new JSON(); JSON GettingToKnowYourClassObject = new JSON(); JSON InitialSituationObject = new JSON(); // Populate TeacherActions TeacherActionsObject.AddOrReplace("TASData", TASData); // Populate PlayerActions PlayerActionsObject.AddOrReplace("LookingAt", PlayerLookingAtData); PlayerActionsObject.AddOrReplace("MovedTo", PlayerMovedToData); PlayerActionsObject.AddOrReplace("SelectedStudent", PlayerSelectedStudentData); // Populate StudentActions StudentActionsObject.AddOrReplace("LookingAt", StudentLookingAtData); StudentActionsObject.AddOrReplace("Animations", StudentAnimationsData); // Populate GettingToKnowYourClassObject GettingToKnowYourClassObject.AddOrReplace("start1", ""); GettingToKnowYourClassObject.AddOrReplace("end1", ""); // Populate InitialSituationObject InitialSituationObject.AddOrReplace("start2", ""); InitialSituationObject.AddOrReplace("end2", ""); // Add all the above and StudentSetup to the Current Scenario Object ScenarioMasterObject.AddOrReplace("GettingToKnowYourClass", GettingToKnowYourClassObject); ScenarioMasterObject.AddOrReplace("InitialSituation", InitialSituationObject); ScenarioMasterObject.AddOrReplace("TeacherActions", TeacherActionsObject); ScenarioMasterObject.AddOrReplace("StudentSetup", StudentSetupData); ScenarioMasterObject.AddOrReplace("PlayerActions", PlayerActionsObject); ScenarioMasterObject.AddOrReplace("StudentActions", StudentActionsObject); if (LogData.ContainsKey(currentSecnarioMasterKey)) { LogData.AddOrReplace(currentSecnarioMasterKey, ScenarioMasterObject); } else { LogData.Add(currentSecnarioMasterKey, ScenarioMasterObject); } } return(true); } currentSecnarioMasterKey = ""; Debug.LogAssertion("Key for New attepmt to set Scenario Master Log Object is empty or null"); return(false); }