Ejemplo n.º 1
0
    IEnumerator Start()
    {
        while (true)
        {
            yield return(new WaitForSeconds(3.0f));

            // 1초 간격으로 리포트하니까 그 사이 queuedScoreDict가 바뀌어 있을 수도 있다.
            // 복사해서 써야한다.
            foreach (var kv in new Dictionary <string, long>(queuedScoreDict))
            {
                SushiDebug.Log($"Social.ReportScore {kv.Key}: {kv.Value}...");
                if (!Application.isEditor)
                {
                    Social.ReportScore(kv.Value, kv.Key, success =>
                    {
                        SushiDebug.Log($"Social.ReportScore {kv.Key}: {kv.Value} (Result:{success})");
                        if (success)
                        {
                            successfullyReportedScoreDict[kv.Key] = kv.Value;
                        }
                    });
                }
                else
                {
                    SushiDebug.Log($"Social.ReportScore {kv.Key}: {kv.Value} (Result:EDITOR MODE)");
                    successfullyReportedScoreDict[kv.Key] = kv.Value;
                }

                yield return(new WaitForSeconds(1.0f));
            }

            queuedScoreDict.Clear();
        }
    }
Ejemplo n.º 2
0
    public void RegisterAllNotifications(string title, string body, string largeIcon)
    {
        var notificationDate0000 = DateTime.Today;
        var now = DateTime.Now;
        var notificationDate0900 = notificationDate0000.AddHours(9);

        if (notificationDate0900 < now)
        {
            notificationDate0900 = notificationDate0900.AddDays(1);
        }

#if UNITY_IOS
        string text = string.Format("{0}\n{1}", title, body);
        SushiDebug.Log("Schedule Local Notification");
        UnityEngine.iOS.NotificationServices.ClearLocalNotifications();
        UnityEngine.iOS.NotificationServices.CancelAllLocalNotifications();
        ClearAllNotifications();

        // 09:00
        UnityEngine.iOS.LocalNotification notification0900 = new UnityEngine.iOS.LocalNotification();
        notification0900.fireDate       = notificationDate0900;
        notification0900.alertBody      = text;
        notification0900.alertAction    = "Action";
        notification0900.soundName      = UnityEngine.iOS.LocalNotification.defaultSoundName;
        notification0900.repeatInterval = UnityEngine.iOS.CalendarUnit.Day;
        UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(notification0900);
#endif
    }
Ejemplo n.º 3
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;
         }
     }
 }
Ejemplo n.º 4
0
    IEnumerator HandleRewardBasedVideoFailedToLoadCoro(AdFailedToLoadEventArgs args)
    {
        yield return(null);

        SushiDebug.Log("HandleRewardBasedVideoFailedToLoad event received with message: " + args.Message);
        PlatformAdMobAds.HandleFailedToLoad();
    }
Ejemplo n.º 5
0
    IEnumerator HandleAdOpenedCoro(EventArgs args)
    {
        yield return(null);

        SushiDebug.Log("HandleAdClosedCoro event received");
        BalloonSound.instance.StopTimeAndMuteAudioMixer();
    }
Ejemplo n.º 6
0
    public void QueueScore(string key, long value, string desc)
    {
        if (Application.isEditor)
        {
            //SushiDebug.Log($"Editor Mode: Try to queue score... {key}: {value} ({desc})");
        }

        long oldValue = 0;

        if (successfullyReportedScoreDict.TryGetValue(key, out oldValue) && oldValue == value)
        {
            // 앱이 실행된 이후 성공적으로 등록했던 점수와 동일하다면 다시 할 필요는 없다.
        }
        else
        {
            if (BalloonSpawner.instance.cheatMode)
            {
                if (notifyCheatModeOnlyOnce == false)
                {
                    SushiDebug.Log("### Cheat Mode was turned on (notified only at the first time)");
                    SushiDebug.Log($"ReportScore: {key}: {value} ({desc})");
                    notifyCheatModeOnlyOnce = true;
                }

                return;
            }

            queuedScoreDict[key] = value;
        }
    }
Ejemplo n.º 7
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.º 8
0
    internal static void DeleteSaveFileAndReloadScene()
    {
        // From MSDN: If the file to be deleted does not exist, no exception is thrown.
        SushiDebug.Log("DeleteSaveFileAndReloadScene");
        DeleteAllSaveFiles();

        SceneManager.LoadScene("Splash");
    }
