public void CheckTimeReward() { string lastTimeStr = GameData.LastPlayTimeString; if (!string.IsNullOrEmpty(lastTimeStr)) { DateTime dtStart = new DateTime(1970, 1, 1, 0, 0, 0, 0); var timeStr = UnityExtensions.GetTimeStamp(); if (!string.IsNullOrEmpty(timeStr)) { GameData.LastPlayTimeString = timeStr; long longTimeLast /*= long.Parse(timeStr)*/; long.TryParse(lastTimeStr, out longTimeLast); var dtNow = DateTime.UtcNow; var dtLast = dtStart.AddMilliseconds(longTimeLast); var adds = (int)(dtNow - dtLast).TotalSeconds; if (adds > GetShowTimeRewardMinTime) { //if(GuideMgr.S.IsGuideFinish(2)) //UIMgr.S.OpenPanel(UIID.PopEarnPanel, adds); } } } StartTimeRecord(); }
//每隔一段时间请求一下服务器时间存档作为最后游玩时间(ms时间戳) private void OnGameTimeRecord(int count) { Log.i("OnGameTimeRecord : " + count); GameDataMgr.S.Save(); var timeStr = UnityExtensions.GetTimeStamp(); if (/*m_GetTimeReward && */ !string.IsNullOrEmpty(timeStr)) { GameData.LastPlayTimeString = timeStr; } }