using System; using System.Collections.Generic; using MiniJSON; using UILib; using UnityEngine; using XMainClient.UI; using XMainClient.UI.UICommon; using XUpdater; using XUtliPoolLib; namespace XMainClient { internal class AdditionRemindDocument : XDocComponent { public override uint ID { get { return AdditionRemindDocument.uuID; } } public new static readonly uint uuID = XSingleton.singleton.XHash("AdditionRemindDocument"); private bool is3G = false; private static bool is_3g_tip = false; private string cacheString = null; private int uploadtime = 0; public uint loginday = 10u; public bool gm_is_3g = false; public int FREQUENCY = 0; public int LOGINTIME = 0; private float lasttime = 10f; protected override void OnReconnected(XReconnectedEventArgs arg) { } public override void OnAttachToHost(XObject host) { base.OnAttachToHost(host); this.is3G = ((int)Application.internetReachability == 1); } public override void Update(float fDeltaT) { base.Update(fDeltaT); bool flag = Time.time - this.lasttime > 5f; if (flag) { this.Free3GTimer(); this.lasttime = Time.time; } } public void OnRecieveAdditionTip(string msg) { this.cacheString = msg; bool flag = XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; if (flag) { this.ShowAddtionUI(); } } public void Free3GTimer() { bool flag = this.LOGINTIME <= 0; if (flag) { this.LOGINTIME = XSingleton.singleton.GetInt("Free3GTime"); } bool flag2 = this.FREQUENCY <= 0; if (flag2) { this.FREQUENCY = XSingleton.singleton.GetInt("Free3GDay"); } bool flag3 = Time.time > (float)this.LOGINTIME && (this.is3G || this.gm_is_3g) && !AdditionRemindDocument.is_3g_tip && (ulong)this.loginday >= (ulong)((long)this.FREQUENCY) && !XSingleton.singleton.freeflow && !DlgBase.singleton.IsVisible() && !XSingleton.singleton.InTutorial && DlgBase.singleton.IsVisible(); if (flag3) { this.UpdateFreeState(); AdditionRemindDocument.is_3g_tip = true; string @string = XStringDefineProxy.GetString("REM_3G"); XSingleton.singleton.ShowModalDialog(@string, XStringDefineProxy.GetString("REM_BUY"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.Show3GFreeUI)); } } public void SetFreeflowTime(uint time) { this.loginday = ((uint)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds - time) / 3600u; } private void UpdateFreeState() { PtcC2G_UpdateFreeflowHintInfo ptcC2G_UpdateFreeflowHintInfo = new PtcC2G_UpdateFreeflowHintInfo(); TimeSpan timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); ptcC2G_UpdateFreeflowHintInfo.Data.hint_time = (uint)timeSpan.TotalSeconds; XSingleton.singleton.Send(ptcC2G_UpdateFreeflowHintInfo); } private bool Show3GFreeUI(IXUIButton button) { this.Open3GWebPage(); DlgBase.singleton.SetVisible(false, true); return true; } public void Open3GWebPage() { int num = (XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ) ? 2 : 1; string value = XSingleton.singleton.GetValue("SignalKey"); Dictionary dictionary = new Dictionary(); dictionary["url"] = string.Format(XSingleton.singleton.GetValue("SignalFreeUrl"), new object[] { XSingleton.singleton.OpenID, num, XSingleton.singleton.XPlatform.UserMd5(string.Concat(new object[] { XSingleton.singleton.OpenID, num, XSingleton.singleton.GetTimeStamp(), "1231_LongZhiGuApp", XSingleton.singleton.Decrypt(value) })).ToLower(), XSingleton.singleton.GetTimeStamp(), "1231_LongZhiGuApp", XSingleton.singleton.TokenCache }); dictionary["screendir"] = "SENSOR"; bool isEditor = Application.isEditor; if (isEditor) { Application.OpenURL(dictionary["url"]); } else { XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); } } public void ShowAddtionUI() { bool inTutorial = XSingleton.singleton.InTutorial; if (!inTutorial) { bool flag = !string.IsNullOrEmpty(this.cacheString); if (flag) { XSingleton.singleton.ShowModalDialog(this.cacheString, XStringDefineProxy.GetString(XStringDefine.COMMON_OK)); } this.cacheString = null; } } public override void OnEnterSceneFinally() { base.OnEnterSceneFinally(); bool flag = XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; if (flag) { this.ShowAddtionUI(); bool flag2 = this.uploadtime < 1; if (flag2) { this.OnUploadUrl(); } } } public override void OnDetachFromHost() { this.uploadtime = 0; base.OnDetachFromHost(); } public void OnUploadUrl() { bool flag = XSingleton.singleton.playerInfo != null; if (flag) { this.uploadtime++; PtcC2G_PicUrlNtf ptcC2G_PicUrlNtf = new PtcC2G_PicUrlNtf(); bool flag2 = XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ; if (flag2) { ptcC2G_PicUrlNtf.Data.url = XSingleton.singleton.playerInfo.data.pictureLarge; } else { ptcC2G_PicUrlNtf.Data.url = XSingleton.singleton.playerInfo.data.pictureMiddle; } XSingleton.singleton.Send(ptcC2G_PicUrlNtf); } } } }