Ejemplo n.º 9
0
    IEnumerator HandleAdClosedCoro()
    {
        yield return(null);

        SushiDebug.Log("HandleAdClosedCoro event received");
        PlatformAds.HandleRewarded_Video(null, null, PlatformAds.AdsType.AdMob);
        BalloonSound.instance.ResumeToNormalTimeAndResumeAudioMixer();
    }
Ejemplo n.º 10
0
    IEnumerator HandleRewardBasedVideoOpenedCoro(EventArgs args)
    {
        yield return(null);

        SushiDebug.Log("HandleRewardBasedVideoOpened event received");
        shouldBeRewarded = false;
        BalloonSound.instance.StopTimeAndMuteAudioMixer();
    }
Ejemplo n.º 11
0
    void Start()
    {
        SushiDebug.Log("PlatformUnityAdsInit.Start()");
#if UNITY_ANDROID || UNITY_IOS
        //Advertisement.debugMode = true;
        Advertisement.Initialize(gameID, false);
#endif
    }
Ejemplo n.º 12
0
 public void Close()
 {
     SushiDebug.Log("Subcanvas.Close()");
     if (canvas.enabled)
     {
         canvas.enabled = false;
         SendPopupEventMessage();
     }
 }
Ejemplo n.º 13
0
 public void StopTimeAndMuteAudioMixer()
 {
     SushiDebug.Log("StopTimeAndMuteAudioMixer() called.");
     if (Time.timeScale != 1)
     {
         Debug.LogError("Time.timeScale expected to be 1 at this moment!");
     }
     Time.timeScale = 0;
     audioMixer.SetFloat("MasterVolume", -80.0f);
 }
Ejemplo n.º 14
0
    IEnumerator HandleRewardBasedVideoRewardedCoro(Reward args)
    {
        yield return(null);

        var type   = args.Type;
        var amount = args.Amount;

        SushiDebug.Log("HandleRewardBasedVideoRewarded event received for " + amount + " " + type);
        shouldBeRewarded = true;
    }
Ejemplo n.º 15
0
    // 저장 슬롯 감소 (불러오기 실패 후 항상 1씩 감소되어야 함)
    public static void DecreaseSaveDataSlotAndWrite()
    {
        var oldSaveDataSlot = GetSaveSlot();
        var newSaveDataSlot = PositiveMod(oldSaveDataSlot - 1, maxSaveDataSlot);

        SushiDebug.Log($"Decrease save data slot from {oldSaveDataSlot} to {newSaveDataSlot}...");
        PlayerPrefs.SetInt(saveDataSlotKey, newSaveDataSlot);
        PlayerPrefs.Save();
        SushiDebug.Log($"Decrease save data slot from {oldSaveDataSlot} to {newSaveDataSlot}... OKAY");
    }
Ejemplo n.º 16
0
    IEnumerator HandleRewardBasedVideoClosedCoro(EventArgs args)
    {
        yield return(null);

        SushiDebug.Log("HandleRewardBasedVideoClosed event received");
        RequestRewardBasedVideo();
        if (shouldBeRewarded) // Workaround for processing result in main thread
        {
            StartCoroutine(HandleRewarded());
        }
        BalloonSound.instance.ResumeToNormalTimeAndResumeAudioMixer();
    }
Ejemplo n.º 17
0
    /// <summary>
    ///     Shares multiple files at once
    /// </summary>
    /// <param name="body"></param>
    /// <param name="filePaths">The paths to the attached files</param>
    /// <param name="url"></param>
    /// <param name="subject"></param>
    /// <param name="mimeType"></param>
    /// <param name="chooser"></param>
    /// <param name="chooserText"></param>
    public static void ShareMultiple(string body, string[] filePaths = null, string url = null, string subject      = "",
                                     string mimeType = "text/html", bool chooser        = false, string chooserText = "Select sharing app")
    {
#if UNITY_ANDROID
        ShareAndroid(body, subject, url, filePaths, mimeType, chooser, chooserText);
#elif UNITY_IOS
        ShareIOS(body, subject, url, filePaths);
#else
        SushiDebug.Log("No sharing set up for this platform.");
        SushiDebug.Log("Subject: " + subject);
        SushiDebug.Log("Body: " + body);
#endif
    }
Ejemplo n.º 18
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);
    }