//自己进入房间的消息被服务器处理,返回给自己 static void ClientJoinRoomRsp(JoinRoomRsp rsp) { //如果规则是暗杀或者死斗 //自己进入房间成功时的信息,跳转到选角色界面,角色选择,就跳转到武器选择界面 //到最后一步确认后,开始同步服务器场景数据. if (rsp.result == 1) { if (Main.Ins.NetWorkBattle.RoomId == -1) { //选人,或者阵营,或者 //UnityEngine.Debug.LogError("OnJoinRoom successful"); //if (MainLobby.Exist) // MainLobby.Instance.Close(); //if (RoomOptionWnd.Exist) // RoomOptionWnd.Instance.Close(); Main.Ins.NetWorkBattle.OnEnterRoomSuccessed((int)rsp.roomId, (int)rsp.levelIdx, (int)rsp.playerId); UdpClientProxy.Connect((int)rsp.port, (int)rsp.playerId); RoomInfo r = Main.Ins.RoomMng.GetRoom((int)rsp.roomId); //如果是盟主模式,无需选择阵营 //if (r.rule == RoomInfo.RoomRule.MZ) // RoleSelectWnd.Instance.Open(); //else // CampSelectWnd.Instance.Open(); } //U3D.LoadNetLevel((int)rsp.levelIdx, LevelMode.MultiplyPlayer, GameMode.MENGZHU); } else { //显示各种错误信息框 //rsp.reason //2未找到 //3需要退出当前房间 //1房间满 UnityEngine.Debug.LogError(string.Format("error:{0}", rsp.reason)); switch (rsp.reason) { case 1: U3D.PopupTip("此房间已满,无法进入"); break; case 2: U3D.PopupTip("房间已解散"); break; case 3: U3D.PopupTip("需要先退出房间"); break; //密码不正确 case 4: Main.Ins.EnterState(Main.Ins.PsdEditDialogState); PsdEditDialogState.Instance.OnConfirm = () => { Common.SendJoinRoom((int)rsp.roomId, PsdEditDialogState.Instance.Control("PsdField").GetComponent <UnityEngine.UI.InputField>().text); PsdEditDialogState.Instance.OnBackPress(); }; break; } } }
////其他人进入我所在的房间,消息发给我 //static void OnEnterRoomRsp_(JoinRoomRsp rsp) //{ // //显示某某进入房间的文字 // GameOverlayWnd.Instance.InsertSystemMsg(string.Format("{0} 进入房间", rsp.playerNick)); //} //创建房间OK时自动进入房间. static void ClientAutoJoinRoom(CreateRoomRsp rsp) { if (Main.Ins.NetWorkBattle.RoomId == -1) { //选人,或者阵营,或者 //if (MainLobby.Exist) // MainLobby.Instance.Close(); //if (RoomOptionWnd.Exist) // RoomOptionWnd.Instance.Close(); Main.Ins.NetWorkBattle.OnEnterRoomSuccessed((int)rsp.roomId, (int)rsp.levelId, (int)rsp.playerId); UdpClientProxy.Connect((int)rsp.port, (int)rsp.playerId); RoomInfo r = Main.Ins.RoomMng.GetRoom((int)rsp.roomId); //如果是盟主模式,无需选择阵营 //if (r.rule == RoomInfo.RoomRule.MZ) // RoleSelectWnd.Instance.Open(); //else // CampSelectWnd.Instance.Open(); } }