Shegotwet/Assets/Scripts/Util/DataCheckMgr.cs

153 lines
5.9 KiB
C#

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<DataCheckMgr>(); 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();
//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;
//Debug.LogFormat("The CalendarWeekRule used for the ko-KR culture is {0}.", myCWR);
//Debug.LogFormat("The FirstDayOfWeek used for the ko-KR culture is {0}.", myFirstDOW);
//Debug.LogFormat("Therefore, the current week is Week {0} of the current year.", myCal.GetWeekOfYear(_dt, myCWR, myFirstDOW));
//DateTime LastDay = new DateTime(_dt.Year, 1, 1);
//Debug.LogFormat("(1,1) There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//LastDay = new DateTime(_dt.Year, 1, 2);
//Debug.LogFormat("(1,2) There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//LastDay = new DateTime(_dt.Year, 6, 30);
//Debug.LogFormat("(6,30)There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//LastDay = new DateTime(_dt.Year, 7, 1);
//Debug.LogFormat("(7,1)There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//LastDay = new DateTime(_dt.Year, 7, 2);
//Debug.LogFormat("(7,2)There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//LastDay = new DateTime(_dt.Year, 7, 3);
//Debug.LogFormat("(7,3)There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//// Displays the total number of weeks in the current year.
//LastDay = new DateTime(_dt.Year, 12, 30);
//Debug.LogFormat("(12,30)There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//LastDay = new DateTime(_dt.Year, 12, 31);
//Debug.LogFormat("(12,31)There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//LastDay = new DateTime(_dt.Year + 1, 1, 1);
//Debug.LogFormat("(1,1)There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
//LastDay = new DateTime(_dt.Year + 1, 1, 2);
//Debug.LogFormat("(1,2)There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);
return myCal.GetWeekOfYear(_dt, myCWR, myFirstDOW);
}
}