/// <summary> /// Parsuje wiadomość. /// </summary> /// <param name="msg">Wiadomość.</param> public PlayerDisconnected(Message msg) { if (msg.Type != (MessageType)GameMessageType.PlayerDisconnected) { throw new InvalidCastException("Cannot convert this message to PlayerDisconnected"); } BinarySerializer s = new BinarySerializer(msg.Data); this.UserId = s.GetUInt32(); this.Reason = (DisconnectionReason)s.GetByte(); }
/// <summary> /// Parsuje wiadomość. /// </summary> /// <param name="msg">Wiadomość.</param> public PlayerHurt(Message msg) { if (msg.Type != (MessageType)GameMessageType.PlayerHurt) { throw new InvalidCastException("Cannot convert this message to PlayerHurt"); } BinarySerializer s = new BinarySerializer(msg.Data); this.PlayerId = s.GetByte(); this.Value = s.GetInt32(); }
/// <summary> /// Parsuje wiadomość. /// </summary> /// <param name="msg">Wiadomość.</param> public UnitDestroyed(Message msg) { if (msg.Type != (MessageType)GameMessageType.UnitDestroyed) { throw new InvalidCastException("Cannot convert this message to UnitDestroyed"); } BinarySerializer s = new BinarySerializer(msg.Data); this.PlayerId = s.GetByte(); this.UnitId = s.GetUInt32(); }
/// <summary> /// Parsuje wiadomość. /// </summary> /// <param name="msg">Wiadomość.</param> public UnitCreated(Message msg) { if (msg.Type != (MessageType)GameMessageType.UnitCreated) { throw new InvalidCastException("Cannot convert this message to UnitCreated"); } BinarySerializer s = new BinarySerializer(msg.Data); this.PlayerId = s.GetByte(); this.UnitId = s.GetString(); this.NumericUnitId = s.GetUInt32(); this.Position = new Vector2(s.GetFloat(), s.GetFloat()); }