public override byte[] Serialize() { List <byte> s = new List <byte>(); // serialize Width s.Add((byte)((Width == null) ? 0 : 1)); if (Width != null) { s.AddRange(BitConverter.GetBytes((int)Width)); } // serialize Height s.Add((byte)((Height == null) ? 0 : 1)); if (Height != null) { s.AddRange(BitConverter.GetBytes((int)Height)); } // serialize Board s.Add((byte)((Board == null) ? 0 : 1)); if (Board != null) { List <byte> tmp14 = new List <byte>(); tmp14.AddRange(BitConverter.GetBytes((uint)Board.Count())); while (tmp14.Count > 0 && tmp14.Last() == 0) { tmp14.RemoveAt(tmp14.Count - 1); } s.Add((byte)tmp14.Count); s.AddRange(tmp14); foreach (var tmp15 in Board) { s.Add((byte)((tmp15 == null) ? 0 : 1)); if (tmp15 != null) { List <byte> tmp16 = new List <byte>(); tmp16.AddRange(BitConverter.GetBytes((uint)tmp15.Count())); while (tmp16.Count > 0 && tmp16.Last() == 0) { tmp16.RemoveAt(tmp16.Count - 1); } s.Add((byte)tmp16.Count); s.AddRange(tmp16); foreach (var tmp17 in tmp15) { s.Add((byte)((tmp17 == null) ? 0 : 1)); if (tmp17 != null) { s.Add((byte)((sbyte)tmp17)); } } } } } // serialize Scores s.Add((byte)((Scores == null) ? 0 : 1)); if (Scores != null) { List <byte> tmp18 = new List <byte>(); tmp18.AddRange(BitConverter.GetBytes((uint)Scores.Count())); while (tmp18.Count > 0 && tmp18.Last() == 0) { tmp18.RemoveAt(tmp18.Count - 1); } s.Add((byte)tmp18.Count); s.AddRange(tmp18); foreach (var tmp19 in Scores) { s.Add((byte)((tmp19.Key == null) ? 0 : 1)); if (tmp19.Key != null) { List <byte> tmp20 = new List <byte>(); tmp20.AddRange(BitConverter.GetBytes((uint)tmp19.Key.Count())); while (tmp20.Count > 0 && tmp20.Last() == 0) { tmp20.RemoveAt(tmp20.Count - 1); } s.Add((byte)tmp20.Count); s.AddRange(tmp20); s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(tmp19.Key)); } s.Add((byte)((tmp19.Value == null) ? 0 : 1)); if (tmp19.Value != null) { s.AddRange(BitConverter.GetBytes((int)tmp19.Value)); } } } // serialize Pacman s.Add((byte)((Pacman == null) ? 0 : 1)); if (Pacman != null) { s.AddRange(Pacman.Serialize()); } // serialize Ghosts s.Add((byte)((Ghosts == null) ? 0 : 1)); if (Ghosts != null) { List <byte> tmp21 = new List <byte>(); tmp21.AddRange(BitConverter.GetBytes((uint)Ghosts.Count())); while (tmp21.Count > 0 && tmp21.Last() == 0) { tmp21.RemoveAt(tmp21.Count - 1); } s.Add((byte)tmp21.Count); s.AddRange(tmp21); foreach (var tmp22 in Ghosts) { s.Add((byte)((tmp22 == null) ? 0 : 1)); if (tmp22 != null) { s.AddRange(tmp22.Serialize()); } } } // serialize Constants s.Add((byte)((Constants == null) ? 0 : 1)); if (Constants != null) { s.AddRange(Constants.Serialize()); } return(s.ToArray()); }