/// <summary> /// 创建房间 /// </summary> private async void OnCreateRoom() { try { RoomInfo ToServerinfo = new RoomInfo(); ToServerinfo.GameCount = 10; ToServerinfo.GameScore = 20; ToServerinfo.PlayerCount = 2; G2C_CreateRoom RoomInfo = await SessionComponent.Instance.Session.Call(new C2G_CreateRoom() { Room = ToServerinfo }) as G2C_CreateRoom; Log.Debug($"RoomInfo={RoomInfo.Room.GameCount},{RoomInfo.Room.GameScore},{RoomInfo.Room.PlayerCount}"); //添加房间配置 RoomConfig config = new RoomConfig(); config.GameCount = RoomInfo.Room.GameCount; config.GamePlayer = RoomInfo.Room.PlayerCount; config.RoomId = RoomInfo.RoomId; config.GameScore = RoomInfo.Room.GameScore; GameTools.GetUser().ChairId = RoomInfo.ChairID; RoomComponent roomComponent = Game.Scene.GetComponent <RoomComponent>(); if (roomComponent == null) { Game.Scene.AddComponent <RoomComponent, RoomConfig>(config); } else { roomComponent.SetRoomConfig(config); } Game.Scene.GetComponent <UIComponent>().CreateOrShow(UIType.UIRoom); this.Close(); } catch (Exception e) { } }
private async ETVoid Send_C2G_CreateRoom() { C2G_CreateRoom msg = new C2G_CreateRoom(); msg.PeopleNum = this.GetPeopleNum(); msg.MapId = this.GetMapName(); msg.BigModel = this.GetBigModel(); msg.SmallModel = this.GetSmallModel(); msg.RoomNam = this.GetRoomName(); G2C_CreateRoom response = (G2C_CreateRoom)await ETModel.SessionComponent.Instance.Session.Call(msg); if (response.Error == ErrorCode.ERR_Success) { await FUIFactory.Create <RoomViewComponent>(FUIType.Room); this.OnClose(); } }