public override void OnOperationResponse(OperationResponse operationResponse) { if (operationResponse.ReturnCode == (short)ReturnCode.Success) { GameRoot.AddTips("注册成功!请创建角色!"); NetLogin netLogin = new NetLogin(_acct, _password); } else { GameRoot.AddTips("注册失败!账号重复"); } NetSvc.Instance.RemoveRequest(this); }
//TODO 记录玩家账号密码 public void ClickLogin() { audioSvc.PlayUIAudio(Constants.UILoginBtn); string acct = iptAcct.text; string pass = iptPass.text; if (acct != "" && pass != "") { //更新本地储存的密码 PlayerPrefs.SetString("Acct", acct); PlayerPrefs.SetString("Pass", pass); //TODO 发送网络消息 NetLogin netLogin = new NetLogin(int.Parse(acct), pass); } else { GameRoot.AddTips("账号密码不能为空!!!!"); } }
public void ClickLoginBtn() { audioSvc.PlayUIAudio(Constants.audioUIByUIClickBtn); string acct = iptAcct.text; string password = iptPassword.text; if (acct != "" && password != "") { //更新本地存储的账号密码 PlayerPrefs.SetString("Acct", acct); PlayerPrefs.SetString("Pass", password); //发送网络消息 这里先假设 登录成功 NetLogin netLogin = new NetLogin(acct, password); } else { //账号密码不能为空tips OARoot.Instance.AddTips("账号密码不能为空!"); } }
/// <summary> // This method is executed when using this.Publish(new NetLogin()) /// </summary> public virtual void NetLoginHandler(NetLogin data) { // Process the commands information. Also, you can publish new events by using the line below. // this.Publish(new AnotherEvent()) }
public override void NetLoginHandler(NetLogin data) { base.NetLoginHandler(data); if (Client.State == ClientState.Uninitialized) { RefreshNetInfo("正在登录PlayFab..."); Client.State = ClientState.Queued; LoginWithCustomIDRequest request = new LoginWithCustomIDRequest() { TitleId = TitleId, CreateAccount = true, CustomId = data.CustomID }; PlayFabClientAPI.LoginWithCustomID(request, loginResult => { PlayFabId = loginResult.PlayFabId; CustomId = data.CustomID; if (loginResult.NewlyCreated) { RefreshNetInfo("登录成功,正在为新用户设置名称..."); UpdateUserTitleDisplayNameRequest request2 = new UpdateUserTitleDisplayNameRequest() { DisplayName = data.CustomID }; PlayFabClientAPI.UpdateUserTitleDisplayName(request2, result2 => { DisplayName = data.CustomID; RefreshUserInfo(); // PlayFab 部分登录及初始化完毕 OnPlayFabSuccessLogin(); }, error2 => { ResetUserInfo(); Client.State = ClientState.Uninitialized; RefreshNetInfo("错误:未能更新用户显示名称"); }); } else { RefreshNetInfo("登录成功,正在同步用户信息..."); GetUserCombinedInfoRequest r1 = new GetUserCombinedInfoRequest() { PlayFabId = PlayFabId }; PlayFabClientAPI.GetUserCombinedInfo(r1, rs1 => { DisplayName = rs1.AccountInfo.TitleInfo.DisplayName; RefreshUserInfo(); // PlayFab 部分登录及初始化完毕 OnPlayFabSuccessLogin(); }, re1 => { ResetUserInfo(); Client.State = ClientState.Uninitialized; RefreshNetInfo("错误:未能获取用户信息"); }); } }, error => { ResetUserInfo(); Client.State = ClientState.Uninitialized; RefreshNetInfo("错误:未能成功登录 PlayFab"); }); } }