Ejemplo n.º 1
0
 public void ShareScreenshot(byte[] pngData)
 {
     SushiDebug.LogFormat("ShareScreenshot: pngData length {0} bytes", pngData.Length);
     var screenshotFileName = "screenshot.png";
     File.WriteAllBytes(screenshotFileName, pngData);
     SushiDebug.Log($"ShareScreenshot: successfully written to {screenshotFileName}");
 }
Ejemplo n.º 2
0
 public void StartLogin()
 {
     //rootCanvasGroup.interactable = false;
     try
     {
         Platform.StartAuthAsync((result, reason) =>
         {
             if (rootCanvasGroup != null)
             {
                 rootCanvasGroup.interactable = true;
             }
             SushiDebug.LogFormat("Social.localUser.Authenticate {0}", result);
             if (result)
             {
                 SushiDebug.LogFormat("Social.localUser userName={0}, userId={1}", Social.localUser.userName,
                                      Social.localUser.id);
                 if (userName)
                 {
                     userName.text = Social.localUser.userName;
                 }
                 if (userId)
                 {
                     userId.text = Social.localUser.id;
                 }
             }
         });
     }
     catch
     {
         if (rootCanvasGroup != null)
         {
             rootCanvasGroup.interactable = true;
         }
     }
 }
    // Unity API의 한계로 함수 인자는 string 하나만 쓸 수 있다.
    void OnIosLoadResult(string result)
    {
        if (result.StartsWith("*****ERROR***** "))
        {
            Platform.instance.OnCloudLoadResult(result, null);
        }
        else
        {
            SushiDebug.LogFormat("PlatformCallbackHandler.OnIosLoadResult: {0}", result != null ? result : "(null)");
            byte[] loadedDataBytes = null;
            if (result != null)
            {
                try
                {
                    loadedDataBytes = Convert.FromBase64String(result);
                }
                catch
                {
                    loadedDataBytes = null;
                }
            }

            Platform.instance.OnCloudLoadResult("OK", loadedDataBytes);
        }
    }
Ejemplo n.º 4
0
    public static void TryShowRewardedAd(ShopProductEntry shopProductEntry, ShopProductData shopProductData)
    {
#if GOOGLE_MOBILE_ADS
        // Get singleton reward based video ad reference.
        var rewardBasedVideo = RewardBasedVideoAd.Instance;

        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            ConfirmPopup.instance.Open(string.Format("\\인터넷 연결이 필요합니다.".Localized()));
        }
        else if (rewardBasedVideo.IsLoaded())
        {
            PlatformAdMobAds.shopProductEntry = shopProductEntry;
            PlatformAdMobAds.shopProductData  = shopProductData;
            SushiDebug.LogFormat("ShowRewardedAd: shopProductEntry: {0}", shopProductEntry);
            SushiDebug.LogFormat("ShowRewardedAd: shopProductData: {0}", shopProductData);
            rewardBasedVideo.Show();
        }
        else
        {
            Debug.LogError("Ad not ready!");
            ConfirmPopup.instance.Open(string.Format("\\광고가 아직 준비되지 않았습니다.".Localized()));
        }
#endif
    }
