Beispiel #1
0
        public void HandleRoomJoinPacket(Client client, Packet packet)
        {
            C2SRoomJoinPacket roomJoinPacket = new C2SRoomJoinPacket(packet);
            Room room = this.GameHandler.Rooms.Find(r => r.Id == roomJoinPacket.RoomId);

            S2CRoomJoinAnswer roomJoinAnswer = new S2CRoomJoinAnswer(0, 0, 0, 0);

            client.PacketStream.Write(roomJoinAnswer);
            client.ActiveRoom = room;

            S2CRoomInformation roomInformationPacket = new S2CRoomInformation(room);

            client.PacketStream.Write(roomInformationPacket);

            RoomPlayer roomPlayer = new RoomPlayer();

            roomPlayer.Character = client.ActiveCharacter;
            roomPlayer.Position  = 1;
            roomPlayer.Master    = false;
            room.CurrentPlayers.Add(roomPlayer);

            List <Client> clientsInRoom = this.GameHandler.GetClientsInRoom(room.Id);

            foreach (Client roomClient in clientsInRoom)
            {
                S2CRoomPlayerInformation roomPlayerInformationPacket =
                    new S2CRoomPlayerInformation(room.CurrentPlayers);
                roomClient.PacketStream.Write(roomPlayerInformationPacket);
            }
        }
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);
            }
        }