public void GetCloudLastSavedMetadataAsync(Action<CloudMetadata> onPeekResult) { PlatformSaveUtil.ShowPeekProgressPopup(); if (File.Exists(RemoteSaveFileForEditor)) { var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(File.ReadAllBytes(RemoteSaveFileForEditor)); var cloudMetadata = new CloudMetadata { level = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_KEY), levelExp = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_EXP_KEY), gem = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_GEM_KEY), riceRate = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_RICE_RATE_KEY), saveDate = PlatformSaveUtil.GetInt64FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.SAVE_DATE_KEY) }; onPeekResult(cloudMetadata); } else { onPeekResult(CloudMetadata.Invalid); } }
public void ExecuteCloudLoad() { PlatformSaveUtil.ShowLoadProgressPopup(); var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(File.ReadAllBytes(RemoteSaveFileForEditor)); PlatformSaveUtil.LoadDataAndLoadSplashScene(remoteSaveDict); }
public void ExecuteCloudLoad() { PlatformSaveUtil.ShowLoadProgressPopup(); // GetCloudLastSavedMetadataAsync()의 첫 번째 인자가 null이면 // 게임 데이터 로드로 작동한다. GetCloudLastSavedMetadataAsync(null); }
void SerializeAndSaveGame(ISavedGameMetadata game) { var savedData = PlatformSaveUtil.SerializeSaveData(); var played = TimeSpan.FromSeconds(BalloonSpawner.instance .playTimeSec); // System.TimeSpan.Zero;//NetworkTime.GetNetworkTime() - NetworkTime.BaseDateTime; SaveGame(game, savedData, played); }
// 버그 메일 보내기 (세이브 파일 첨부) 기능을 위한 아래 함수는 Unity 이벤트 핸들러로서 연결되어 있으므로 // Visual Studio에서 참고(레퍼런스) 체크 시 검사되지 않음 // 사용되지 않는 것이 아니므로 삭제하지 말 것... public static void ReportBugByMailSaveFileOnUiThread() { var reportPopupTitle = TextHelper.GetText("platform_report_popup_title"); var mailTo = TextHelper.GetText("platform_report_mail"); var subject = TextHelper.GetText("platform_report_subject"); var text = TextHelper.GetText("platform_report_text"); var saveData = PlatformSaveUtil.SerializeSaveData(); Platform.instance.Report(reportPopupTitle, mailTo, subject, text, saveData); }
public void OnCloudSaveResult(string result) { if (result == "OK") // handle reading or writing of saved game. { PlatformSaveUtil.ShowSaveResultPopup(); } else // handle error { PlatformSaveUtil.ShowSaveErrorPopup(TextHelper.GetText("platform_cloud_save_fail") + "\n\n" + result); } }
public void ExecuteCloudSave() { SaveLoadManager.Save(BalloonSpawner.instance, ConfigPopup.instance, BalloonSound.instance, Data.instance, SaveLoadManager.SaveReason.BeforeCloudSave); PlatformSaveUtil.ShowSaveProgressPopup(); #pragma warning disable 219 var savedData = PlatformSaveUtil.SerializeSaveData(); #pragma warning restore 219 // 아래 함수의 호출 결과는 결과는 PlatformCallbackHandler GameObject의 // PlatformCallbackHandler.OnIosSaveResult()로 비동기적으로 호출되는 것으로 처리한다. #if UNITY_IOS PlatformIosNative.saveToCloudPrivate(Social.localUser.id, System.Convert.ToBase64String(savedData), LoginErrorTitle, LoginErrorMessage, ConfirmMessage); #endif }
public void ShowAchievements() { if (Platform.instance.CheckLoadSavePrecondition(TextHelper.GetText("platform_logging_in"), () => PlatformSaveUtil.StartLoginAndDoSomething(() => { ConfirmPopup.instance.Close(); ExecuteShowAchievements(); }), ShowLoginFailed) == false) { return; } ExecuteShowAchievements(); ProgressMessage.instance.Close(); }
void ShowSaveResultPopup(byte[] savedData, RemoteSaveDictionary remoteSaveDict, string path) { ProgressMessage.instance.Close(); var text = string.Format( "세이브 완료 - age: {0} sec, size: {1} bytes, accountLevel = {2}, accountLevelExp = {3}, accountGem = {4}, savedDate = {5}, path = {6}", TimeChecker.instance.GetLastSavedTimeTotalSeconds(), savedData.Length, PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_KEY), PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_EXP_KEY), PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_GEM_KEY), PlatformSaveUtil.GetInt64FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.SAVE_DATE_KEY), path ); ConfirmPopup.instance.Open(text); }
public void ExecuteCloudSave() { SaveLoadManager.Save(BalloonSpawner.instance, ConfigPopup.instance, BalloonSound.instance, Data.instance, SaveLoadManager.SaveReason.BeforeCloudSave); PlatformSaveUtil.ShowSaveProgressPopup(); var savedData = PlatformSaveUtil.SerializeSaveData(); using (var f = File.Create(RemoteSaveFileForEditor)) { f.Write(savedData, 0, savedData.Length); } var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(savedData); ShowSaveResultPopup(savedData, remoteSaveDict, RemoteSaveFileForEditor); }
public void OnSavedGameOpenedAndRead(SavedGameRequestStatus status, ISavedGameMetadata game) { if (status == SavedGameRequestStatus.Success) { // handle reading or writing of saved game. SushiDebug.LogFormat("Save game open (read) success! Filename: {0}", game.Filename); LoadGameData(game); } else { // handle error PlatformSaveUtil.ShowLoadErrorPopup("OnSavedGameOpenedAndRead: status != SavedGameRequestStatus.Success"); BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudLoadFailure, 0, 3); } }
public void OnSavedGameWritten(SavedGameRequestStatus status, ISavedGameMetadata game) { if (status == SavedGameRequestStatus.Success) { // handle reading or writing of saved game. PlatformSaveUtil.ShowSaveResultPopup(); } else { // handle error PlatformSaveUtil.ShowSaveErrorPopup(string.Format("OnSavedGameWritten: OnSavedGameWritten failed! - {0}", status)); BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudSaveFailure, 0, 3); } //rootCanvasGroup.interactable = true; }
public void OnSavedGameDataRead(SavedGameRequestStatus status, byte[] data) { if (status == SavedGameRequestStatus.Success) { // handle processing the byte array data SushiDebug.LogFormat("OnSavedGameDataRead success! - Data size: {0} bytes", data.Length); var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(data); PlatformSaveUtil.LoadDataAndLoadSplashScene(remoteSaveDict); } else { // handle error PlatformSaveUtil.ShowLoadErrorPopup("OnSavedGameDataRead: status == SavedGameRequestStatus.Success"); BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudLoadFailure, 0, 4); } }
void SaveGame(ISavedGameMetadata game, byte[] savedData, TimeSpan totalPlaytime) { #if !NO_GPGS var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(savedData); var accountLevel = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_KEY); var accountLevelExp = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_EXP_KEY); var accountGem = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_GEM_KEY); var savedGameClient = PlayGamesPlatform.Instance.SavedGame; var builder = new SavedGameMetadataUpdate.Builder(); builder = builder.WithUpdatedDescription(string.Format("Level {0} / Exp {1} / Gem {2}", accountLevel, accountLevelExp, accountGem)); builder = builder.WithUpdatedPlayedTime(totalPlaytime); var updatedMetadata = builder.Build(); savedGameClient.CommitUpdate(game, updatedMetadata, savedData, OnSavedGameWritten); #endif }
public void OnSavedGameOpenedAndWrite(SavedGameRequestStatus status, ISavedGameMetadata game) { if (status == SavedGameRequestStatus.Success) { // handle reading or writing of saved game. SushiDebug.LogFormat("OnSavedGameOpenedAndWrite: Save game open (write) success! Filename: {0}", game.Filename); SerializeAndSaveGame(game); } else { // handle error PlatformSaveUtil.ShowSaveErrorPopup( string.Format("OnSavedGameOpenedAndWrite: Save game open (write) failed! - {0}", status)); //rootCanvasGroup.interactable = true; BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudSaveFailure, 0, 2); } }
public void ExecuteCloudLoad() { #if !NO_GPGS PlatformSaveUtil.ShowLoadProgressPopup(); var savedGameClient = PlayGamesPlatform.Instance.SavedGame; if (savedGameClient != null) { Open(savedGameClient, true, OnSavedGameOpenedAndReadConflictResolve, OnSavedGameOpenedAndRead); } else { // handle error PlatformSaveUtil.ShowLoadErrorPopup("OnClick_cloudSave: savedGameClient null"); BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudLoadFailure, 0, 2); } #endif }
public void ExecuteCloudSave() { #if !NO_GPGS SaveLoadManager.Save(BalloonSpawner.instance, ConfigPopup.instance, BalloonSound.instance, Data.instance, SaveLoadManager.SaveReason.BeforeCloudSave); PlatformSaveUtil.ShowSaveProgressPopup(); var savedGameClient = PlayGamesPlatform.Instance.SavedGame; if (savedGameClient != null) { Open(savedGameClient, true, OnSavedGameOpenedAndWriteConflictResolve, OnSavedGameOpenedAndWrite); } else { PlatformSaveUtil.ShowSaveErrorPopup("OnClick_cloudSave: savedGameClient null"); BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudSaveFailure, 0, 1); } #endif }
public void GetCloudLastSavedMetadataAsync(Action <CloudMetadata> onPeekResult) { if (!Social.localUser.authenticated) { SushiDebug.LogFormat("GetCloudSavedAccountData: not authenticated"); onPeekResult(CloudMetadata.Invalid); return; } #if !NO_GPGS var savedGameClient = PlayGamesPlatform.Instance.SavedGame; if (savedGameClient != null) { Open(savedGameClient, true, OnSavedGameOpenedAndReadConflictResolve, (status, game) => { if (status == SavedGameRequestStatus.Success) { // handle reading or writing of saved game. SushiDebug.LogFormat("GetCloudSavedAccountData: Save game open (read) success! Filename: {0}", game.Filename); savedGameClient.ReadBinaryData(game, (status2, data2) => { if (status == SavedGameRequestStatus.Success) { // handle processing the byte array data SushiDebug.LogFormat("GetCloudSavedAccountData success! - Data size: {0} bytes", data2.Length); try { var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(data2); var cloudMetadata = new CloudMetadata { level = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_KEY), levelExp = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_EXP_KEY), gem = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_GEM_KEY), riceRate = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_RICE_RATE_KEY), saveDate = PlatformSaveUtil.GetInt64FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.SAVE_DATE_KEY) }; onPeekResult(cloudMetadata); } catch { SushiDebug.LogFormat("GetCloudSavedAccountData: Exception at deserialization"); onPeekResult(CloudMetadata.Invalid); } } else { SushiDebug.LogFormat("GetCloudSavedAccountData: ReadBinaryData error! - {0}", status2); onPeekResult(CloudMetadata.Invalid); } }); } else { PlatformSaveUtil.LogCloudLoadSaveError(string.Format( "GetCloudSavedAccountData: OpenWithAutomaticConflictResolution error! - {0}", status)); onPeekResult(CloudMetadata.Invalid); } }); } else { PlatformSaveUtil.LogCloudLoadSaveError("GetCloudSavedAccountData: savedGameClient null"); onPeekResult(CloudMetadata.Invalid); } #endif }
public void OnCloudLoadResult(string result, byte[] data) { if (result == "OK") { SushiDebug.LogFormat("OnCloudLoadResult: data length {0} bytes", data != null ? data.Length : 0); // 메타데이터 조회의 경우와 실제 세이브 데이터 로딩의 경우를 나눠서 처리 if (onPeekResultSave != null) { SushiDebug.Log("OnCloudLoadResult: onPeekResultSave valid"); var cloudMetadata = CloudMetadata.Invalid; if (data == null || data.Length == 0) { } else { try { var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(data); cloudMetadata = new CloudMetadata { level = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_KEY), levelExp = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_EXP_KEY), gem = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_GEM_KEY), riceRate = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_RICE_RATE_KEY), saveDate = PlatformSaveUtil.GetInt64FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.SAVE_DATE_KEY) }; } catch { cloudMetadata = CloudMetadata.Invalid; } } onPeekResultSave(cloudMetadata); onPeekResultSave = null; } else { SushiDebug.Log("OnCloudLoadResult: onPeekResultSave empty. data load..."); if (data == null || data.Length == 0) { PlatformSaveUtil.ShowLoadErrorPopup("OnCloudLoadResult: Cloud save data corrupted"); } else { SushiDebug.LogFormat("OnCloudLoadResult: success! - Data size: {0} bytes", data.Length); var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(data); PlatformSaveUtil.LoadDataAndLoadSplashScene(remoteSaveDict); } } } else { PlatformSaveUtil.ShowSaveErrorPopup(TextHelper.GetText("platform_cloud_load_fail") + "\n\n" + result); } }
public static void CloudLoad() { BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudLoadBegin, 0, 0); if (instance.CheckLoadSavePrecondition(TextHelper.GetText("platform_loading"), PlatformSaveUtil.StartLoginAndLoad, PlatformSaveUtil.CancelStartLoginForLoad) == false) { return; } instance.GetCloudLastSavedMetadataAsync(cloudMetadata => { ProgressMessage.instance.Close(); SushiDebug.LogFormat("prevAccountLevel = {0}", cloudMetadata.level); SushiDebug.LogFormat("prevAccountLevelExp = {0}", cloudMetadata.levelExp); SushiDebug.LogFormat("prevAccountGem = {0}", cloudMetadata.gem); SushiDebug.LogFormat("prevAccountRiceRate = {0}", cloudMetadata.riceRate); SushiDebug.LogFormat("prevSaveDate = {0}", cloudMetadata.saveDate); if (cloudMetadata.level >= 0 && cloudMetadata.levelExp >= 0 && cloudMetadata.saveDate >= 0) { var overwriteConfirmMsg = TextHelper.GetText("platform_load_confirm_popup", /* {0} */ 0, /* {1} */ cloudMetadata.levelExp.Postfixed(), /* {2} */ cloudMetadata.gem >= 0 ? cloudMetadata.gem.Postfixed() : "???", /* {3} */ cloudMetadata.riceRate >= 0 ? cloudMetadata.riceRate.Postfixed() : "???", /* {4} */ new DateTime(cloudMetadata.saveDate), /* {5} */ 0, /* {6} */ 0, /* {7} */ 0, /* {8} */ 0, /* {9} */ DateTime.Now); ConfirmPopup.instance.OpenYesNoPopup(overwriteConfirmMsg, () => { // 로드하려는 데이터가 현재 플레이하는 것보다 진행이 "덜" 된 것인가? // 경고 한번 더 보여줘야 한다. var rollback = cloudMetadata.level < ResourceManager.instance.accountLevel || cloudMetadata.levelExp < ResourceManager.instance.accountLevelExp || cloudMetadata.gem < ResourceManager.instance.accountGem || cloudMetadata.riceRate < ResourceManager.instance.accountRiceRate; if (rollback) { var msgAgain = TextHelper.GetText("platform_load_confirm_popup_rollback_alert") + "\n\n" + overwriteConfirmMsg; ConfirmPopup.instance.OpenYesNoPopup(msgAgain, instance.ExecuteCloudLoad, PlatformSaveUtil.CancelStartLoginForLoad); } else { instance.ExecuteCloudLoad(); } }, PlatformSaveUtil.CancelStartLoginForLoad); } else { PlatformSaveUtil.NoDataToLoad(); } }); }