예제 #1
0
 void ExecuteShowAchievements()
 {
     BalloonLogManager.Add(BalloonLogEntry.Type.GameOpenAchievements, 0, 0);
     if (Application.isEditor)
     {
         ShortMessage.instance.Show("Achievements not supported in Editor");
     }
     else
     {
         Social.ShowAchievementsUI();
     }
 }
예제 #2
0
 void ExecuteShowLeaderboard()
 {
     BalloonLogManager.Add(BalloonLogEntry.Type.GameOpenLeaderboard, 0, 0);
     if (Application.isEditor)
     {
         ShortMessage.instance.Show("Leaderboard not supported in Editor");
     }
     else
     {
         Social.ShowLeaderboardUI();
     }
 }
예제 #3
0
    public static bool SaveBalloonSaveData2(BalloonSaveData2 balloonSaveData2)
    {
        var binFormatter = new BinaryFormatter();
        var memStream    = new MemoryStream();

        //SushiDebug.LogFormat("Start Saving JSON Data: {0}", JsonUtility.ToJson(balloonSaveData2));
        binFormatter.Serialize(memStream, balloonSaveData2);
        var saveDataArray = memStream.ToArray();

        SushiDebug.LogFormat("Saving path: {0}", SaveFileName);
        if (lastSaveDataArray != null && lastSaveDataArray.SequenceEqual(saveDataArray))
        {
            SushiDebug.LogFormat("Saving skipped since there is no difference made compared to last time saved.");
        }
        else
        {
            try
            {
                // 진짜 쓰자!!
                File.WriteAllBytes(SaveFileName, saveDataArray);

                // 마지막 저장 데이터 갱신
                lastSaveDataArray = saveDataArray;
                SushiDebug.Log($"{SaveFileName} Saved. (written to disk)");

                // 유저 서비스를 위해 필요할 수도 있으니까 개발 중일 때는 base64 인코딩 버전 세이브 파일도 저장한다.
                // 실서비스 버전에서는 불필요한 기능이다.
                if (Application.isEditor)
                {
                    var base64Path = SaveFileName + ".base64.txt";
                    SushiDebug.LogFormat("Saving path (base64): {0}", base64Path);
                    File.WriteAllText(base64Path, Convert.ToBase64String(saveDataArray));
                    SushiDebug.Log($"{base64Path} Saved. (written to disk)");
                }

                IncreaseSaveDataSlotAndWrite();
                BalloonLogManager.Add(BalloonLogEntry.Type.GameSaved, 0, 0);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                Debug.LogError("Writing to disk failed!!!");
                ConfirmPopup.instance.Open("Writing to disk failed!!!");
                BalloonLogManager.Add(BalloonLogEntry.Type.GameSaveFailure, 0, 0);
                return(false);
            }
        }

        return(true);
    }
예제 #4
0
    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;
    }
예제 #5
0
    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);
        }
    }
예제 #6
0
    public static void LoadDataAndLoadSplashScene(RemoteSaveDictionary dict)
    {
        // 모든 저장 파일을 지운다.
        SaveLoadManager.DeleteAllSaveFiles();
        // 그 다음 쓴다.
        foreach (var fileName in dict)
        {
            var filePath = Path.Combine(Application.persistentDataPath, fileName.Key);
            SushiDebug.Log(
                $"LoadDataAndLoadSplashScene: gd key = {fileName.Key}, length = {fileName.Value.Length:n0}, writing to = {filePath}");
            File.WriteAllBytes(filePath, fileName.Value);
        }

        SushiDebug.Log("LoadCloudDataAndSave");
        BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudLoadEnd, 0, 0);
        SceneManager.LoadScene("Splash");
    }
예제 #7
0
    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);
        }
    }
예제 #8
0
    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);
        }
    }
예제 #9
0
    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
    }
예제 #10
0
    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
    }
예제 #11
0
        public List <BalloonLogEntry> Read(int logEntryStartIndex, int count)
        {
            var logEntryList       = new List <BalloonLogEntry>();
            var dummyLogEntryBytes = BalloonLogManager.GetLogEntryBytes(BalloonLogEntry.Type.DummyLogRecord, 0, 0);

            readLogStream.Seek(logEntryStartIndex * dummyLogEntryBytes.Length, SeekOrigin.Begin);
            var bytes         = new byte[count * dummyLogEntryBytes.Length];
            var readByteCount = readLogStream.Read(bytes, 0, bytes.Length);
            var offset        = 0;

            for (var i = 0; i < readByteCount / dummyLogEntryBytes.Length; i++)
            {
                logEntryList.Add(new BalloonLogEntry
                {
                    ticks = BitConverter.ToInt64(bytes, offset + 0),
                    type  = BitConverter.ToInt32(bytes, offset + 0 + 8),
                    arg1  = BitConverter.ToInt32(bytes, offset + 0 + 8 + 4),
                    arg2  = BitConverter.ToInt64(bytes, offset + 0 + 8 + 4 + 4)
                });
                offset += dummyLogEntryBytes.Length;
            }

            return(logEntryList);
        }
예제 #12
0
        public long Count()
        {
            var dummyLogEntryBytes = BalloonLogManager.GetLogEntryBytes(BalloonLogEntry.Type.DummyLogRecord, 0, 0);

            return(readLogStream.Length / dummyLogEntryBytes.Length);
        }
예제 #13
0
 void Awake()
 {
     instance       = this;
     writeLogStream = File.Open(LogFilePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
 }
예제 #14
0
    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();
            }
        });
    }
예제 #15
0
 public static void CancelStartLoginForSave()
 {
     ConfirmPopup.instance.Open(TextHelper.GetText("platform_save_cancelled_popup"));
     BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudSaveFailure, 0, 0);
 }
예제 #16
0
 public static void ShowSaveResultPopup()
 {
     ProgressMessage.instance.Close();
     ConfirmPopup.instance.Open(TextHelper.GetText("platform_saved_popup"));
     BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudSaveEnd, 0, 0);
 }
예제 #17
0
 public static void NoDataToLoad()
 {
     ConfirmPopup.instance.Open(TextHelper.GetText("platform_cloud_load_fail"));
     BalloonLogManager.Add(BalloonLogEntry.Type.GameCloudLoadFailure, 0, 1);
 }