//================= Start ===================== //================= 进入前 ===================== #region 进入游戏前判断是否登陆 public static void PrejudgeLogin() { if (PlayerComponent.This.LastPlayerInfo == null) { //如果还未登陆,先调整至手机登录界面 Login_Account.PageToAccout_NumberInit(); } else { StartLogin(); } }
/// <summary> /// 登录成功回调 /// </summary> public static void LoginCallBackForSavePlayer(Player player) { //本地存储 当前玩家登陆信息 SettingComponent.This.SetString(GlobalData.CookieSets.Cookie_MainPlayer, JsonHelper.ToJson(player.PlayerInfo)); Log.Info("PlayerPrefs save :" + JsonHelper.ToJson(player.PlayerInfo), LogCategory.Event); //存储当前 登录玩家 SUID SettingComponent.This.SetString(GlobalData.CookieSets.Cookie_UUID, player.UserId.ToString()); //本地保存 游客登录SUID,只存储一次 //暂时使用playfrefs 之后切换keychain if (!SettingComponent.This.HasKey(GlobalData.CookieSets.Cookie_Quick)) { SettingComponent.This.SetString(GlobalData.CookieSets.Cookie_Quick, JsonHelper.ToJson(player.PlayerInfo)); } //储存已登录记录到本地 Login_Account.SetHistoryUser(player); //登录成功 下浮成功信息框显示 //PoFor_LoginSuccess(player); }
//================= 选择登录方式 ===================== #region 游戏登陆方式 #region 1、QuestLogin 游客注册并登录 /// <summary> /// 游客注册并登录 /// </summary> /// <param name="loginType">登录方式</param> /// <param name="timeAction">时间代理</param> public static async void QuestLogin(LoginType loginType, TimeAction timeAction) { Dictionary <string, object> dic = VarDicSO.NewValue(); dic["AUTHKEY"] = ""; try { //游客模式登陆 第一次登陆,用户和密码为空\第二次登陆之后 根据 UUID 和 授权码进行自动登陆 PlayerInfo playerInfo = SettingComponent.This.GetObject <PlayerInfo>(GlobalData.CookieSets.Cookie_Quick); if (playerInfo != null) { dic["AUTHKEY"] = playerInfo.AuthorizedSKey; } WebRequestAwaitEventArgs webRequest = await WebRequestLogin(dic, loginType); if (webRequest.WebRequestCallBackStatus == WebRequestCallBackStatus.Success) { string responseJson = Utility.Converter.GetString(webRequest.GetWebResponseBytes()); HttpResult ret = JsonHelper.ToObject <HttpResult>(responseJson); //返回登录成功or失败信息 P6_LoginMesg.This.m_Text_LoginMesg .SetGTextByCode(ret.code.ToString()); if (!ret.status) { Log.Error(ret.code.ToString() + responseJson, LogCategory.Proto); //执行结束 结束异步时间代理调用 timeAction?.EndLoop(); } else { timeAction.CFParams.BoolParam1 = true; //关闭用户信息面板 Login_Account.PageToAccount_Close(); Log.Info(ret.code.ToString() + responseJson, LogCategory.Proto); //获取到网关信息 LoginFromRealmCallback(ret.data?.ToString(), loginType, timeAction); } } else { P6_LoginMesg.This .m_Text_LoginMesg .SetGTextByValue(webRequest.ErrorMessage); Log.Info(webRequest.ErrorMessage, LogCategory.Proto); //执行结束 结束异步时间代理调用 timeAction?.EndLoop(); } } catch (Exception ex) { Log.Error(ex.Message, LogCategory.Proto); } }