/// <summary> /// Parsuje wiadomość. /// </summary> /// <param name="msg">Wiadomość.</param> public PlayerAccepted(Message msg) { if (msg.Type != (MessageType)GameMessageType.PlayerAccepted) { throw new InvalidCastException("Cannot convert this message to PlayerAccepted"); } BinarySerializer s = new BinarySerializer(msg.Data); this.UserId = s.GetUInt32(); this.InGame = s.GetBool(); ushort players = s.GetUInt16(); this.Players = new List<IPlayerData>(); for (int i = 0; i < players; i++) { var player = new Player.PlayerData(s.GetUInt32()); player.Nick = s.GetString(); player.InGame = s.GetBool(); this.Players.Add(player); } ushort nations = s.GetUInt16(); this.AvailableNations = new List<string>(); for (int i = 0; i < nations; i++) { this.AvailableNations.Add(s.GetString()); } }
/// <summary> /// Parsuje wiadomość. /// </summary> /// <param name="msg">Wiadomość.</param> public UnitQueueAction(Message msg) { if (msg.Type != (MessageType)GameMessageType.UnitQueueAction) { throw new InvalidCastException("Cannot convert this message to CreateUnit"); } BinarySerializer s = new BinarySerializer(msg.Data); this.UnitId = s.GetString(); this.Created = s.GetBool(); }