using System; using System.Collections; using System.Globalization; using UnityEngine; #if UNITY_ANDROID //using Google.Play.Review; #elif UNITY_IOS using UnityEngine.iOS; #endif public class DataCheckMgr : MyCoroutine { private static DataCheckMgr _ins; public static DataCheckMgr Ins { get { if (_ins == null) { _ins = new GameObject("DataCheckMgr").AddComponent(); DontDestroyOnLoad(_ins.gameObject); } return _ins; } } public int NewChapter { get; set; } = 0; public void Set() { StartCoroutine(Co_1Min()); StartCoroutine(Co_1Sec()); } IEnumerator Co_1Min() { //var sdata = ServerInfo.Ins.m_ServerData; while (true) { // 매시간 뉴스 체크 //if (NewsGetTime != ServerInfo.ServerTime.Hour) //{ // ServerInfo.Ins.Get_News(news => // { // NewsGetTime = ServerInfo.ServerTime.Hour; // NoticeUI.list_news = news; // }); //} yield return new WaitForSeconds(60f); } } IEnumerator Co_1Sec() { bool checkinit = false; while (true) { // 게임 접속 중에 다음날이 됐을 때 if (!checkinit && SaveMgr.Ins.Get_DoY() != InternetTime.Ins.Time.DayOfYear) SaveMgr.Ins.DailyCheck(); var woy = SamplesCalendar.Get_WeekOfYear(InternetTime.Ins.Time); if (woy != SaveMgr.Ins.Get_WOY()) SaveMgr.Ins.WeeklyCheck(woy); //if (checkinit && !callinit) //{ // callinit = true; // ServerInfo.Ins.Save_Init(result => // { // checkinit = false; // callinit = false; // if (result.initDaily) sdata.Init_Daily(result.farmshop); // if (result.initWeek) sdata.Init_Week(SamplesCalendar.Get_WeekOfYear(ServerInfo.ServerTime)); // if (result.initMonth) sdata.Init_Month(); // }); //} yield return new WaitForSeconds(1f); } } #region 리뷰 bool showReview; public void Show_Review(Action _act) { if (showReview) return; showReview = true; Set_Coroutine(_act, 1f); #if UNITY_ANDROID #if FGB_OneStore WebViewInfo.Ins.Show_WebView(MyValue.OnestoreURL); #else //var reviewManager = new ReviewManager(); //// start preloading the review prompt in the background //var playReviewInfoAsyncOperation = reviewManager.RequestReviewFlow(); //// define a callback after the preloading is done //playReviewInfoAsyncOperation.Completed += playReviewInfoAsync => //{ // if (playReviewInfoAsync.Error == ReviewErrorCode.NoError) // { // // display the review prompt // var playReviewInfo = playReviewInfoAsync.GetResult(); // reviewManager.LaunchReviewFlow(playReviewInfo); // } // else // { // // handle error when loading review prompt // } //}; #endif #else #if UNITY_IOS Device.RequestStoreReview(); #endif #endif } #endregion } public class SamplesCalendar { public static int Get_WeekOfYear(DateTime _dt) { // Gets the Calendar instance associated with a CultureInfo. CultureInfo myCI = new CultureInfo("ko-KR"); Calendar myCal = myCI.Calendar; // Gets the DTFI properties required by GetWeekOfYear. CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule; DayOfWeek myFirstDOW = DayOfWeek.Monday; return myCal.GetWeekOfYear(_dt, myCWR, myFirstDOW); } }