public static RoomStage Create(NetRoomInfo roomInfo)
        {
            RoomStage stage = new RoomStageNormal();

            stage.Initialize(roomInfo);
            return(stage);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建房间
        /// </summary>
        public bool CreateRoom(NetRoomInfo roomInfo, NetworkingPlayer player = null)
        {
            if (roomDict.ContainsKey(roomInfo.roomUid))
            {
                // 创建房间失败, 房间 已经存在
                string error = string.Format("创建房间失败, 房间ID={0}, 已经存在", roomInfo.roomUid);

                OnCreateRoomFailed(roomInfo.roomUid, error);


                if (player != null)
                {
                    BMSByte data  = ObjectMapper.BMSByte(false, roomInfo.roomUid, error);
                    Binary  frame = new Binary(Socket.Time.Timestep, false, data, Receivers.Target, MessageGroupIds.Lobby, false, RouterIds.LOBBY_CREATE_ROOM);
                    Send(player, frame, true);
                }
                return(false);
            }

            // 创建房间成功
            NetRoomServer room = new NetRoomServer(this, roomInfo);

            roomDict.Add(room.roomId, room);

            OnCreateRoomSuccessed(room.roomId);


            if (player != null)
            {
                BMSByte data  = ObjectMapper.BMSByte(true, roomInfo.roomUid, string.Empty);
                Binary  frame = new Binary(Socket.Time.Timestep, false, data, Receivers.Target, MessageGroupIds.Lobby, false, RouterIds.LOBBY_CREATE_ROOM);
                Send(player, frame, true);
            }
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建房间
        /// </summary>
        private void CreateRoom(NetworkingPlayer player, Binary frame)
        {
            NetRoomInfo roomInfo = new NetRoomInfo();

            roomInfo.roomUid = frame.StreamData.GetBasicType <ulong>();
            roomInfo.stageId = frame.StreamData.GetBasicType <int>();
            CreateRoom(roomInfo, player);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化
        /// </summary>
        protected virtual void Initialize(LobbyBase lobby, NetRoomInfo roomInfo)
        {
            this.lobby  = lobby;
            this.roomId = roomInfo.roomUid;
            this.Time   = lobby.Socket.Time;

            stage = StageFactory.Create(roomInfo);
            scene = stage.Scene;
        }
        public NetRoomClient(LobbyClient lobby, NetRoomInfo roomInfo)
        {
            this.clientLobby = lobby;

            Initialize(lobby, roomInfo);
        }
Exemplo n.º 6
0
 public void Initialize(NetRoomInfo roomInfo)
 {
     Scene = new RoomScene(this);
 }
Exemplo n.º 7
0
        public NetRoomServer(LobbyServer lobby, NetRoomInfo roomInfo)
        {
            this.serverLobby = lobby;

            Initialize(lobby, roomInfo);
        }