Пример #1
0
        /// <summary>
        /// 摧毁房间
        /// </summary>
        /// <param name="roomId"></param>
        public void DestroyRoom(int roomId)
        {
            SelectRoom room;

            if (!RoomDict.TryGetValue(roomId, out room))
            {
                return;
            }

            // 移除玩家id和房间id的映射
            foreach (int item in room.TeamOneDict.Keys)
            {
                PlayerRoomDict.Remove(item);
            }
            foreach (int item in room.TeamTwoDict.Keys)
            {
                PlayerRoomDict.Remove(item);
            }
            // 移除房间id和房间的映射
            RoomDict.Remove(roomId);

            // 清空房间内的数据
            room.Clear();

            // 回收
            RoomQue.Enqueue(room);

            MobaServer.LogInfo("选人房间销毁了");
        }
Пример #2
0
        /// <summary>
        /// 摧毁指定房间
        /// </summary>
        /// <param name="room"></param>
        public void DestroyRoom(int roomId)
        {
            BattleRoom room;

            if (!RoomDict.TryGetValue(roomId, out room))
            {
                return;
            }

            // 移除玩家id和房间id的映射
            foreach (DtoHero item in room.HerosArray)
            {
                PlayerRoomDict.Remove(item.Id);
            }

            // 移除房间id和房间的映射
            RoomDict.Remove(roomId);

            // 清空房间内的数据
            room.Clear();
            // 回收
            RoomQue.Enqueue(room);

            MobaServer.LogInfo("战斗房间销毁了");
        }
Пример #3
0
        /// <summary>
        /// 摧毁指定房间
        /// </summary>
        /// <param name="room"></param>
        public void DestroyRoom(MatchRoom room)
        {
            // 移除玩家id和房间id的映射
            foreach (int item in room.TeamOneIdList)
            {
                PlayerRoomDict.Remove(item);
            }
            foreach (int item in room.TeamTwoIdList)
            {
                PlayerRoomDict.Remove(item);
            }
            // 移除房间id和房间的映射
            RoomDict.Remove(room.Id);
            // 清空房间信息
            room.Clear();

            // 回收
            RoomQue.Enqueue(room);
        }
Пример #4
0
        /// <summary>
        /// 玩家离开匹配队列
        /// </summary>
        /// <param name="peer"></param>
        /// <param name="playerId"></param>
        /// <returns>是否离开成功</returns>
        public bool StopMatch(MobaPeer peer, int playerId)
        {
            // 获取房间
            MatchRoom room = GetRoomByPlayerId(playerId);

            if (room == null)
            {
                return(false);
            }

            room.LeaveRoom(peer, playerId);
            PlayerRoomDict.Remove(playerId);

            if (room.IsEmpty)
            {
                // 移除映射
                RoomDict.Remove(room.Id);
                // 清理房间
                room.Clear();
                // 回收房间
                RoomQue.Enqueue(room);
            }
            return(true);
        }