diff options
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/AdditionRemindDocument.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/AdditionRemindDocument.cs | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/AdditionRemindDocument.cs b/Client/Assets/Scripts/XMainClient/AdditionRemindDocument.cs new file mode 100644 index 00000000..ddf7b4b1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/AdditionRemindDocument.cs @@ -0,0 +1,204 @@ +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<XCommon>.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<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
+ if (flag)
+ {
+ this.ShowAddtionUI();
+ }
+ }
+
+ public void Free3GTimer()
+ {
+ bool flag = this.LOGINTIME <= 0;
+ if (flag)
+ {
+ this.LOGINTIME = XSingleton<XGlobalConfig>.singleton.GetInt("Free3GTime");
+ }
+ bool flag2 = this.FREQUENCY <= 0;
+ if (flag2)
+ {
+ this.FREQUENCY = XSingleton<XGlobalConfig>.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<XLoginDocument>.singleton.freeflow && !DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.IsVisible() && !XSingleton<XTutorialMgr>.singleton.InTutorial && DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsVisible();
+ if (flag3)
+ {
+ this.UpdateFreeState();
+ AdditionRemindDocument.is_3g_tip = true;
+ string @string = XStringDefineProxy.GetString("REM_3G");
+ XSingleton<UiUtility>.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<XClientNetwork>.singleton.Send(ptcC2G_UpdateFreeflowHintInfo);
+ }
+
+ private bool Show3GFreeUI(IXUIButton button)
+ {
+ this.Open3GWebPage();
+ DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
+ return true;
+ }
+
+ public void Open3GWebPage()
+ {
+ int num = (XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ) ? 2 : 1;
+ string value = XSingleton<XGlobalConfig>.singleton.GetValue("SignalKey");
+ Dictionary<string, string> dictionary = new Dictionary<string, string>();
+ dictionary["url"] = string.Format(XSingleton<XGlobalConfig>.singleton.GetValue("SignalFreeUrl"), new object[]
+ {
+ XSingleton<XLoginDocument>.singleton.OpenID,
+ num,
+ XSingleton<XUpdater.XUpdater>.singleton.XPlatform.UserMd5(string.Concat(new object[]
+ {
+ XSingleton<XLoginDocument>.singleton.OpenID,
+ num,
+ XSingleton<UiUtility>.singleton.GetTimeStamp(),
+ "1231_LongZhiGuApp",
+ XSingleton<UiUtility>.singleton.Decrypt(value)
+ })).ToLower(),
+ XSingleton<UiUtility>.singleton.GetTimeStamp(),
+ "1231_LongZhiGuApp",
+ XSingleton<XLoginDocument>.singleton.TokenCache
+ });
+ dictionary["screendir"] = "SENSOR";
+ bool isEditor = Application.isEditor;
+ if (isEditor)
+ {
+ Application.OpenURL(dictionary["url"]);
+ }
+ else
+ {
+ XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary));
+ }
+ }
+
+ public void ShowAddtionUI()
+ {
+ bool inTutorial = XSingleton<XTutorialMgr>.singleton.InTutorial;
+ if (!inTutorial)
+ {
+ bool flag = !string.IsNullOrEmpty(this.cacheString);
+ if (flag)
+ {
+ XSingleton<UiUtility>.singleton.ShowModalDialog(this.cacheString, XStringDefineProxy.GetString(XStringDefine.COMMON_OK));
+ }
+ this.cacheString = null;
+ }
+ }
+
+ public override void OnEnterSceneFinally()
+ {
+ base.OnEnterSceneFinally();
+ bool flag = XSingleton<XGame>.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<PDatabase>.singleton.playerInfo != null;
+ if (flag)
+ {
+ this.uploadtime++;
+ PtcC2G_PicUrlNtf ptcC2G_PicUrlNtf = new PtcC2G_PicUrlNtf();
+ bool flag2 = XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ;
+ if (flag2)
+ {
+ ptcC2G_PicUrlNtf.Data.url = XSingleton<PDatabase>.singleton.playerInfo.data.pictureLarge;
+ }
+ else
+ {
+ ptcC2G_PicUrlNtf.Data.url = XSingleton<PDatabase>.singleton.playerInfo.data.pictureMiddle;
+ }
+ XSingleton<XClientNetwork>.singleton.Send(ptcC2G_PicUrlNtf);
+ }
+ }
+ }
+}
|