Ejemplo n.º 5
0
        public async Task LoadPlayLogAsync(string playLogCode)
        {
            var saveDbUrl = ConfigPopup.BaseUrl + "/playLog";

            ProgressMessage.instance.Open("Loading play log");
            playLogCode = playLogCode.Trim();
            var url = string.Format("{0}/{1}", saveDbUrl, playLogCode);

            SushiDebug.LogFormat("URL: {0}", url);

            try
            {
                using (var httpClient = new HttpClient())
                {
                    var getTask = await httpClient.GetAsync(url);

                    if (getTask.IsSuccessStatusCode)
                    {
                        var text = await getTask.Content.ReadAsStringAsync();

                        var userPlayLogDataRoot                      = Json.Deserialize(text) as Dict;
                        var userPlayLogDataFields                    = userPlayLogDataRoot["fields"] as Dict;
                        var userPlayLogDataFieldsSaveData            = userPlayLogDataFields["playLogData"] as Dict;
                        var userPlayLogDataFieldsSaveDataStringValue =
                            userPlayLogDataFieldsSaveData["bytesValue"] as string;
                        var userPlayLogUncompressedSizeData =
                            userPlayLogDataFields["playLogUncompressedSizeData"] as Dict;
                        var userPlayLogUncompressedSizeDataIntegerValue =
                            int.Parse(userPlayLogUncompressedSizeData["integerValue"] as string);

                        var playLogDataBase64       = userPlayLogDataFieldsSaveDataStringValue;
                        var playLogData             = Convert.FromBase64String(playLogDataBase64);
                        var playLogUncompressedData = new byte[userPlayLogUncompressedSizeDataIntegerValue];
                        LZ4Codec.Decode(playLogData, 0, playLogData.Length, playLogUncompressedData, 0,
                                        playLogUncompressedData.Length);

                        readLogStream = new MemoryStream(playLogUncompressedData);

                        SushiDebug.LogFormat("Play Log Data Base64 ({0} bytes): {1}",
                                             playLogDataBase64 != null ? playLogDataBase64.Length : 0, playLogDataBase64);
                        SushiDebug.LogFormat("Play Log Data ({0} bytes - compresseed)", playLogData.Length);
                    }
                    else
                    {
                        Debug.LogError($"Loading play log failed - status code {getTask.StatusCode}");
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError($"Play log upload exception: {e}");
            }
            finally
            {
                // 어떤 경우가 됐든지 마지막으로는 진행 상황 창을 닫아야 한다.
                ProgressMessage.instance.Close();
            }
        }
Ejemplo n.º 6
0
 public static void DeleteAllCaches()
 {
     SushiDebug.LogFormat("Deleting invalid cache file {0}...", BalloonBytesPath);
     File.Delete(BalloonBytesPath);
     SushiDebug.LogFormat("Deleting invalid cache file {0}...", BalloonBytesETagPath);
     File.Delete(BalloonBytesETagPath);
     SushiDebug.LogFormat("Deleting invalid cache file {0}...", BalloonBytesHashPath);
     File.Delete(BalloonBytesETagPath);
 }
Ejemplo n.º 7
0
    public static IEnumerator ReportCorruptSaveFileSendCoroutine(string guid, string reportJsonStr)
    {
        using (var request = UnityWebRequest.Put(string.Format(saveUrlFormat, guid), reportJsonStr))
        {
            yield return(request.SendWebRequest());
        }

        SushiDebug.LogFormat("ReportCorruptSaveFile report finished. GUID {0}", guid);
    }
Ejemplo n.º 8
0
 public static void HandleRewarded_Video(ShopProductEntry shopProductEntry, ShopProductData shopProductData,
                                         AdsType adsType)
 {
     SushiDebug.Log("The ad was successfully shown. (Video)");
     SushiDebug.LogFormat("HandleShowResult: shopProductEntry: {0}", shopProductEntry);
     SushiDebug.LogFormat("HandleShowResult: shopProductData: {0}", shopProductData);
     // 이번 스테이지를 처음부터 새로 시작한다.
     LoadStageFromStart(stageNumber);
 }
Ejemplo n.º 9
0
 public void PostLeaderboardScore2()
 {
     //rootCanvasGroup.interactable = false;
     leaderboardScore2++;
     Social.ReportScore(leaderboardScore2, "CgkI87XJzNYNEAIQBA", success =>
     {
         SushiDebug.LogFormat("PostLeaderboardScore2 result: {0}, score: {1}", success, leaderboardScore2);
         //rootCanvasGroup.interactable = true;
     });
 }
Ejemplo n.º 10
0
    public void UnlockAchievement2()
    {
        //rootCanvasGroup.interactable = false;
        var id = Application.platform == RuntimePlatform.Android ? "CgkI87XJzNYNEAIQAQ" : "share_screenshot2";

        Social.ReportProgress(id, 100.0f, success =>
        {
            SushiDebug.LogFormat("Unlock achievement 2 result: {0}", success);
            //rootCanvasGroup.interactable = true;
        });
    }
Ejemplo n.º 11
0
 public static void HandleRewarded_RewardedVideo(ShopProductEntry shopProductEntry, ShopProductData shopProductData,
                                                 AdsType adsType)
 {
     SushiDebug.Log("The ad was successfully shown. (Rewarded Video)");
     SushiDebug.LogFormat("HandleShowResult: shopProductEntry: {0}", shopProductEntry);
     SushiDebug.LogFormat("HandleShowResult: shopProductData: {0}", shopProductData);
     // 체크포인트부터 이어서 플레이한다.
     // HotairBalloon.initialPositionY를 리셋하지 않으면
     // 이어서 되도록 해 놓았다.
     Bootstrap.ReloadCurrentScene();
 }
Ejemplo n.º 12
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);
    }
