public void Btn_Create() { if (TelentDrawController.instance && TelentDrawController.instance.ChatOk) { PlayerInfoPara playerInfoPara = new PlayerInfoPara { Name = usrCreateName.text.Trim(), CustomProfile = "customStr", CustomPlayerStatus = 0, }; CreateRoomPara createRoomPara = new CreateRoomPara { RoomName = roomCreateName.text.Trim(), RoomType = "customStr", MaxPlayers = uint.Parse(numCreatePlayer.text.Trim()), IsPrivate = true, CustomProperties = "CustomProperties", PlayerInfo = playerInfoPara, }; TelentDrawController.instance.PlayerInfoPara = playerInfoPara; TelentDrawController.instance.CreatePara = createRoomPara; TelentDrawController.instance.paintJoinState = PaintJoinState.Create; TelentDrawController.instance.CurrentRoomName = roomCreateName.text.Trim(); SceneManager.LoadScene("PaintCanvas2"); } }
/// <summary> /// 创建房间 /// createRoom 调用结果将在 callback 中异步返回。操作成功后,roomInfo 属性将更新。 /// 创建房间成功后,玩家自动进入该房间,因此无法继续调用 joinRoom、matchPlayers 等方法,可以利用房间ID邀请其他玩家进入该房间。 /// </summary> /// <param name="SDKType.CreateRoomPara"></param> /// <param name="createRoomPara"></param> /// <param name="callback"></param> public void CreateRoom(CreateRoomPara createRoomPara, Action <ResponseEvent> callback) { Sdk.Instance.CreateRoom(createRoomPara, (eve) => { if (eve.Data != null) { var rsp = new CreateRoomRsp(); rsp.MergeFrom((ByteString)eve.Data); eve.Data = rsp.RoomInfo?.ToByteString(); this.RoomUtil.SaveRoomInfo(eve); eve.Data = rsp; } callback?.Invoke(eve); }); }
void CreateRoom() { var param = new CreateRoomPara { RoomName = waitStartInfo.roomName, RoomType = "TODO", MaxPlayers = 4, IsPrivate = !string.IsNullOrEmpty(waitStartInfo.password), CustomProperties = "TODO", PlayerInfo = MakeMyPlayerInfo(), }; Global.Room.CreateRoom(param, (e) => { Debug.Log("create room callback"); Debug.Log(e); if (e.Code == ErrCode.EcOk) { AddAction(() => this.StartGame()); } }); }