static void Load(IBlackContext context) { // 모든 세이브 슬롯에 대해 로드를 성공 할 때까지 시도한다. var exceptionList = new List <Exception>(); for (var i = 0; i < maxSaveDataSlot; i++) { try { if (LoadInternal(context)) { // 저장 파일 중 하나는 제대로 읽히긴 했다. if (i != 0) { // 그런데 한번 이상 실패했다면 에러 메시지는 보여준다. Debug.LogError($"Save data rolled back {i} time(s)...!!!"); } // 게임은 속행하면 된다. 롤백이 됐건 안됐건 읽긴 읽었다... return; } // 뭔가 예외 발생에 의한 실패는 아니지만 실패일 수도 있다. // 어쩄든 실패긴 실패. // 이전 슬롯으로 넘어간다. exceptionList.Add(new Exception("Black Save Data Load Exception")); DecreaseSaveDataSlotAndWrite(); } catch (NotSupportedBlackSaveDataVersionException e) { // 지원되지 않는 저장 파일 버전 Debug.LogWarning(e.ToString()); exceptionList.Add(e); DecreaseSaveDataSlotAndWrite(); } }
public static bool Save(IBlackContext context, ConfigPopup configPopup, Sound sound, Data data, StageSaveData wipStageSaveData) { // 에디터에서 간혹 게임 플레이 시작할 때 Load도 호출되기도 전에 Save가 먼저 호출되기도 한다. // (OnApplicationPause 통해서) // 실제 기기에서도 이럴 수 있나? 이러면 망인데... // 그래서 플래그를 하나 추가한다. 이 플래그는 로드가 제대로 한번 됐을 때 true로 변경된다. if (context == null || context.LoadedAtLeastOnce == false) { Debug.LogWarning( "****** Save() called before first Load(). There might be an error during Load(). Save() will be skipped to prevent losing your save data."); return(false); } var blackSaveData = new BlackSaveData { version = LatestVersion, lastClearedStageId = BlackContext.instance.LastClearedStageId, lastClearedStageIdEvent = BlackContext.instance.LastClearedStageIdEvent, goldScUInt128 = BlackContext.instance.Gold, clearedDebrisIndexList = BlackContext.instance.GetDebrisState(), pendingGoldScUInt128 = BlackContext.instance.PendingGold, bgmAudioVolume = 1.0f, sfxAudioVolume = 1.0f, muteBgmAudioSource = Sound.instance.BgmAudioSourceActive == false, muteSfxAudioSource = Sound.instance.SfxAudioSourceActive == false, maxBlackLevelGathered = BlackContext.instance.AchievementGathered.MaxBlackLevel, maxBlackLevelRedeemed = BlackContext.instance.AchievementRedeemed.MaxBlackLevel, maxColoringComboGathered = BlackContext.instance.AchievementGathered.MaxColoringCombo, maxColoringComboRedeemed = BlackContext.instance.AchievementRedeemed.MaxColoringCombo, //stageLockRemainTime = StageDetail.instance.StageLockDetailTime, wipStageSaveData = wipStageSaveData, performanceMode = ConfigPopup.instance.IsPerformanceModeOn, }; return(SaveBlackSaveData(blackSaveData)); }