예제 #1
0
        public static Packet AnnounceGame(GameDefinition gameDefinition)
        {
            var packet = new Packet();

            packet.Type = gameDefinition.GameTypeInfo.PacketType;
            packet.Data.Add(new Signature(SignatureType.Data, gameDefinition.GameId));
            packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.GameTimeMinutes)));
            packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.Tags)));
            packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.Reloads)));
            packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.Shields)));
            packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.Mega)));

            var flags1 = (byte)((gameDefinition.ExtendedTagging ? 1 : 0) << 7 |
                                (gameDefinition.LimitedReloads ? 1 : 0) << 6 |
                                (gameDefinition.LimitedMega ? 1 : 0) << 5 |
                                (gameDefinition.TeamTags ? 1 : 0) << 4 |
                                (gameDefinition.MedicMode ? 1 : 0) << 3 |
                                (gameDefinition.SlowTags ? 1 : 0) << 2 |
                                (gameDefinition.GameTypeInfo.HuntThePrey ? 1 : 0) << 1 |
                                (gameDefinition.GameTypeInfo.ReverseHuntDirection ? 1 : 0) << 0);

            var flags2 = (byte)((gameDefinition.GameTypeInfo.Zones ? 1 : 0) << 7 |
                                (gameDefinition.GameTypeInfo.TeamZones ? 1 : 0) << 6 |
                                (gameDefinition.GameTypeInfo.NeutralizePlayersTaggedInZone ? 1 : 0) << 5 |
                                (gameDefinition.GameTypeInfo.ZonesRevivePlayers ? 1 : 0) << 4 |
                                (gameDefinition.GameTypeInfo.HospitalZones ? 1 : 0) << 3 |
                                (gameDefinition.GameTypeInfo.ZonesTagPlayers ? 1 : 0) << 2 |
                                (gameDefinition.TeamCount & 0x03));

            // hard code these here for now
            switch (gameDefinition.GameType)
            {
            case GameType.Respawn:                     // RESP
            case GameType.RespawnTwoTeams:             // 2TRS
            case GameType.RespawnThreeTeams:           // 3TRS
                flags1 |= 0x80;
                flags2 |= 0x30;
                break;
            }

            packet.Data.Add(new Signature(SignatureType.Data, flags1));
            packet.Data.Add(new Signature(SignatureType.Data, flags2));

            if (gameDefinition.GameTypeInfo.PacketType == PacketType.AnnounceGameSpecial)
            {
                packet.Data.AddRange(gameDefinition.GameTypeInfo.Name.GetSignatures(4, true));
            }

            packet.PopulateChecksum();

            return(packet);
        }
예제 #2
0
        public static Packet Countdown(UInt16 gameId, byte remainingSeconds, int playerCountTeam1, int playerCountTeam2, int playerCountTeam3)
        {
            var packet = new Packet();

            packet.Type = PacketType.AnnounceCountdown;
            packet.Data.Add(new Signature(SignatureType.Data, gameId));
            packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal(remainingSeconds)));
            packet.Data.Add(new Signature(SignatureType.Data, (UInt16)(playerCountTeam1 & 0xff)));
            packet.Data.Add(new Signature(SignatureType.Data, (UInt16)(playerCountTeam2 & 0xff)));
            packet.Data.Add(new Signature(SignatureType.Data, (UInt16)(playerCountTeam3 & 0xff)));
            packet.PopulateChecksum();

            return(packet);
        }
예제 #3
0
 public Signature(BinaryCodedDecimal data, byte bitCount = 8)
     : this(SignatureType.Data, data, bitCount)
 {
 }
예제 #4
0
 public Signature(SignatureType type, BinaryCodedDecimal data, byte bitCount = 8)
     : this(type, (UInt16)data.BinaryCodedValue, bitCount)
 {
 }
예제 #5
0
 public void DataAdd(BinaryCodedDecimal data)
 {
     Data.Add(new Signature(data));
 }