Ejemplo n.º 13
0
 public static Stream GetBalloonDataStream()
 {
     try
     {
         var stream = new MemoryStream(File.ReadAllBytes(BalloonBytesPath));
         SushiDebug.Log("GetBalloonDataStream(): returning cached remote datasheet");
         return(stream);
     }
     catch (Exception e)
     {
         SushiDebug.LogFormat("Something went wrong while accessing cached remote datasheet: {0}", e.ToString());
         DeleteAllCaches();
         return(GetBuiltInBalloonDataStream());
     }
 }
Ejemplo n.º 14
0
    public void OnSavedGameSelected(SelectUIStatus status, ISavedGameMetadata game)
    {
        if (status == SelectUIStatus.SavedGameSelected)
        {
            // handle selected game save
            SushiDebug.LogFormat("Save game selection selected! Selected save filename: {0}", game.Filename);
            ShortMessage.instance.Show("ERROR: Not supported");
        }
        else
        {
            // handle cancel or error
            SushiDebug.LogFormat("Save game selection canceled! - {0}", status);
        }

        //rootCanvasGroup.interactable = true;
    }
Ejemplo n.º 15
0
    public void OnSavedGameWritten(SavedGameRequestStatus status, ISavedGameMetadata game)
    {
        if (status == SavedGameRequestStatus.Success)
        {
            // handle reading or writing of saved game.

            SushiDebug.LogFormat("OnSavedGameWritten success!");
        }
        else
        {
            // handle error

            SushiDebug.LogFormat("OnSavedGameWritten failed! - {0}", status);
        }

        //rootCanvasGroup.interactable = true;
    }
Ejemplo n.º 16
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);
        }
    }
Ejemplo n.º 17
0
    public void OnSavedGameDataRead(SavedGameRequestStatus status, byte[] data)
    {
        if (status == SavedGameRequestStatus.Success)
        {
            // handle processing the byte array data

            SushiDebug.LogFormat("OnSavedGameDataRead success! - Data: " + Encoding.UTF8.GetString(data));
        }
        else
        {
            // handle error

            SushiDebug.LogFormat("OnSavedGameDataRead failed! - {0}", status);
        }

        //rootCanvasGroup.interactable = true;
    }
Ejemplo n.º 18
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);
        }
    }
Ejemplo n.º 19
0
    static void GatherAllStaticLocalizedTextRef()
    {
        List <string> textRefList = new List <string>();

        foreach (var root in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects())
        {
            foreach (var staticLocalizedText in root.GetComponentsInChildren <StaticLocalizedText>(true))
            {
                //var strRefLiteral = ToLiteral(staticLocalizedText.StrRef);
                //textRefList.Add(strRefLiteral.Substring(1, strRefLiteral.Length - 2));
                textRefList.Add(staticLocalizedText.StrRef);
            }
        }
        textRefList = textRefList.Distinct().ToList();
        textRefList.Sort();
        File.WriteAllLines("textref.txt", textRefList.ToArray());
        SushiDebug.LogFormat("textref.txt written: {0} items", textRefList.Count);
    }
Ejemplo n.º 20
0
    //public void DeleteGameData(string filename)
    //{
    //    // Open the file to get the metadata.
    //    ISavedGameClient savedGameClient = PlayGamesPlatform.Instance.SavedGame;
    //    savedGameClient.OpenWithAutomaticConflictResolution(filename, DataSource.ReadCacheOrNetwork,
    //        ConflictResolutionStrategy.UseLongestPlaytime, DeleteSavedGame);
    //}

    public void DeleteSavedGame(SavedGameRequestStatus status, ISavedGameMetadata game)
    {
#if !NO_GPGS
        if (status == SavedGameRequestStatus.Success)
        {
            var savedGameClient = PlayGamesPlatform.Instance.SavedGame;
            savedGameClient.Delete(game);

            SushiDebug.LogFormat("DeleteSavedGame success!");
        }
        else
        {
            // handle error

            SushiDebug.LogFormat("DeleteSavedGame failed! - {0}", status);
        }
#endif
    }
