Ejemplo n.º 1
0
 public PlayerConnectedCmd(byte[] bytes, int offset = 0) :
     base(CommandType.PlayerConnected)
 {
     pID  = Serialization.DecodeInt(bytes, offset);
     pCol = Serialization.DecodeVec3(bytes, offset + 4);
     pPos = Serialization.DecodeVec3(bytes, offset + 4 + Vector3.SizeInBytes);
 }
Ejemplo n.º 2
0
 public PlayerDeathCmd(byte[] bytes, int offset = 0) :
     base(CommandType.PlayerDeath)
 {
     killedID = Serialization.DecodeInt(bytes, offset);
     offset  += 4;
     killerID = Serialization.DecodeInt(bytes, offset);
     offset  += 4;
     rPos     = Serialization.DecodeVec3(bytes, offset);
     offset  += 4;
 }
Ejemplo n.º 3
0
        public static ConnectingDynamicData Decode(byte[] bytes, int startIndex)
        {
            int offset     = startIndex;
            var numPlayers = Serialization.DecodeInt(bytes, offset);

            offset += 4;
            var numPickups = Serialization.DecodeInt(bytes, offset);

            offset += 4;
            var players = new Dictionary <int, Engine.Player>(numPlayers);

            for (int i = 0; i < numPlayers; ++i)
            {
                var pID = Serialization.DecodeInt(bytes, offset);
                offset += 4;
                var pos = Serialization.DecodeVec3(bytes, offset);
                offset += OpenTK.Vector3.SizeInBytes;
                var col = Serialization.DecodeVec3(bytes, offset);
                offset += OpenTK.Vector3.SizeInBytes;
                var killCount = Serialization.DecodeInt(bytes, offset);
                offset += 4;
                var deathCount = Serialization.DecodeInt(bytes, offset);
                offset += 4;
                players.Add(pID, new Engine.Player(pID, pos, col, killCount, deathCount));
            }
            var pickups = new Dictionary <int, Engine.ShieldPickup>(numPickups);

            for (int i = 0; i < numPickups; ++i)
            {
                var pID = Serialization.DecodeInt(bytes, offset);
                offset += 4;
                var pos = Serialization.DecodeVec3(bytes, offset);
                offset += OpenTK.Vector3.SizeInBytes;
                var state = Serialization.DecodeBool(bytes, offset);
                offset += 1;
                pickups.Add(pID, new Engine.ShieldPickup(pos, state));
            }
            return(new ConnectingDynamicData(players, pickups));
        }
Ejemplo n.º 4
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));
            }
        }