public static void SaveGame(Game game) { var path = Application.persistentDataPath + "/save.json"; Debug.Log($"Saving to ${path}"); var data = JsonUtility.ToJson(SavedGame.Create(game), prettyPrint: true); File.WriteAllText(path, data); }
private Game(Module module, string fileName) { FileName = fileName; Module = module; Data = SavedGame.Create(); Data.Game = this; _entities = new EntityContainer(Module.EntityDefinitions); _entities.AddEntities(() => Data.factions); _entities.AddEntities(() => Data.info_pages); _entities.AddEntities(() => Data.item_kinds); _entities.AddEntities(() => Data.parties); _entities.AddEntities(() => Data.party_templates); _entities.AddEntities(() => Data.quests); _entities.AddEntities(() => Data.scenes); _entities.AddEntities(() => Data.troops); }
public async Task SaveGameAsync(string gameId, int slot, GameState state) { var saveGameRecord = new StoreRecord <SavedGame> { Storename = StoreName, Data = SavedGame.Create(gameId, slot, state) }; if (await SavedGameExists(gameId, slot)) { await _dbManager.UpdateRecord(saveGameRecord); } else { await _dbManager.AddRecord(saveGameRecord); } }