Ejemplo n.º 21
0
    public void ScheduleNotification()
    {
        var notificationDate0000 = DateTime.Today;
        var now = DateTime.Now;
        var notificationDate1200 = notificationDate0000.AddHours(12);
        var notificationDate1800 = notificationDate0000.AddHours(18);

        if (notificationDate1200 < now)
        {
            notificationDate1200 = notificationDate1200.AddDays(1);
        }
        if (notificationDate1800 < now)
        {
            notificationDate1800 = notificationDate1800.AddDays(1);
        }
        SushiDebug.LogFormat("Notification Time 1: {0}", notificationDate1200);
        SushiDebug.LogFormat("Notification Time 2: {0}", notificationDate1800);
#if UNITY_IOS
        SushiDebug.Log("Schedule Local Notification");
        UnityEngine.iOS.NotificationServices.ClearLocalNotifications();
        UnityEngine.iOS.NotificationServices.CancelAllLocalNotifications();
                #if !UNITY_EDITOR
        clearAllNotifications();
                #endif

        UnityEngine.iOS.LocalNotification notification1200 = new UnityEngine.iOS.LocalNotification();
        notification1200.fireDate       = notificationDate1200;
        notification1200.alertBody      = "Message";
        notification1200.alertAction    = "Action";
        notification1200.soundName      = UnityEngine.iOS.LocalNotification.defaultSoundName;
        notification1200.repeatInterval = UnityEngine.iOS.CalendarUnit.Day;
        UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(notification1200);

        UnityEngine.iOS.LocalNotification notification1800 = new UnityEngine.iOS.LocalNotification();
        notification1800.fireDate       = notificationDate1800;
        notification1800.alertBody      = "Message";
        notification1800.alertAction    = "Action";
        notification1800.soundName      = UnityEngine.iOS.LocalNotification.defaultSoundName;
        notification1800.repeatInterval = UnityEngine.iOS.CalendarUnit.Day;
        UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(notification1800);
#endif
    }
Ejemplo n.º 22
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);
        }
    }
Ejemplo n.º 23
0
    public void GetCloudLastSavedMetadataAsync(Action <CloudMetadata> onPeekResult)
    {
        if (!Social.localUser.authenticated)
        {
            SushiDebug.LogFormat("GetCloudSavedAccountData: not authenticated");
            if (onPeekResult != null)
            {
                onPeekResult(CloudMetadata.Invalid);
            }
            return;
        }

        // 아래 함수의 호출 결과는 결과는 PlatformCallbackHandler GameObject의
        // PlatformCallbackHandler.OnIosLoadResult()로 비동기적으로 호출되는 것으로 처리한다.
        // 이를 위해 onPeekResult를 챙겨둔다.
        onPeekResultSave = onPeekResult;
#if UNITY_IOS
        PlatformIosNative.loadFromCloudPrivate(Social.localUser.id, LoginErrorTitle, LoginErrorMessage, ConfirmMessage);
#endif
    }
Ejemplo n.º 24
0
    public void OnSavedGameOpenedAndWrite(SavedGameRequestStatus status, ISavedGameMetadata game)
    {
        if (status == SavedGameRequestStatus.Success)
        {
            // handle reading or writing of saved game.

            SushiDebug.LogFormat("Save game open (write) success! Filename: {0}", game.Filename);

            daysPlayed++;

            SaveGame(game, Encoding.UTF8.GetBytes("Hello save file world!" + DateTime.Now),
                     TimeSpan.FromDays(daysPlayed));
        }
        else
        {
            // handle error
            SushiDebug.LogFormat("Save game open (write) failed! - {0}", status);
            //rootCanvasGroup.interactable = true;
        }
    }
