예제 #1
0
 public LeaveGamePacket(byte[] binaryLeaveGamePacket)
 {
     this.playerIdField = BitConverter.ToUInt16(binaryLeaveGamePacket, 2);
     this.gameIdField = BitConverter.ToUInt16(binaryLeaveGamePacket, 4);
     this.packetIdField = new PacketIdCounter(BitConverter.ToUInt16(binaryLeaveGamePacket, 6));
     this.timestampField = DateTime.FromBinary(BitConverter.ToInt64(binaryLeaveGamePacket, 8));
 }
예제 #2
0
        public GameInfoPacket(byte[] binaryGameInfoPacket)
        {
            int pos = 2;
            packetIdField = new PacketIdCounter(BitConverter.ToUInt16(binaryGameInfoPacket,pos));
            pos += 2;
            timestampField=DateTime.FromBinary(BitConverter.ToInt64(binaryGameInfoPacket,pos));
            pos += 8;
            gameIdField = BitConverter.ToUInt16(binaryGameInfoPacket, pos);
            pos += 2;

            playerStatusListField = new List<PlayerStatus>();

            int playerCount = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos);
            pos += 2;

            for (int i = 0; i < playerCount; i++)
            {
                int psLength = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos);
                pos += 2;
                PlayerStatus ps = new PlayerStatus(binaryGameInfoPacket, pos);
                pos += psLength;
                playerStatusListField.Add(ps);
            }

            int teamScoreCount = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos);

            pos += 2;
            teamScoreListField = new List<TeamData>();

            for (int i = 0; i < teamScoreCount; i++)
            {
                TeamData ts = new TeamData();
                ts.TeamId = BitConverter.ToUInt16(binaryGameInfoPacket, pos);
                pos += 2;
                ts.TeamScore = BitConverter.ToUInt16(binaryGameInfoPacket, pos);
                pos += 2;
                int count = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos);
                pos += 2;
                ts.TeamName = Encoding.UTF8.GetString(binaryGameInfoPacket, pos, count);
                pos += count;
                teamScoreListField.Add(ts);
            }

            this.gameTypeField = (Constants.GameTypeEnumeration)BitConverter.ToUInt16(binaryGameInfoPacket, pos);
            pos += 2;
            this.limitField = BitConverter.ToUInt16(binaryGameInfoPacket, pos);
            pos += 2;

            int addressLength = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos);
            pos += 2;
            string address = Encoding.UTF8.GetString(binaryGameInfoPacket, pos, addressLength);
            pos += addressLength;
            int port = BitConverter.ToInt32(binaryGameInfoPacket, pos);
            pos += 4;
            serverAddressField = new IPEndPoint(IPAddress.Parse(address), port);

            roundNumberField = BitConverter.ToUInt16(binaryGameInfoPacket, pos);
        }
예제 #3
0
 public ServerPacket(byte[] binaryServerPacket)
 {
     this.packetIdField = new PacketIdCounter( BitConverter.ToUInt16(binaryServerPacket, 2));
     int playerNumber = BitConverter.ToUInt16(binaryServerPacket, 4);
     this.timestampField = DateTime.FromBinary(BitConverter.ToInt64(binaryServerPacket, 6));
     this.playerInfoListField = new List<PlayerInfo>();
     int positionIn = 14;
     for (int i = 0; i < playerNumber; i++)
     {
         PlayerInfo info = new PlayerInfo(binaryServerPacket, positionIn);
         positionIn += info.ByteCount;
         playerInfoListField.Add(info);
     }
 }
예제 #4
0
 public ServerPacket()
 {
     playerInfoListField = new List<PlayerInfo>();
     packetIdField = new PacketIdCounter();
 }
예제 #5
0
 public ClientPacket()
     : base()
 {
     this.packetIdField = new PacketIdCounter();
 }
예제 #6
0
 public ClientPacket(byte[] binaryClientPacket)
     : base(binaryClientPacket, 2)
 {
     this.packetIdField = new PacketIdCounter(BitConverter.ToUInt16(binaryClientPacket, base.ByteCount + 2));
     this.timestampField = DateTime.FromBinary(BitConverter.ToInt64(binaryClientPacket, base.ByteCount + 4));
 }
예제 #7
0
 public LeaveGamePacket()
 {
     this.packetIdField = new PacketIdCounter();
 }
예제 #8
0
 public GameInfoPacket()
 {
     this.packetIdField = new PacketIdCounter();
     this.playerStatusListField = new List<PlayerStatus>();
     this.teamScoreListField = new List<TeamData>();
 }