public void LoadGame(MainMissionSaveData info) { SideMissionSaveData temp = JsonUtility.FromJson <SideMissionSaveData>(info.missionSaveData); missionSlot.LoadGame(temp, alchemistMaster); currentMission = info.currentMission; currentStringDisplay = info.currentStringDisplay; }
public MainMissionSaveData SaveGame() { SideMissionSaveData temp = missionSlot.SaveGame(); MainMissionSaveData saveData = new MainMissionSaveData(); saveData.missionSaveData = JsonUtility.ToJson(temp); saveData.currentMission = currentMission; saveData.currentStringDisplay = currentStringDisplay; return(saveData); }
public void LoadGame() { NewGame(); //load from file string filePath = path + "/" + gameDataFileName; if (File.Exists(filePath)) { string[] dataAsJson = File.ReadAllLines(filePath); //Stage 1 get Save Data List <SlotSaveData> inventorySaveData = new List <SlotSaveData>(); //Inventory Save Data List <SlotSaveData> storageSaveData = new List <SlotSaveData>(); //Storage Save Data List <FluctuationSaveData> itemDatabaseSaveData = new List <FluctuationSaveData>(); //Item Save Data TickSaveData tickSaveData = new TickSaveData(); //Day Save Data List <CollectionSaveData> collectionSaveData = new List <CollectionSaveData>(); int bankData = 0; MainMissionSaveData mainMissionSaveData = new MainMissionSaveData(); SideMissionManagerSaveData sideMissionSaveData = new SideMissionManagerSaveData(); int phase = 0; for (int i = 0; i < dataAsJson.Length; i++) { string line = dataAsJson[i]; if (line != "BREAK") { switch (phase) { case 0: //invent SlotSaveData tempI = JsonUtility.FromJson <SlotSaveData>(line); inventorySaveData.Add(tempI); break; case 1: //storage SlotSaveData tempS = JsonUtility.FromJson <SlotSaveData>(line); storageSaveData.Add(tempS); break; case 2: //items FluctuationSaveData tempIt = JsonUtility.FromJson <FluctuationSaveData>(line); itemDatabaseSaveData.Add(tempIt); break; case 3: //tick tickSaveData = JsonUtility.FromJson <TickSaveData>(line); break; case 4: //tick bankData = int.Parse(line); break; case 5: //Main Missions mainMissionSaveData = JsonUtility.FromJson <MainMissionSaveData>(line); break; case 6: //Side Missions sideMissionSaveData = JsonUtility.FromJson <SideMissionManagerSaveData>(line); break; default: //Plots e.g. anything thats not the first 4 fixed things CollectionSaveData tempC = JsonUtility.FromJson <CollectionSaveData>(line); collectionSaveData.Add(tempC); break; } } else { phase = phase + 1; } }//End for //Stage 2, load inventory.LoadInfo(inventorySaveData); storage.LoadInfo(storageSaveData); itemDatabase.LoadInfo(itemDatabaseSaveData); tickAll.LoadInfo(tickSaveData); bank.LoadGame(bankData); mainMissions.LoadGame(mainMissionSaveData); sideMissions.LoadGame(sideMissionSaveData); for (int i = 0; i < plotCollections.Length; i++) { plotCollections[i].LoadInfo(collectionSaveData[i]); } } }