Beispiel #1
0
        public void HandleRoomListReqPacket(Client client, Packet packet)
        {
            // To Do: C2SRoomListReqPacket
            S2CRoomListAnswerPacket roomListAnswerPacket = new S2CRoomListAnswerPacket(this.GameHandler.Rooms);

            client.PacketStream.Write(roomListAnswerPacket);
        }
Beispiel #2
0
        public void HandleRoomCreatePacket(Client client, Packet packet)
        {
            C2SRoomCreatePacket roomCreatePacket = new C2SRoomCreatePacket(packet);

            // Still needs fixes
            Room room = new Room();

            room.Id           = Convert.ToInt16(this.GameHandler.Rooms.Count);
            room.Name         = roomCreatePacket.Name;
            room.GameMode     = 0;
            room.BattleMode   = roomCreatePacket.GameMode;
            room.Level        = client.ActiveCharacter.Level;
            room.LevelRange   = roomCreatePacket.LevelRange;
            room.Map          = 1;
            room.Betting      = false;
            room.BettingCoins = 0;
            room.BettingGold  = 0;
            room.MaxPlayer    = roomCreatePacket.Players;

            RoomPlayer roomPlayer = new RoomPlayer();

            roomPlayer.Character = client.ActiveCharacter;
            roomPlayer.Position  = 0;
            roomPlayer.Master    = true;
            room.CurrentPlayers.Add(roomPlayer);

            this.GameHandler.Rooms.Add(room);

            client.ActiveRoom = room;

            Packet roomCreateAnswerPacket = new Packet(PacketId.S2CRoomCreateAnswer);

            roomCreateAnswerPacket.Write(0);
            client.PacketStream.Write(roomCreateAnswerPacket);

            S2CRoomInformation roomInformationPacket = new S2CRoomInformation(room);

            client.PacketStream.Write(roomInformationPacket);

            S2CRoomPlayerInformation roomPlayerInformationPacket = new S2CRoomPlayerInformation(room.CurrentPlayers);

            client.PacketStream.Write(roomPlayerInformationPacket);

            List <Client>           clientsInLobby       = this.GameHandler.GetClientsInLobby();
            S2CRoomListAnswerPacket roomListAnswerPacket = new S2CRoomListAnswerPacket(this.GameHandler.Rooms);

            foreach (Client c in clientsInLobby)
            {
                c.PacketStream.Write(roomListAnswerPacket);
            }
        }