// 点击开始,进入游戏 public void OnEnterGame() { if (mSelectIndex < 0) { ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_90")); return; } // 保存本地玩家ID UnitID uid = new UnitID(); uid.type = (byte)EUnitType.UNITTYPE_PLAYER; uid.obj_idx = (uint)mData [mSelectIndex].uuid; Game.GetInstance().LocalPlayerID = uid; Game.GetInstance().LocalPlayerTypeID = ActorHelper.RoleIdToTypeId(mData [mSelectIndex].rid); Game.GetInstance().LocalPlayerName = System.Text.Encoding.UTF8.GetString(mData [mSelectIndex].name); // 保存选择的角色索引 GlobalSettings.GetInstance().LastActorIndex = mSelectIndex; GlobalSettings.GetInstance().Save(); // Enter Game C2SEnterGame c2sEnterGame = new C2SEnterGame(); c2sEnterGame.uuid = mData[mSelectIndex].uuid; NetClient.GetBaseClient().SendData <C2SEnterGame>(NetMsg.MSG_ENTER_GAME, c2sEnterGame); GlobalConfig.GetInstance().LoginInfo.Name = System.Text.Encoding.UTF8.GetString(mData[mSelectIndex].name); GlobalConfig.GetInstance().LoginInfo.RId = mData [mSelectIndex].uuid.ToString(); GlobalConfig.GetInstance().LoginInfo.Job = mData [mSelectIndex].rid.ToString(); GlobalConfig.GetInstance().LoginInfo.Level = mData[mSelectIndex].level.ToString(); ControlServerLogHelper.GetInstance().PostRoleInfo(); // 注册FCM DBOSManager.getOSBridge().registerFCM(); DBOSManager.getOSBridge().registerPush(); // 为确保进入场景的角色等级判断正确,这里要赋值给LocalPlayerManager LocalPlayerManager.Instance.LocalActorAttribute.Level = mData[mSelectIndex].level; Game.Instance.IsCreateRoleEnter = false; xc.ui.ugui.UIManager.Instance.ShowWaitScreen(true); // 点击选角按钮 ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.ClickSelectActorButton); ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.select_role); }
/// <summary> /// 响应注册的网络消息 /// </summary> /// <param name="protocol"></param> /// <param name="data"></param> void HandleCreateRole(ushort protocol, byte[] data) { if (protocol != NetMsg.MSG_CREATE_ROLE) { return; } var create_role = S2CPackBase.DeserializePack <S2CCreateRole>(data); if (create_role.result != 1) // 创建不成功 { string content = ""; DBErrorCode db_error_code = (DBErrorCode)DBManager.GetInstance().GetDB(typeof(DBErrorCode).Name); DBErrorCode.ErrorInfo errorInfo = db_error_code.GetErrorInfo(create_role.result); if (errorInfo == null) { content = xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_35"); } else { content = errorInfo.mDesc; } GameDebug.LogError(string.Format("服务端报错: {0}", content)); UINotice.GetInstance().ShowMessage(content); UIManager.Instance.ShowWaitScreen(false); return; } // 保存本地玩家ID UnitID uid = new UnitID(); uid.type = (byte)EUnitType.UNITTYPE_PLAYER; uid.obj_idx = (uint)create_role.uuid; Game.GetInstance().LocalPlayerID = uid; Game.GetInstance().LocalPlayerTypeID = ActorHelper.RoleIdToTypeId(mVocationId); Game.GetInstance().LocalPlayerName = mNameInputField.text; // 保存角色职业信息 GlobalConfig.GetInstance().LoginInfo.RId = create_role.uuid.ToString(); GlobalConfig.GetInstance().LoginInfo.Job = mVocationId.ToString(); GlobalConfig.GetInstance().LoginInfo.Level = "0"; GlobalConfig.GetInstance().LoginInfo.CreateRoleTime = create_role.now.ToString(); // 通知服务端 var enter_game = new C2SEnterGame(); enter_game.uuid = create_role.uuid; NetClient.GetBaseClient().SendData <C2SEnterGame>(NetMsg.MSG_ENTER_GAME, enter_game); // 通知控制服 ControlServerLogHelper.GetInstance().PostRoleInfo(); // 通知sdk,sendRoleInfo2SDK要求等级最小为1,需要特殊处理 GlobalConfig.GetInstance().LoginInfo.Level = "1"; SDKControler.getSDKControler().sendRoleInfo2SDK((int)SDKControler.RoleEvent.CREATE_ROLE); // 创角埋点数据上报 if (xc.Const.Region == xc.RegionType.KOREA) { xc.BuriedPointHelper.ReportTapjoyEvnet("account generate"); } // 注册FCM DBOSManager.getOSBridge().registerFCM(); // 注册推送服务 DBOSManager.getOSBridge().registerPush(); }
void OnClickCreateNewRoleButton() { string char_name = mNameInputField.text; // 判断是否输入了角色名 if (char_name.Length <= 0) { ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL1")); //请输入角色名 return; } // 韩国版的角色名字和聊天敏感字库读取不同的表,其他 if (Const.Region == RegionType.KOREA) { // 判断角色名字是否合法 if (SensitiveWordsFilterPlayerName.Instance.IsInputUserNameLegal(char_name) == false) { ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL2")); //角色名请使用汉字,英文或者数字 return; } // 判断角色名中的敏感字符 if (SensitiveWordsFilterPlayerName.GetInstance().IsHaveSensitiveWords(char_name)) { ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL3"));//角色名中包含敏感字符 return; } } else { // 判断角色名字是否合法 if (SensitiveWordsFilter.Instance.IsInputUserNameLegal(char_name, Const.Region) == false) { ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL2")); //角色名请使用汉字,英文或者数字 return; } // 判断角色名中的敏感字符 if (SensitiveWordsFilter.GetInstance().IsHaveSensitiveWords(char_name)) { ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL3"));//角色名中包含敏感字符 return; } } // 判断角色名字是否超长 var utf8_parse = new Utf8Parse(char_name); float role_name_len = utf8_parse.GetWordLenByRule(); if (role_name_len > (float)GameConstHelper.GetFloat("GAME_NAME_MAX_COUNT")) { UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("NAME_COUNT_EXCEED")); GameDebug.Log("role_name_len:" + role_name_len); return; } if (GlobalConfig.GetInstance().LoginInfo == null || GlobalConfig.GetInstance().LoginInfo.ServerInfo == null) { return; } mVocationId = 4; // 发送创建角色的协议 var create_role = new C2SCreateRole(); create_role.name = System.Text.Encoding.UTF8.GetBytes(char_name);; create_role.rid = mVocationId; // actor type, 从1开始 create_role.server_id = (uint)GlobalConfig.GetInstance().LoginInfo.ServerInfo.SId; if (string.IsNullOrEmpty(GlobalConfig.GetInstance().LoginInfo.ProviderPassport)) { create_role.chn_passport = System.Text.Encoding.UTF8.GetBytes("provider_passport"); } else { create_role.chn_passport = System.Text.Encoding.UTF8.GetBytes(GlobalConfig.GetInstance().LoginInfo.ProviderPassport); } if (AuditManager.Instance.AuditAndIOS()) { SDKConfig sdkConfig = SDKHelper.GetSDKConfig(); if (sdkConfig != null) { create_role.majia_id = sdkConfig.copy_bag_id; create_role.majia_pack = sdkConfig.copy_bag_id; } } else { SDKConfig sdkConfig = SDKHelper.GetSDKConfig(); if (sdkConfig != null) { create_role.majia_id = 0; create_role.majia_pack = sdkConfig.copy_bag_id; } } ControlServerLogHelper.CreatePkgAccPhoneInfos(create_role.phone_info); NetClient.GetBaseClient().SendData <C2SCreateRole>(NetMsg.MSG_CREATE_ROLE, create_role); // 保存创建角色的名字 GlobalConfig.GetInstance().LoginInfo.Name = char_name; // 记录上一次选中的职业 GlobalSettings.GetInstance().LastActorIndex = Game.GetInstance().CharacterList.Count; GlobalSettings.GetInstance().Save(); Game.Instance.IsCreateRoleEnter = true; UIManager.Instance.ShowWaitScreen(true); // 点击创角按钮 ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.ClickCreateActorButton); ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.create_role); // 点击选角按钮 ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.ClickSelectActorButton); ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.select_role); }