/// <summary> /// 整个房间的初始化 /// </summary> private async void Init() { PlayerInit(); //选择英雄的时间 await Task.Delay(selectHeroTime); //是不是所有玩家都锁定了英雄 if (lockCount == (roomInfo.TeamA.Count + roomInfo.TeamB.Count)) { //所有人都锁定了选择的英雄 //可以加载战斗了 RoomToBattleS2C s2cMSG = new RoomToBattleS2C(); foreach (var rolesID in playerList.Keys) { UClient client = GameManager.uSocket.GetClient (PlayerManager.GetPlayerEntityFromRoles(rolesID).session); //缓存每一个客户端 为广播接口服务的 clientList.TryAdd(rolesID, client); s2cMSG.PlayerList.Add(playerList[rolesID]); } Broadcast(1407, s2cMSG); } else { //解散房间 RoomCloseS2C s2cMSG = new RoomCloseS2C(); Broadcast(1403, s2cMSG); //通知房间管理器 释放掉这个房间 RoomManager.Instance.Remove(roomID); } }
/// <summary> /// 解散房间 /// </summary> /// <param name="response"></param> private void HandleRoomCloseS2C(BufferEntity response) { RoomCloseS2C s2cMSG = ProtobufHelper.FromBytes <RoomCloseS2C>(response.proto); Close(); RoomCtrl.Instance.RemoveRoomInfo(); WindowManager.Instance.OpenWindow(WindowType.LobbyWindow); }