void Save() { var save = new SaveInfo { Name = ui.SaveName, Player1BenchUnits = GetUnits(playerContext.GetBenchUnitDict(EPlayer.First)), Player1BoardUnits = GetUnits(playerContext.GetBoardUnitDict(EPlayer.First)), Player2BenchUnits = GetUnits(playerContext.GetBenchUnitDict(EPlayer.Second)), Player2BoardUnits = GetUnits(playerContext.GetBoardUnitDict(EPlayer.Second)), }; saveInfoLoader.Save(save); }
public bool Save(SaveInfo save) { //TODO: add confirmation if file already exists try { var path = Path.Combine(Application.dataPath, "Data", "Saves", save.Name + ".json"); var bytes = MessagePackSerializer.Serialize(save); WriteAllBytes(path, bytes); return(true); } catch (Exception e) { Debug.LogError($"e: {e}"); return(false); } }