public GameOptions() { teamOneNameField = "TeamOne"; teamTwoNameField = "TeamTwo"; gameTypeField = UDPClientServerCommons.Constants.GameTypeEnumeration.FragLimit; gameLimitField= 10; }
public GameOptions(string TeamOneName, string TeamTwoName, Constants.GameTypeEnumeration GameType, ushort GameLimit) { this.teamOneNameField = TeamOneName; this.teamTwoNameField = TeamTwoName; this.gameLimitField = GameLimit; this.gameTypeField = GameType; }
public GameInfoPacket(byte[] binaryGameInfoPacket) { int pos = 2; packetIdField = new PacketIdCounter(BitConverter.ToUInt16(binaryGameInfoPacket,pos)); pos += 2; timestampField=DateTime.FromBinary(BitConverter.ToInt64(binaryGameInfoPacket,pos)); pos += 8; gameIdField = BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; playerStatusListField = new List<PlayerStatus>(); int playerCount = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; for (int i = 0; i < playerCount; i++) { int psLength = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; PlayerStatus ps = new PlayerStatus(binaryGameInfoPacket, pos); pos += psLength; playerStatusListField.Add(ps); } int teamScoreCount = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; teamScoreListField = new List<TeamData>(); for (int i = 0; i < teamScoreCount; i++) { TeamData ts = new TeamData(); ts.TeamId = BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; ts.TeamScore = BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; int count = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; ts.TeamName = Encoding.UTF8.GetString(binaryGameInfoPacket, pos, count); pos += count; teamScoreListField.Add(ts); } this.gameTypeField = (Constants.GameTypeEnumeration)BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; this.limitField = BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; int addressLength = (int)BitConverter.ToUInt16(binaryGameInfoPacket, pos); pos += 2; string address = Encoding.UTF8.GetString(binaryGameInfoPacket, pos, addressLength); pos += addressLength; int port = BitConverter.ToInt32(binaryGameInfoPacket, pos); pos += 4; serverAddressField = new IPEndPoint(IPAddress.Parse(address), port); roundNumberField = BitConverter.ToUInt16(binaryGameInfoPacket, pos); }