Пример #1
0
        /// <summary>
        /// 销毁房间
        /// </summary>
        /// <param name="room"></param>
        public void Destroy(FightRoom room)
        {
            foreach (var item in room.playerList)
            {
                if (IsFighting(item.UserId))//有些人提前离开了 就提前已经删除了
                {
                    uIdRidDic.Remove(item.UserId);
                }
            }
            rIdRoomDic.Remove(room.id);

            //清空房间
            room.Destroy();
            roomQueue.Enqueue(room);
        }
Пример #2
0
        /// <summary>
        /// 创建房间
        /// </summary>
        /// <param name="userIds"></param>
        /// <returns></returns>
        public FightRoom Creat(List <int> userIds)
        {
            FightRoom room = null;

            //if (roomQueue.Count > 0)
            //{
            //    room = roomQueue.Dequeue();
            //}
            //else
            //{
            //    room = new FightRoom(id.Add_Get(),userIds);
            //}
            room = new FightRoom(id.Add_Get(), userIds);
            room.Init(userIds);
            //存储
            foreach (var id in userIds)
            {
                uIdRidDic.Add(id, room.id);
            }

            rIdRoomDic.Add(room.id, room);
            return(room);
        }