From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XLoginDocument.cs | 1440 ++++++++++++++++++++ 1 file changed, 1440 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XLoginDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XLoginDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XLoginDocument.cs b/Client/Assets/Scripts/XMainClient/XLoginDocument.cs new file mode 100644 index 00000000..2d1a1b0c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XLoginDocument.cs @@ -0,0 +1,1440 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using KKSG; +using MiniJSON; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XLoginDocument : XSingleton + { + public XLoginView View + { + get + { + return this._view; + } + set + { + this._view = value; + } + } + + public PlatNotice Announcement + { + get + { + return this._announcement; + } + } + + public bool SDKSignOut + { + get + { + return this._sdk_sign_out; + } + set + { + this._sdk_sign_out = value; + } + } + + private string _openid + { + get + { + return this.__openid; + } + set + { + this.__openid = value; + XFileLog.OpenID = value; + XSingleton.singleton.XPlatform.SetApmUserID(value); + } + } + + public uint LoginZoneID + { + get + { + return this._login_zoneid; + } + } + + public bool freeflow + { + get + { + return this._freeflow; + } + } + + public int cctype + { + get + { + return this._cctype; + } + } + + private float FetchingElapsed + { + get + { + return Time.realtimeSinceStartup - this._last_fetch_at; + } + } + + private float LoginingElapsed + { + get + { + return Time.realtimeSinceStartup - this._last_login_at; + } + } + + public string Account + { + get + { + return this._account; + } + } + + public string Password + { + get + { + return this._pwd; + } + } + + public string OpenID + { + get + { + return this._openid; + } + } + + public XAuthorizationChannel Channel + { + get + { + return this._channel; + } + } + + public string TokenCache + { + get + { + return this._token_cache; + } + } + + public bool FetchTokenDelay + { + get + { + return this._fetch_delay; + } + } + + public bool LoginDelay + { + get + { + return this._login_delay; + } + } + + public bool Authorized + { + get + { + return this._authorized; + } + } + + public List ZoneList + { + get + { + return this._zone_list; + } + } + + public Dictionary> ServerCategory + { + get + { + return this._server_category; + } + } + + public uint RoleCountInQueue + { + get + { + return this._role_count_inqueue; + } + } + + public uint LeftTimeInQueue + { + get + { + return this._left_time_inqueue; + } + } + + public List BackFlowServerList + { + get + { + return this._backFlowServerList; + } + } + + private static readonly byte _seed = 148; + + private static readonly float _delay_notice_threshold = 0.5f; + + private static readonly float _max_delay_notice_threshold = 10f; + + private static readonly float _max_notice_threshold = 5f; + + private XAuthorizationChannel _channel = XAuthorizationChannel.XAuthorization_Max; + + private XLoginView _view = null; + + private PlatNotice _announcement = null; + + private bool _sdk_sign_out = false; + + private bool _after_login_announcement = false; + + private bool _notification = false; + + private bool _authorized = false; + + private bool _auto_authorization = false; + + private string _account = null; + + private string _pwd = null; + + private string __openid = null; + + private uint _login_zoneid = 0u; + + private bool _freeflow; + + private int _cctype; + + private string _token_cache = null; + + private bool _fetch_delay = false; + + private bool _fetching_token = false; + + private float _last_fetch_at = 0f; + + private bool _authorized_from_login_stage = false; + + private bool _login_delay = false; + + private bool _logining = false; + + private float _last_login_at = 0f; + + private bool _in_server_queue = false; + + private float enterWorldTime = 0f; + + private List _zone_list = new List(); + + private Dictionary> _server_category = new Dictionary>(); + + private Dictionary _server_dic = new Dictionary(); + + private List _backFlowServerList = new List(); + + public Dictionary FriendServerDic = new Dictionary(); + + public List FriendOpenid = new List(); + + private uint _role_count_inqueue = 0u; + + private uint _left_time_inqueue = 0u; + + private LoginReconnectInfo _login_reconnect_info = null; + + private uint _query_queue_token = 0u; + + private float[] lastLoginTime = new float[2]; + + private StartUpType _LaunchTypeServer = StartUpType.StartUp_Normal; + + private void ResetAccoutInfo() + { + this._sdk_sign_out = false; + this._account = null; + this._pwd = null; + this._openid = null; + this._token_cache = null; + } + + public void SetChannelByWakeUp() + { + switch (this.GetWakeUpType()) + { + case StartUpType.StartUp_QQ: + this._channel = XAuthorizationChannel.XAuthorization_QQ; + break; + case StartUpType.StartUp_WX: + this._channel = XAuthorizationChannel.XAuthorization_WeChat; + break; + } + } + + private void SetChannelByLaunchType() + { + switch (this.GetLaunchType()) + { + case StartUpType.StartUp_QQ: + this._channel = XAuthorizationChannel.XAuthorization_QQ; + break; + case StartUpType.StartUp_WX: + this._channel = XAuthorizationChannel.XAuthorization_WeChat; + break; + } + } + + public void LoadAccount() + { + string path = Application.persistentDataPath + "/account.txt"; + bool flag = (int)Application.platform == 7 || (int)Application.platform == 0 || (int)Application.platform == 2; + if (flag) + { + path = Application.dataPath + "/account.txt"; + } + bool flag2 = !File.Exists(path); + if (flag2) + { + this.SetChannelByLaunchType(); + } + else + { + string text = this.XCryptography(File.ReadAllBytes(path)); + string[] array = text.Split(null); + int num = 0; + bool flag3 = int.TryParse(array[0], out num) && num > 0 && num < XFastEnumIntEqualityComparer.ToInt(XAuthorizationChannel.XAuthorization_Max); + if (flag3) + { + this._channel = (XAuthorizationChannel)num; + this.SetChannelByLaunchType(); + switch (this._channel) + { + case XAuthorizationChannel.XAuthorization_Internal: + { + bool flag4 = array.Length == 3; + if (flag4) + { + this._account = array[1]; + this._pwd = array[2]; + } + break; + } + } + } + else + { + this.SetChannelByLaunchType(); + } + } + } + + public void DelAccount() + { + string path = Application.persistentDataPath + "/account.txt"; + bool flag =(int) Application.platform == 7 || (int)Application.platform == 0 || (int)Application.platform == 2; + if (flag) + { + path = Application.dataPath + "/account.txt"; + } + try + { + bool flag2 = !File.Exists(path); + if (!flag2) + { + File.Delete(path); + } + } + catch (Exception ex) + { + XSingleton.singleton.AddErrorLog("Delete account file failed " + ex.Message, null, null, null, null, null); + } + } + + public void AutoAuthorization(bool fromLoginStage) + { + this.Authorization(this._channel, fromLoginStage, true, this._account, this._pwd); + } + + public bool CheckLoginBlockTime() + { + return Time.time - this.lastLoginTime[1] > XSingleton.singleton.LoginBlockTime; + } + + public void Authorization(XAuthorizationChannel channel, bool fromLoginStage, bool auto = false, string account = null, string pwd = null) + { + this.lastLoginTime[1] = this.lastLoginTime[0]; + this.lastLoginTime[0] = Time.time; + this.SetBlockUIVisable(true); + this._authorized = false; + this._auto_authorization = auto; + this._authorized_from_login_stage = fromLoginStage; + this._fetching_token = true; + this._last_fetch_at = Time.realtimeSinceStartup; + switch (channel) + { + case XAuthorizationChannel.XAuthorization_Internal: + this._channel = channel; + this.InternalAuthorization(account, pwd); + break; + case XAuthorizationChannel.XAuthorization_SD: + this._channel = channel; + this.PlatformAuthorization(); + break; + case XAuthorizationChannel.XAuthorization_QQ: + this._channel = channel; + this.QQAuthorization(auto); + break; + case XAuthorizationChannel.XAuthorization_WeChat: + this._channel = channel; + this.WeChatAuthorization(auto); + break; + case XAuthorizationChannel.XAuthorization_Guest: + this._channel = channel; + this.GuestAuthorization(auto); + break; + default: + this._fetching_token = false; + break; + } + } + + public void ShowAfterLoginAnnouncement() + { + bool flag = !this._after_login_announcement; + if (flag) + { + XSingleton.singleton.ShowAfterLoginAnnouncement(this._announcement); + this._after_login_announcement = true; + } + } + + public void OnError(string notify) + { + XSingleton.singleton.PandoraLogout(); + this._fetching_token = false; + this._authorized = false; + this._logining = false; + this._in_server_queue = false; + bool flag = this._channel != XAuthorizationChannel.XAuthorization_Internal && this._channel != XAuthorizationChannel.XAuthorization_Max; + if (flag) + { + this.ResetAccoutInfo(); + } + bool flag2 = !string.IsNullOrEmpty(notify); + if (flag2) + { + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), notify)); + } + this.FromBegining(); + } + + public void OnError() + { + this._fetching_token = false; + this._authorized = false; + this._logining = false; + this._in_server_queue = false; + } + + public void FromBegining() + { + XSingleton.singleton.ClearServerInfo(); + this.SetBlockUIVisable(false); + bool authorized_from_login_stage = this._authorized_from_login_stage; + if (authorized_from_login_stage) + { + XSingleton.singleton.ShowLoginUI(); + } + else + { + this.BackToBegin(); + } + this._after_login_announcement = false; + this._authorized_from_login_stage = false; + } + + public void FromLogining() + { + this.SetBlockUIVisable(false); + bool authorized_from_login_stage = this._authorized_from_login_stage; + if (authorized_from_login_stage) + { + XSingleton.singleton.ShowLoginSelectServerUI(); + } + else + { + this.BackToLogin(); + } + this._authorized_from_login_stage = false; + } + + public void RefreshAccessToken(string token) + { + this._token_cache = token; + XSingleton.singleton.AddLog("AccessToken : ", this._token_cache, null, null, null, null, XDebugColor.XDebug_None); + } + + public void OnAuthorization(string account, string pwd, string openid, XAuthorizationChannel channel) + { + this._fetching_token = false; + this._account = account; + this._pwd = pwd; + this._openid = openid; + this._channel = channel; + this._token_cache = account; + bool flag = string.IsNullOrEmpty(account) || string.IsNullOrEmpty(openid); + if (flag) + { + this.OnAuthorizedFailed(); + } + else + { + switch (channel) + { + case XAuthorizationChannel.XAuthorization_Internal: + XSingleton.singleton.Authorization(LoginType.LOGIN_PASSWORD, account, pwd, openid); + break; + case XAuthorizationChannel.XAuthorization_SD: + XSingleton.singleton.Authorization(LoginType.LOGIN_SNDA_PF, account, pwd, openid); + break; + case XAuthorizationChannel.XAuthorization_QQ: + XSingleton.singleton.Authorization(LoginType.LOGIN_QQ_PF, account, pwd, openid); + break; + case XAuthorizationChannel.XAuthorization_WeChat: + XSingleton.singleton.Authorization(LoginType.LGOIN_WECHAT_PF, account, pwd, openid); + break; + case XAuthorizationChannel.XAuthorization_Guest: + XSingleton.singleton.Authorization(LoginType.LOGIN_IOS_GUEST, account, pwd, openid); + break; + } + } + } + + public void OnAuthorizationSignOut(string msg) + { + bool flag = this._channel == XAuthorizationChannel.XAuthorization_Max; + if (!flag) + { + this._sdk_sign_out = true; + bool flag2 = !XStage.IsConcreteStage(XSingleton.singleton.CurrentStage.Stage); + if (flag2) + { + bool flag3 = string.IsNullOrEmpty(msg); + if (flag3) + { + this._authorized = false; + } + else + { + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), msg)); + } + this.FromBegining(); + } + else + { + XSingleton.singleton.AddLog("OnAuthorizationSignOut " + msg, null, null, null, null, null, XDebugColor.XDebug_None); + XSingleton.singleton.Close(NetErrCode.Net_NoError); + bool sceneReady = XSingleton.singleton.SceneReady; + if (sceneReady) + { + XSingleton.singleton.OnFatalErrorClosed(ErrorCode.ERR_AUTH_TOKEN_INVALID); + } + else + { + XSingleton.singleton.Error = ErrorCode.ERR_AUTH_TOKEN_INVALID; + } + } + this._channel = XAuthorizationChannel.XAuthorization_Max; + } + } + + public void AuthorizationSignOut() + { + bool flag = this._channel == XAuthorizationChannel.XAuthorization_Max; + if (!flag) + { + this._authorized = false; + bool flag2 = this._channel != XAuthorizationChannel.XAuthorization_Internal && this._channel != XAuthorizationChannel.XAuthorization_Max; + if (flag2) + { + this.ResetAccoutInfo(); + XSingleton.singleton.XPlatform.LogOut(); + } + this.DelAccount(); + XSingleton.singleton.PandoraLogout(); + this._channel = XAuthorizationChannel.XAuthorization_Max; + this.FromBegining(); + } + } + + public void OnAuthorized(string identification) + { + bool flag = this._channel == XAuthorizationChannel.XAuthorization_SD; + if (flag) + { + this._account = string.Format("{0} ({1})", identification, XStringDefineProxy.GetString("SDO_TOKEN")); + } + bool flag2 = this._channel == XAuthorizationChannel.XAuthorization_QQ; + if (flag2) + { + this._account = identification + " (QQ)"; + } + bool flag3 = this._channel == XAuthorizationChannel.XAuthorization_WeChat; + if (flag3) + { + this._account = string.Format("{0} ({1})", identification, XStringDefineProxy.GetString("WECHAT_TOKEN")); + } + bool flag4 = this._channel == XAuthorizationChannel.XAuthorization_Guest; + if (flag4) + { + this._account = string.Format("{0} ({1})", identification, XStringDefineProxy.GetString("GUEST_TOKEN")); + } + bool flag5 = !this._auto_authorization || this._authorized_from_login_stage; + if (flag5) + { + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), XStringDefineProxy.GetString("AUTHORIZED_SUCCESS"))); + } + this.SaveAccount(); + this._authorized = true; + this.ShowLoginSelectServerUI(); + this.SetBlockUIVisable(false); + XSingleton.singleton.XLoginStep = XLoginStep.Login; + } + + public void OnAuthorizedFailed() + { + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), XStringDefineProxy.GetString("AUTHORIZED_FAIL"))); + string sdkconfig = XSingleton.singleton.XPlatform.GetSDKConfig("get_login_eflag", ""); + bool flag = this._channel != XAuthorizationChannel.XAuthorization_Internal && this._channel != XAuthorizationChannel.XAuthorization_Max; + if (flag) + { + this.ResetAccoutInfo(); + } + XSingleton.singleton.playerInfo = null; + XSingleton.singleton.friendsInfo = null; + this._authorized = false; + this.OnError(); + this.FromBegining(); + } + + public void OnAuthorizedConnectFailed() + { + bool flag = this._channel != XAuthorizationChannel.XAuthorization_Internal && this._channel != XAuthorizationChannel.XAuthorization_Max; + if (flag) + { + this.ResetAccoutInfo(); + } + XSingleton.singleton.playerInfo = null; + XSingleton.singleton.friendsInfo = null; + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), XStringDefineProxy.GetString("AUTHORIZED_CONNECT_FAIL"))); + this._authorized = false; + this.OnError(); + this.FromBegining(); + } + + public void OnAuthorizedTimeOut() + { + bool flag = this._channel != XAuthorizationChannel.XAuthorization_Internal && this._channel != XAuthorizationChannel.XAuthorization_Max; + if (flag) + { + this.ResetAccoutInfo(); + } + XSingleton.singleton.playerInfo = null; + XSingleton.singleton.friendsInfo = null; + XSingleton.singleton.ShowLoginTip(this.PlatformComment(this._channel) + " 授权验证超时"); + this._authorized = false; + this.FromBegining(); + } + + public void Login() + { + this.SetBlockUIVisable(true); + this._logining = true; + this._last_login_at = Time.realtimeSinceStartup; + this._in_server_queue = false; + XSingleton.singleton.Login(); + } + + public void OnLogin() + { + bool authorized_from_login_stage = this._authorized_from_login_stage; + if (authorized_from_login_stage) + { + this._view.TweenAlpha(true); + } + XSingleton.singleton.OnLogin(); + this._logining = false; + this._authorized_from_login_stage = false; + this._in_server_queue = false; + this.SetBlockUIVisable(false); + } + + public StartUpType GetWakeUpType() + { + StartUpType startUpType = StartUpType.StartUp_Normal; + string sdkconfig = XSingleton.singleton.XPlatform.GetSDKConfig("get_wakeup_info", ""); + XSingleton.singleton.AddLog("[GetLaunchType] wakeupInfo:" + sdkconfig, null, null, null, null, null, XDebugColor.XDebug_None); + bool flag = sdkconfig == ""; + StartUpType result; + if (flag) + { + result = startUpType; + } + else + { + Dictionary dictionary = Json.Deserialize(sdkconfig) as Dictionary; + object obj = null; + bool flag2 = dictionary != null && dictionary.TryGetValue("wakeup_platform", out obj); + if (flag2) + { + XSingleton.singleton.AddLog("[GetLaunchType] platform: " + obj.ToString(), null, null, null, null, null, XDebugColor.XDebug_None); + bool flag3 = (long)obj == 1L; + if (flag3) + { + startUpType = StartUpType.StartUp_WX; + } + else + { + bool flag4 = (long)obj == 2L; + if (flag4) + { + startUpType = StartUpType.StartUp_QQ; + } + } + } + result = startUpType; + } + return result; + } + + public StartUpType GetLaunchType() + { + StartUpType startUpType = StartUpType.StartUp_Normal; + string sdkconfig = XSingleton.singleton.XPlatform.GetSDKConfig("get_wakeup_info", ""); + XSingleton.singleton.AddLog("[GetLaunchType] wakeupInfo:" + sdkconfig, null, null, null, null, null, XDebugColor.XDebug_None); + bool flag = sdkconfig == ""; + StartUpType result; + if (flag) + { + result = startUpType; + } + else + { + Dictionary dictionary = Json.Deserialize(sdkconfig) as Dictionary; + object obj = null; + bool flag2 = dictionary != null && dictionary.TryGetValue("wakeup_platform", out obj); + if (flag2) + { + XSingleton.singleton.AddLog("[GetLaunchType] platform: " + obj.ToString(), null, null, null, null, null, XDebugColor.XDebug_None); + bool flag3 = (long)obj == 1L; + if (flag3) + { + XSingleton.singleton.AddLog("[GetLaunchType] platform == 1", null, null, null, null, null, XDebugColor.XDebug_None); + object obj2 = null; + bool flag4 = dictionary.TryGetValue("wakeup_wx_extInfo", out obj2); + if (flag4) + { + bool flag5 = obj2.ToString() == "WX_GameCenter"; + if (flag5) + { + startUpType = StartUpType.StartUp_WX; + XSingleton.singleton.AddLog("[GetLaunchType] StartUpType.StartUp_WX", null, null, null, null, null, XDebugColor.XDebug_None); + } + } + } + else + { + bool flag6 = (long)obj == 2L; + if (flag6) + { + XSingleton.singleton.AddLog("[GetLaunchType] platform == 2", null, null, null, null, null, XDebugColor.XDebug_None); + object obj3 = null; + bool flag7 = dictionary.TryGetValue("wakeup_qq_extInfo", out obj3); + if (flag7) + { + bool flag8 = obj3.ToString() == "sq_gamecenter"; + if (flag8) + { + startUpType = StartUpType.StartUp_QQ; + XSingleton.singleton.AddLog("[GetLaunchType] StartUpType.StartUp_QQ", null, null, null, null, null, XDebugColor.XDebug_None); + } + } + } + } + } + result = startUpType; + } + return result; + } + + public void SetLaunchTypeServerInfo(StartUpType type) + { + this._LaunchTypeServer = type; + } + + public StartUpType GetLaunchTypeServerInfo() + { + return this._LaunchTypeServer; + } + + public void EnterToSelectChar() + { + XSingleton.singleton.OnLogin(); + EXStage stage = XSingleton.singleton.CurrentStage.Stage; + if (stage != EXStage.Login) + { + if (stage == EXStage.SelectChar) + { + XSelectcharStage xselectcharStage = XSingleton.singleton.CurrentStage as XSelectcharStage; + xselectcharStage.ReLogined(); + } + } + else + { + XSingleton.singleton.CurrentStage.Play(); + } + } + + public void CheckQueueState(object o) + { + XSingleton.singleton.KillTimer(this._query_queue_token); + this._query_queue_token = 0u; + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + bool flag2 = !this._in_server_queue; + if (!flag2) + { + PtcC2M_CheckQueuingReq ptcC2M_CheckQueuingReq = new PtcC2M_CheckQueuingReq(); + ptcC2M_CheckQueuingReq.Data.iscancel = false; + XSingleton.singleton.Send(ptcC2M_CheckQueuingReq); + this._query_queue_token = XSingleton.singleton.SetTimer(5f, new XTimerMgr.ElapsedEventHandler(this.CheckQueueState), null); + } + } + } + + public void CancelQueue() + { + PtcC2M_CheckQueuingReq ptcC2M_CheckQueuingReq = new PtcC2M_CheckQueuingReq(); + ptcC2M_CheckQueuingReq.Data.iscancel = true; + XSingleton.singleton.Send(ptcC2M_CheckQueuingReq); + this.OnCancelServerQueue(); + } + + public void ShowServerQueue() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + this._in_server_queue = true; + DlgBase.singleton.ShowQueue(); + this.CheckQueueState(null); + this.SetBlockUIVisable(false); + } + } + + public void WaitForServerQueue(uint roleCount, uint leftTime) + { + this._role_count_inqueue = roleCount; + this._left_time_inqueue = leftTime; + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.RefreshQueueState(); + } + } + + public void OnLoginFailed(string error) + { + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), string.IsNullOrEmpty(error) ? XStringDefineProxy.GetString("LOGIN_FAIL") : error)); + this._logining = false; + this._in_server_queue = false; + this.FromLogining(); + } + + public void OnLoginTimeout() + { + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), XStringDefineProxy.GetString("LOGIN_TIMEOUT"))); + this._logining = false; + this._in_server_queue = false; + this.FromLogining(); + } + + public void OnLoginConnectFailed() + { + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), XStringDefineProxy.GetString("LOGIN_CONNECT_FAIL"))); + this._logining = false; + this._in_server_queue = false; + this.FromLogining(); + } + + public void OnCancelServerQueue() + { + XSingleton.singleton.ShowLoginTip(XStringDefineProxy.GetString("CANCEL_QUEUE")); + this._logining = false; + this._in_server_queue = false; + XSingleton.singleton.Close(NetErrCode.Net_NoError); + this._authorized_from_login_stage = true; + this.FromLogining(); + } + + public void EnterWorld(int index) + { + bool flag = Time.time - this.enterWorldTime < 2f; + if (!flag) + { + this.enterWorldTime = Time.time; + bool flag2 = index > 0; + if (flag2) + { + RpcC2M_SelectRoleNew rpcC2M_SelectRoleNew = new RpcC2M_SelectRoleNew(); + rpcC2M_SelectRoleNew.oArg.index = index - 1; + XSingleton.singleton.Send(rpcC2M_SelectRoleNew); + } + XSingleton.singleton.XLoginToken = null; + } + } + + public void CreateChar(string name, RoleType type) + { + bool flag = Time.time - this.enterWorldTime < 2f; + if (!flag) + { + this.enterWorldTime = Time.time; + RpcC2M_CreateRoleNew rpcC2M_CreateRoleNew = new RpcC2M_CreateRoleNew(); + rpcC2M_CreateRoleNew.oArg.name = name; + rpcC2M_CreateRoleNew.oArg.type = type; + XSingleton.singleton.Send(rpcC2M_CreateRoleNew); + this.SetBlockUIVisable(true); + } + } + + public void OnEnterWorldFailed(string error) + { + this.BackToLogin(); + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), string.IsNullOrEmpty(error) ? XStringDefineProxy.GetString("ENTER_WORLD_FAIL") : error)); + } + + public void OnEnterWorldTimeOut() + { + this.BackToLogin(); + XSingleton.singleton.ShowLoginTip(string.Format("{0} {1}", this.PlatformComment(this._channel), XStringDefineProxy.GetString("ENTER_WORLD_TIMEOUT"))); + } + + public void EnableSDONotify() + { + bool flag = !this._notification; + if (flag) + { + XSingleton.singleton.XPlatform.ResgiterSDONotification(XSingleton.singleton.ServerID, XSingleton.singleton.Player.Name); + } + this._notification = true; + } + + private void BackToBegin() + { + bool flag = XSingleton.singleton.XLoginStep == XLoginStep.Begin; + if (!flag) + { + XSingleton.singleton.XPlayerCharacters.PlayerBriefInfo.Clear(); + XSingleton.singleton.XPlayerCharacters.SelectedSlot = 0; + XSingleton.singleton.XLoginStep = XLoginStep.Begin; + XSingleton.singleton.SwitchTo(EXStage.Login, 3u); + } + } + + private void BackToLogin() + { + bool flag = XSingleton.singleton.XLoginStep == XLoginStep.Login; + if (!flag) + { + XSingleton.singleton.XPlayerCharacters.PlayerBriefInfo.Clear(); + XSingleton.singleton.XPlayerCharacters.SelectedSlot = 0; + XSingleton.singleton.XLoginStep = XLoginStep.Login; + XSingleton.singleton.SwitchTo(EXStage.Login, 3u); + } + } + + private void SaveAccount() + { + int num = XFastEnumIntEqualityComparer.ToInt(this._channel); + string text = Application.persistentDataPath + "/account.txt"; + bool flag = (int)Application.platform == 7 || (int)Application.platform == 0 || (int)Application.platform == 2; + if (flag) + { + text = Application.dataPath + "/account.txt"; + } + try + { + File.WriteAllBytes(text, this.XCryptography(string.Format("{0}\n{1}\n{2}", num, this._account, this._pwd))); + XSingleton.singleton.XPlatform.SetNoBackupFlag(text); + } + catch (Exception ex) + { + XSingleton.singleton.AddErrorLog("Save account file error ", ex.Message, null, null, null, null); + } + } + + private void PlatformAuthorization() + { + XSingleton.singleton.XPlatform.OnPlatformLogin(); + } + + private void QQAuthorization(bool auto) + { + XSingleton.singleton.XPlatform.OnQQLogin(); + } + + private void WeChatAuthorization(bool auto) + { + XSingleton.singleton.XPlatform.OnWeChatLogin(); + } + + private void GuestAuthorization(bool auto) + { + XSingleton.singleton.XPlatform.OnGuestLogin(); + } + + private void InternalAuthorization(string account, string pwd) + { + this.OnAuthorization(account, pwd, account, XAuthorizationChannel.XAuthorization_Internal); + } + + public void Update() + { + this._fetch_delay = false; + this._login_delay = false; + bool fetching_token = this._fetching_token; + if (fetching_token) + { + bool flag = this.FetchingElapsed > XLoginDocument._delay_notice_threshold; + if (flag) + { + this._fetch_delay = true; + } + bool flag2 = this.FetchingElapsed > XLoginDocument._max_delay_notice_threshold; + if (flag2) + { + this._fetching_token = false; + this._fetch_delay = false; + this.SetBlockUIVisable(false); + } + } + bool flag3 = this._logining && !this._in_server_queue; + if (flag3) + { + bool flag4 = this.LoginingElapsed > XLoginDocument._delay_notice_threshold; + if (flag4) + { + bool flag5 = this.LoginingElapsed > XLoginDocument._max_notice_threshold; + if (flag5) + { + XSingleton.singleton.Close(NetErrCode.Net_NoError); + this.OnLoginTimeout(); + } + else + { + this._login_delay = true; + } + } + } + } + + private string PlatformComment(XAuthorizationChannel channel) + { + string result; + switch (channel) + { + case XAuthorizationChannel.XAuthorization_Internal: + result = ""; + break; + case XAuthorizationChannel.XAuthorization_SD: + result = XStringDefineProxy.GetString("SDO_TOKEN"); + break; + case XAuthorizationChannel.XAuthorization_QQ: + result = "QQ"; + break; + case XAuthorizationChannel.XAuthorization_WeChat: + result = XStringDefineProxy.GetString("WECHAT_TOKEN"); + break; + case XAuthorizationChannel.XAuthorization_Guest: + result = XStringDefineProxy.GetString("GUEST_TOKEN"); + break; + default: + result = ""; + break; + } + return result; + } + + private byte[] XCryptography(string content) + { + byte[] bytes = Encoding.UTF8.GetBytes(content); + for (int i = 0; i < bytes.Length; i++) + { + bytes[i] ^= XLoginDocument._seed; + } + return bytes; + } + + private string XCryptography(byte[] content) + { + for (int i = 0; i < content.Length; i++) + { + content[i] ^= XLoginDocument._seed; + } + return Encoding.UTF8.GetString(content); + } + + public bool IsPublish() + { + return XSingleton.singleton.XPlatform.IsPublish(); + } + + public void SetBlockUIVisable(bool state) + { + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.uiBehaviour.m_BlockWindow.gameObject.SetActive(state); + } + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.uiBehaviour.m_block.gameObject.SetActive(state); + } + } + + public void ShowLoginUI() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.ShowLogin(); + } + } + + public void ShowLoginSelectServerUI() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + bool flag2 = string.IsNullOrEmpty(XSingleton.singleton.XLoginToken); + if (flag2) + { + XSingleton.singleton.AutoAuthorization(false); + } + this.ShowAfterLoginAnnouncement(); + DlgBase.singleton.ShowSelectServer(); + DlgBase.singleton.SetCurrentServer(); + } + } + + public void ShowSelectCharGerenalUI() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.ShowSelectCharGerenal(); + } + } + + public void ShowSelectCharSelectedUI(string name, int level) + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.ShowSelectCharSelected(name, level); + } + } + + public void ShowSelectCharCreatedUI() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.ShowSelectCharCreated(); + } + } + + public void SetLoginZoneID(uint loginZoneId) + { + this._login_zoneid = loginZoneId; + } + + public void SetAnnouncement(PlatNotice announcement) + { + this._announcement = announcement; + } + + public void SetFreeflow(bool _free, int _type) + { + this._freeflow = _free; + this._cctype = _type; + } + + public void SetGateIPTable(List myServersList, byte[] bytes, List serverList) + { + this._server_dic.Clear(); + this._server_category.Clear(); + this._zone_list.Clear(); + this.BackFlowServerList.Clear(); + for (int i = serverList.Count - 1; i >= 0; i--) + { + LoginGateData loginGateData = serverList[i]; + bool isbackflow = loginGateData.isbackflow; + if (isbackflow) + { + bool flag = true; + for (int j = 0; j < this.BackFlowServerList.Count; j++) + { + bool flag2 = this.BackFlowServerList[j].ServerID == loginGateData.serverid; + if (flag2) + { + flag = false; + break; + } + } + bool flag3 = flag; + if (flag3) + { + this.BackFlowServerList.Add(this.CreateServerInfoData(loginGateData.serverid, loginGateData.servername, loginGateData.zonename, loginGateData.ip, (uint)loginGateData.port, (int)loginGateData.state, (int)loginGateData.flag, loginGateData.backflowlevel)); + } + serverList.RemoveAt(i); + } + } + string @string = XSingleton.singleton.GetString("MYSELF_SERVERS"); + this._server_category.Add(@string, new List()); + this._zone_list.Add(@string); + string string2 = XSingleton.singleton.GetString("BACK_SERVERS"); + bool flag4 = this.BackFlowServerList.Count > 0; + if (flag4) + { + this._zone_list.Add(string2); + this._server_category.Add(string2, new List()); + } + string string3 = XSingleton.singleton.GetString("FRIENDS_SERVERS"); + this._server_category.Add(string3, new List()); + this._zone_list.Add(string3); + bool flag5 = myServersList.Count == 0; + if (flag5) + { + XSingleton.singleton.ShowModalDialog(XStringDefineProxy.GetString("TRUE_NAME_TIP"), XStringDefineProxy.GetString("COMMON_OK")); + } + for (int k = 0; k < myServersList.Count; k++) + { + this._server_category[@string].Add(myServersList[k].servers.serverid); + bool flag6 = !this._server_dic.ContainsKey(myServersList[k].servers.serverid); + if (flag6) + { + List list = new List(); + list.Add(string.Format("{0}:{1}", myServersList[k].servers.ip, myServersList[k].servers.port)); + this._server_dic.Add(myServersList[k].servers.serverid, this.CreateServerInfoData(myServersList[k].servers.serverid, myServersList[k].servers.servername, myServersList[k].servers.zonename, myServersList[k].servers.ip, (uint)myServersList[k].servers.port, (int)myServersList[k].servers.state, (int)myServersList[k].servers.flag, myServersList[k].level)); + } + for (int l = 0; l < this._backFlowServerList.Count; l++) + { + bool flag7 = this._backFlowServerList[l].ServerID == myServersList[k].servers.serverid; + if (flag7) + { + this._backFlowServerList[l].Level = myServersList[k].level; + } + } + } + for (int m = 0; m < serverList.Count; m++) + { + bool flag8 = !this._server_category.ContainsKey(serverList[m].zonename); + if (flag8) + { + this._server_category.Add(serverList[m].zonename, new List()); + this._zone_list.Add(serverList[m].zonename); + } + this._server_category[serverList[m].zonename].Add(serverList[m].serverid); + bool flag9 = !this._server_dic.ContainsKey(serverList[m].serverid); + if (flag9) + { + this._server_dic.Add(serverList[m].serverid, this.CreateServerInfoData(serverList[m].serverid, serverList[m].servername, serverList[m].zonename, serverList[m].ip, (uint)serverList[m].port, (int)serverList[m].state, (int)serverList[m].flag, 0u)); + } + } + for (int n = 0; n < this.BackFlowServerList.Count; n++) + { + this._server_category[string2].Add(this.BackFlowServerList[n].ServerID); + bool flag10 = !this._server_dic.ContainsKey(this.BackFlowServerList[n].ServerID); + if (flag10) + { + this._server_dic.Add(this.BackFlowServerList[n].ServerID, this.BackFlowServerList[n]); + } + } + } + + public void SetFriendServerList(List friendList) + { + this.FriendServerDic.Clear(); + this.FriendOpenid.Clear(); + for (int i = 0; i < friendList.Count; i++) + { + ServerInfo serverData = this.GetServerData(friendList[i].serverid); + bool flag = serverData == null; + if (!flag) + { + bool flag2 = !XSingleton.singleton.IsGMAccount; + if (flag2) + { + bool flag3 = serverData.StateTxt == 6; + if (flag3) + { + goto IL_C4; + } + } + FriendServerInfo friendServerInfo = new FriendServerInfo(); + friendServerInfo.info = friendList[i]; + friendServerInfo.account = ""; + friendServerInfo.icon = ""; + this.FriendServerDic[friendList[i].openid] = friendServerInfo; + this.FriendOpenid.Add(friendList[i].openid); + } + IL_C4:; + } + XSingleton.singleton.XPlatform.SendGameExData("QueryFriends", ""); + } + + public void SetFriendServerIcon() + { + for (int i = 0; i < XSingleton.singleton.friendsInfo.data.Length; i++) + { + bool flag = this.FriendServerDic.ContainsKey(XSingleton.singleton.friendsInfo.data[i].openId); + if (flag) + { + this.FriendServerDic[XSingleton.singleton.friendsInfo.data[i].openId].account = XSingleton.singleton.friendsInfo.data[i].nickName; + this.FriendServerDic[XSingleton.singleton.friendsInfo.data[i].openId].icon = XSingleton.singleton.friendsInfo.data[i].pictureLarge; + } + } + } + + public ServerInfo CreateServerInfoData(int serverID, string serverName, string zoneName, string ip, uint port, int state, int stateTxt, uint level) + { + return new ServerInfo + { + ServerID = serverID, + ServerName = serverName, + ZoneName = zoneName, + Ip = ip, + Port = port, + State = state, + StateTxt = stateTxt, + Level = level + }; + } + + public ServerInfo GetServerData(int id) + { + ServerInfo serverInfo; + bool flag = this._server_dic.TryGetValue(id, out serverInfo); + ServerInfo result; + if (flag) + { + result = serverInfo; + } + else + { + result = null; + } + return result; + } + + public void OnServerChanged(int id) + { + ServerInfo serverData = this.GetServerData(id); + bool flag = serverData == null; + if (!flag) + { + bool flag2 = XSingleton.singleton.OnServerChanged(serverData); + if (flag2) + { + this._view.SetCurrentServer(); + } + } + } + + public bool OnLoginForbidClick(IXUIButton btn) + { + DlgBase.singleton.SetVisible(false, true); + this.BackToLogin(); + return true; + } + + public void SetLoginReconnect(LoginReconnectInfo info) + { + this._login_reconnect_info = info; + } + + public void ShowLoginReconnect() + { + bool flag = this._login_reconnect_info == null || this._login_reconnect_info.scenetemplateid == 0u; + if (!flag) + { + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(this._login_reconnect_info.scenetemplateid); + string @string = XStringDefineProxy.GetString("LOGIN_RECONNECT_TIP", new object[] + { + (sceneData != null) ? sceneData.Comment : "" + }); + XSingleton.singleton.ShowModalDialog(@string, XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.OnStartLoginReconnectClicked), new ButtonClickEventHandler(this.OnCancelLoginReconnectClicked), false, XTempTipDefine.OD_START, 50); + } + } + + private bool OnStartLoginReconnectClicked(IXUIButton btn) + { + RpcC2N_LoginReconnectReq rpcC2N_LoginReconnectReq = new RpcC2N_LoginReconnectReq(); + rpcC2N_LoginReconnectReq.oArg.reconnect = true; + XSingleton.singleton.Send(rpcC2N_LoginReconnectReq); + this._login_reconnect_info = null; + this.SetBlockUIVisable(true); + return true; + } + + private bool OnCancelLoginReconnectClicked(IXUIButton btn) + { + RpcC2N_LoginReconnectReq rpcC2N_LoginReconnectReq = new RpcC2N_LoginReconnectReq(); + rpcC2N_LoginReconnectReq.oArg.reconnect = false; + XSingleton.singleton.Send(rpcC2N_LoginReconnectReq); + this._login_reconnect_info = null; + this.SetBlockUIVisable(true); + return true; + } + } +} -- cgit v1.1-26-g67d0