Ejemplo n.º 1
0
        public FightRoom GetRoomByUId(int uid)
        {
            if (uIdRoomIdDict.ContainsKey(uid) == false)
            {
                throw new Exception(string.Format("The user id is {0} is not in room", uid));
            }
            int       roomId = uIdRoomIdDict[uid];
            FightRoom room   = GetRoom(roomId);

            return(room);
        }
Ejemplo n.º 2
0
 public void Destroy(FightRoom room)
 {
     idRoomDict.Remove(room.Id);
     foreach (PlayerDto player in room.PlayerList)
     {
         uIdRoomIdDict.Remove(player.UserId);
     }
     //init room data
     room.PlayerList.Clear();
     room.TableCardList.Clear();
     room.libraryModel.Init();
     roomQueue.Enqueue(room);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// create fight room
        /// </summary>
        /// <param name="uidList"></param>
        /// <returns></returns>
        public FightRoom Create(List <int> uidList)
        {
            FightRoom room = null;

            if (roomQueue.Count > 0)
            {
                room = roomQueue.Dequeue();
                room.Init(uidList);
            }
            else
            {
                room = new FightRoom(id.Add_Get(), uidList);
            }

            foreach (int uid in uidList)
            {
                uIdRoomIdDict.Add(uid, room.Id);
                ClientPeer client = userCache.GetClientPeer(uid);
                room.StartFight(uid, client);
            }
            idRoomDict.Add(room.Id, room);
            return(room);
        }