Esempio n. 1
0
        public static ClientUpdate Decode(byte[] bytes, int offset = 0)
        {
            int ID = Serialization.DecodeInt(bytes, offset);

            offset += 4;
            int pID = Serialization.DecodeInt(bytes, offset);

            offset += 4;
            PressedKeys keys = (PressedKeys)bytes[offset];

            offset += 1;
            bool left = Serialization.DecodeBool(bytes, offset);

            offset += 1;
            bool right = Serialization.DecodeBool(bytes, offset);

            offset += 1;
            float mAngle = Serialization.DecodeFloat(bytes, offset);

            offset += 4;
            double dt = Serialization.DecodeDouble(bytes, offset);

            offset += 8;
            return(new ClientUpdate(ID, pID, keys, mAngle, left, right, dt));
        }
Esempio n. 2
0
        public PlayersStateCmd(byte[] bytes, int offset = 0) :
            base(CommandType.PlayersStates)
        {
            int numPlayers = (bytes.Length - headerSize) / bytesPerPlayer;

            playerStates = new List <PlayersStateCommand.PlayerState>();

            while (numPlayers-- > 0)
            {
                var ID = Serialization.DecodeInt(bytes, offset);
                offset += 4;
                var pos = Serialization.DecodeVec3(bytes, offset);
                offset += Vector3.SizeInBytes;
                var tankAngle = Serialization.DecodeFloat(bytes, offset);
                offset += 4;
                var towerAngle = Serialization.DecodeFloat(bytes, offset);
                offset += 4;
                var fireCooldown = Serialization.DecodeDouble(bytes, offset);
                offset += 8;
                var currShields = bytes[offset++];
                var currHealth  = bytes[offset++];
                playerStates.Add(new PlayersStateCommand.PlayerState(ID, pos, tankAngle, towerAngle, fireCooldown, currHealth, currShields));
            }
        }