Ejemplo n.º 1
0
        public static HotSpringRoom GetHotSpringRoombyID(int id, string pwd, ref string msg)
        {
            HotSpringRoom room = null;

            _locker.AcquireReaderLock();
            try
            {
                if (id > 0)
                {
                    if (_Rooms.Keys.Contains(id))
                    {
                        if (_Rooms[id].Info.Pwd != pwd)
                        {
                            msg = "Game.Server.Managers.PWDError";
                        }
                        else
                        {
                            room = _Rooms[id];
                        }
                    }
                }
            }
            finally
            {
                _locker.ReleaseReaderLock();
            }
            return(room);
        }
Ejemplo n.º 2
0
 //public static HotSpringRoom[] GetAllHotRoom()
 //{
 //    if (ROOM.Count == 0)
 //    {
 //        Caprom();
 //    }
 //    return ROOM.ToArray();
 //}
 public static HotSpringRoom[] GetAllHotSpringRoom()
 {
     HotSpringRoom[] list = null;
     _locker.AcquireReaderLock();
     try
     {
         list = new HotSpringRoom[_Rooms.Count];
         _Rooms.Values.CopyTo(list, 0);
     }
     finally
     {
         _locker.ReleaseReaderLock();
     }
     return(list == null ? new HotSpringRoom[0] : list);
 }
Ejemplo n.º 3
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player.CurrentHotSpringRoom != null)
            {
                int           iD   = client.Player.CurrentHotSpringRoom.Info.RoomID;
                HotSpringRoom room = client.Player.CurrentHotSpringRoom;
                using (PlayerBussiness db = new PlayerBussiness())
                {
                    db.UpdateHotSpringRoomInfo(room.Info);
                }

                GSPacketIn pkg = new GSPacketIn(0xa9);
                pkg.WriteString("Bạn đã thoát khỏi phòng");
                client.SendTCP(pkg);
            }
            return(0);
        }
Ejemplo n.º 4
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int num = packet.ReadInt();

            try
            {
                TankHotSpringLogicProcessor processor = new TankHotSpringLogicProcessor();
                HotSpringRoomInfo           info      = new HotSpringRoomInfo {
                    RoomID = num
                };
                client.Player.CurrentHotSpringRoom = new HotSpringRoom(info, processor);
            }
            catch
            {
                Console.WriteLine("System Error!");
            }
            HotSpringRoom room = client.Player.CurrentHotSpringRoom;

            using (PlayerBussiness db = new PlayerBussiness())
            {
                db.UpdateHotSpringRoomInfo(room.Info);
            }
            string     str = packet.ReadString();
            GSPacketIn pkg = new GSPacketIn(0xca);

            pkg.WriteInt(num);
            pkg.WriteInt(num);
            pkg.WriteString(room.Info.RoomName);
            pkg.WriteString(room.Info.Pwd);
            pkg.WriteInt(1);
            pkg.WriteInt(1);
            pkg.WriteInt(client.Player.PlayerCharacter.ID);
            pkg.WriteString(client.Player.PlayerCharacter.NickName);
            pkg.WriteDateTime(room.Info.BeginTime);
            pkg.WriteString(room.Info.RoomIntroduction);
            pkg.WriteInt(1);
            pkg.WriteInt(10);
            pkg.WriteDateTime(DateTime.Now);
            pkg.WriteInt(10);
            client.SendTCP(pkg);
            return(0);
        }
Ejemplo n.º 5
0
        //public static HotSpringRoom GetHotRoombyID(int id, string pw, ref string msg)
        //{
        //    return ROOM[id - 1];
        //}

        public static HotSpringRoom CreateHotSpringRoomFromDB(HotSpringRoomInfo roomInfo, int timeLeft)
        {
            HotSpringRoom room = null;

            _locker.AcquireWriterLock();
            try
            {
                room = new HotSpringRoom(roomInfo, _processor);
                if (room != null)
                {
                    _Rooms.Add(room.Info.RoomID, room);

                    room.BeginTimer(60 * 1000 * timeLeft);
                    return(room);
                }
            }
            finally
            {
                _locker.ReleaseWriterLock();
            }

            return(null);
        }