public override void SerializeWithCompressor(Compressor c) { c.WriteNumber((int)MessageType.Shot, Enum.GetNames(typeof(MessageType)).Length); c.WriteNumber(_MessageId, GlobalSettings.MaxACK); CompressingUtils.WriteTime(c, _TimeStamp); c.WriteNumber(targetId, GlobalSettings.MaxPlayers); }
public override void SerializeWithCompressor(Compressor c) { c.WriteNumber((int)MessageType.PlayerInput, Enum.GetNames(typeof(MessageType)).Length); c.WriteNumber(_MessageId, int.MaxValue); CompressingUtils.WriteTime(c, _TimeStamp); c.WriteNumber((int)Action, Enum.GetNames(typeof(PlayerAction)).Length); }
public override void SerializeWithCompressor(Compressor c) { c.WriteNumber((int)MessageType.ClientConnect, Enum.GetNames(typeof(MessageType)).Length); c.WriteNumber(_MessageId, int.MaxValue); CompressingUtils.WriteTime(c, _TimeStamp); c.WriteString(name); }
public static GameMessage ClientConnectDeserialize(Decompressor decompressor) { int id = decompressor.GetNumber(int.MaxValue); float time = CompressingUtils.GetTime(decompressor); String name = decompressor.GetString(); return(new ClientConnectMessage(id, name, time, false)); }
private static GameMessage ShotDeserialize(Decompressor decompressor) { int id = decompressor.GetNumber(GlobalSettings.MaxACK); float time = CompressingUtils.GetTime(decompressor); int targetid = decompressor.GetNumber(GlobalSettings.MaxPlayers); return(new ShotMessage(id, targetid, time, false)); }
public static GameMessage PlayerInputDeserialize(Decompressor decompressor) { int id = decompressor.GetNumber(int.MaxValue); float time = CompressingUtils.GetTime(decompressor); PlayerAction action = (PlayerAction)decompressor.GetNumber(Enum.GetNames(typeof(PlayerAction)).Length); return(new PlayerInputMessage(action, id, time, false)); }
public override void SerializeWithCompressor(Compressor c) { c.WriteNumber((int)MessageType.ConnectConfirmation, Enum.GetNames(typeof(MessageType)).Length); c.WriteNumber(_MessageId, GlobalSettings.MaxACK); c.WriteNumber(id, GlobalSettings.MaxPlayers); CompressingUtils.WriteTime(c, _TimeStamp); c.WriteString(name); }
public override byte[] Serialize() { Compressor c = new Compressor(); c.WriteNumber((int)MessageType.Rotation, Enum.GetNames(typeof(MessageType)).Length); CompressingUtils.WriteRotation(c, rot); return(c.GetBuffer()); }
public void serializeWithCompressor(Compressor c) { c.WriteNumber(id, GlobalSettings.MaxPlayers); CompressingUtils.WriteTime(c, _TimeStamp); c.WriteNumber(this.Health, GlobalSettings.MaxHealth); c.PutBit(this.Invulnerable); CompressingUtils.WritePosition(c, position); c.WriteNumber(lastId, GlobalSettings.MaxACK); }
public static GameMessage ConnectedClientDeserialize(Decompressor decompressor) { int mssgid = decompressor.GetNumber(GlobalSettings.MaxACK); int id = decompressor.GetNumber(GlobalSettings.MaxPlayers); float timeStamp = CompressingUtils.GetTime(decompressor); String name = decompressor.GetString(); return(new ClientConnectedMessage(mssgid, id, name, timeStamp, false)); }
public override byte[] Serialize() { Compressor compressor = new Compressor(); compressor.WriteNumber((int)MessageType.ClientConnect, Enum.GetNames(typeof(MessageType)).Length); compressor.WriteNumber(_MessageId, int.MaxValue); CompressingUtils.WriteTime(compressor, _TimeStamp); compressor.WriteString(name); return(compressor.GetBuffer()); }
public override byte[] Serialize() { Compressor compressor = new Compressor(); compressor.WriteNumber((int)MessageType.PlayerInput, Enum.GetNames(typeof(MessageType)).Length); compressor.WriteNumber(_MessageId, int.MaxValue); CompressingUtils.WriteTime(compressor, _TimeStamp); compressor.WriteNumber((int)Action, Enum.GetNames(typeof(PlayerAction)).Length); return(compressor.GetBuffer()); }
public override byte[] Serialize() { Compressor c = new Compressor(); c.WriteNumber((int)MessageType.Shot, Enum.GetNames(typeof(MessageType)).Length); c.WriteNumber(_MessageId, GlobalSettings.MaxACK); CompressingUtils.WriteTime(c, _TimeStamp); c.WriteNumber(targetId, GlobalSettings.MaxPlayers); return(c.GetBuffer()); }
public override void SerializeWithCompressor(Compressor c) { c.WriteNumber((int)MessageType.WorldSnapshot, Enum.GetNames(typeof(MessageType)).Length); CompressingUtils.WriteTime(c, time); c.WriteNumber(_numberOfPlayers, GlobalSettings.MaxPlayers); foreach (PlayerSnapshot playerSnapshot in _playerSnapshots) { playerSnapshot.serializeWithCompressor(c); } }
public override byte[] Serialize() { Compressor compressor = new Compressor(); compressor.WriteNumber((int)MessageType.ConnectConfirmation, Enum.GetNames(typeof(MessageType)).Length); compressor.WriteNumber(_MessageId, GlobalSettings.MaxACK); compressor.WriteNumber(id, GlobalSettings.MaxPlayers); CompressingUtils.WriteTime(compressor, _TimeStamp); compressor.WriteString(name); return(compressor.GetBuffer()); }
public byte[] serialize() { Compressor compressor = new Compressor(); compressor.WriteNumber(id, GlobalSettings.MaxPlayers); CompressingUtils.WriteTime(compressor, _TimeStamp); compressor.WriteNumber(this.Health, GlobalSettings.MaxHealth); compressor.PutBit(this.Invulnerable); CompressingUtils.WritePosition(compressor, position); compressor.WriteNumber(lastId, GlobalSettings.MaxACK); return(compressor.GetBuffer()); }
public static PlayerSnapshot SnapshotDeserialize(Decompressor decompressor) { int id = decompressor.GetNumber(GlobalSettings.MaxPlayers); PlayerSnapshot playerSnapshot = new PlayerSnapshot(id); playerSnapshot._TimeStamp = CompressingUtils.GetTime(decompressor); playerSnapshot.Health = decompressor.GetNumber(GlobalSettings.MaxHealth); playerSnapshot.Invulnerable = decompressor.GetBoolean(); playerSnapshot.position = CompressingUtils.GetPosition(decompressor); playerSnapshot.lastId = decompressor.GetNumber(GlobalSettings.MaxACK); return(playerSnapshot); }
public override byte[] Serialize() { Compressor compressor = new Compressor(); compressor.WriteNumber((int)MessageType.WorldSnapshot, Enum.GetNames(typeof(MessageType)).Length); CompressingUtils.WriteTime(compressor, time); compressor.WriteNumber(_numberOfPlayers, GlobalSettings.MaxPlayers); foreach (PlayerSnapshot playerSnapshot in _playerSnapshots) { playerSnapshot.serializeWithCompressor(compressor); } return(compressor.GetBuffer()); }
public static GameMessage WorldSnapshotDeserialize(Decompressor decompressor) { float time = CompressingUtils.GetTime(decompressor); int numberOfPlayers = decompressor.GetNumber(GlobalSettings.MaxPlayers); List <PlayerSnapshot> playerSnapshots = new List <PlayerSnapshot>(); for (int i = 0; i < numberOfPlayers; i++) { playerSnapshots.Add(SnapshotDeserialize(decompressor)); } return(new WorldSnapshotMessage(playerSnapshots, time)); }
public override void SerializeWithCompressor(Compressor c) { c.WriteNumber((int)MessageType.Rotation, Enum.GetNames(typeof(MessageType)).Length); CompressingUtils.WriteRotation(c, rot); }
public static GameMessage RotationDeserialize(Decompressor decompressor) { Vector3 rot = CompressingUtils.GetRotation(decompressor); return(new RotationMessage(rot)); }