Ejemplo n.º 25
0
    public static bool Save(BalloonSpawner spawner, ConfigPopup configPopup, BalloonSound sound, Data data,
                            SaveReason sr)
    {
        // 에디터에서 간혹 게임 플레이 시작할 때 Load도 호출되기도 전에 Save가 먼저 호출되기도 한다.
        // (OnApplicationPause 통해서)
        // 실제 기기에서도 이럴 수 있나? 이러면 망인데...
        // 그래서 플래그를 하나 추가한다. 이 플래그는 로드가 제대로 한번 됐을 때 true로 변경된다.
        if (spawner.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 balloonSaveData2 = new BalloonSaveData2();

        SushiDebug.LogFormat("Saving...");
        balloonSaveData2.version = LatestVersion;

        return(SaveBalloonSaveData2(balloonSaveData2));
    }
Ejemplo n.º 26
0
    public void OnSavedGameOpenedAndRead(SavedGameRequestStatus status, ISavedGameMetadata game)
    {
#if !NO_GPGS
        if (status == SavedGameRequestStatus.Success)
        {
            // handle reading or writing of saved game.

            SushiDebug.LogFormat("Save game open (read) success! Filename: {0}", game.Filename);

            daysPlayed++;

            LoadGameData(game);
        }
        else
        {
            // handle error
            SushiDebug.LogFormat("Save game open (read) failed! - {0}", status);

            //rootCanvasGroup.interactable = true;
        }
#endif
    }
Ejemplo n.º 27
0
    IEnumerator CaptureScreenshotCoro()
    {
        if (Application.isEditor)
        {
            ScreenCapture.CaptureScreenshot(Application.persistentDataPath + "/" + filename);
        }
        else
        {
            ScreenCapture.CaptureScreenshot(filename);
        }
        SushiDebug.LogFormat("Captured!");
        var info = new FileInfo(Application.persistentDataPath + "/" + filename);

        while (info == null || info.Exists == false)
        {
            info = new FileInfo(Application.persistentDataPath + "/" + filename);
            yield return(null);
        }

        SushiDebug.LogFormat("Screenshot saved successfully! Size={0}, Path={1}", info.Length, info.FullName);
#if !UNITY_EDITOR
        NativeShare.Share("body", info.FullName, null, "subject", "image/png", true, "Select sharing app");
#endif
    }
Ejemplo n.º 28
0
    void AuthenticateCallback(Action <bool, string> onAuthResult, bool b, string reason)
    {
        // Game Center 로그인 성공/실패 유무에 따른 플래그 업데이트
        PlayerPrefs.SetInt(GAME_CENTER_LOGIN_FAILED_FLAG_PREF_KEY, b ? 0 : 1);

        SushiDebug.LogFormat("iOS Game Center Login Result: {0} / Reason: {1}", b, reason);

        // 회수 제한 마지막 기회임을 체크해서 다시는 시도하지 않도록 한다.
        // 그런데... reason은 유저가 읽을 수 있도록 시스템 언어 설정에 따라
        // 같은 결과라도 언어별로 값이 다르다. ㄷㄷㄷ
        // 그러므로 GAME_CENTER_LOGIN_DISABLED_FLAG_PREF_KEY 플래그를 올리는 것은
        // 제대로 작동하지 않는다. (언어별로 정상 작동 여부가 달라진다.)
        // 아직은 고치지 않고 그래두 두겠다...
        if (b == false && reason.Contains("canceled") && reason.Contains("disabled"))
        {
            PlayerPrefs.SetInt(GAME_CENTER_LOGIN_DISABLED_FLAG_PREF_KEY, 1);
        }
        else if (b)
        {
            PlayerPrefs.SetInt(GAME_CENTER_LOGIN_DISABLED_FLAG_PREF_KEY, 0);
        }
        PlayerPrefs.Save();

        onAuthResult(b, reason);

#if UNITY_IOS
        // 로그인 이후 알림 기능에 대한 동의 팝업을 띄우자...
        UnityEngine.iOS.NotificationServices.RegisterForNotifications(UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound);

        // 로그인 성공했다면 업적 알림 기능 켜기
        if (b)
        {
            UnityEngine.SocialPlatforms.GameCenter.GameCenterPlatform.ShowDefaultAchievementCompletionBanner(true);
        }
#endif
    }
Ejemplo n.º 29
0
    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
    }
 // Unity API의 한계로 함수 인자는 string 하나만 쓸 수 있다.
 void OnIosSaveResult(string result)
 {
     SushiDebug.LogFormat("PlatformCallbackHandler.OnIosSaveResult: {0}", result != null ? result : "(null)");
     Platform.instance.OnCloudSaveResult(result);
 }