/// <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()); }
/// <summary> /// Parsuje wiadomość. /// </summary> /// <param name="msg">Wiadomość.</param> public ResourceAdded(Message msg) { if (msg.Type != (MessageType)GameMessageType.ResourceAdded) { throw new InvalidCastException("Cannot convert this message to ResourceAdded"); } BinarySerializer s = new BinarySerializer(msg.Data); this.ResourceId = s.GetString(); this.NumericResourceId = s.GetUInt32(); this.Amount = s.GetUInt32(); this.Position = s.GetFloat(); }