public void copyValues(XmlElement element) { if (element.HasAttributes && element.Attributes.GetNamedItem("rotation").Value != null) { rotation = float.Parse(element.Attributes.GetNamedItem("rotation").Value); } foreach (XmlElement itemChild in element) { if (itemChild.Name.Equals("name")) { name = itemChild.FirstChild.Value; } else if (itemChild.Name.Equals("loc")) { string[] locStr = itemChild.FirstChild.Value.Split(','); loc = new Vector2(float.Parse(locStr[0]), float.Parse(locStr[1])); } else if (itemChild.Name.Equals("radius")) { radius = uint.Parse(itemChild.FirstChild.Value); } else if (itemChild.Name.Equals("startdepth")) { startdepth = uint.Parse(itemChild.FirstChild.Value); } else if (itemChild.Name.Equals("weight")) { weight = uint.Parse(itemChild.FirstChild.Value); } else if (itemChild.Name.Equals("width")) { width = uint.Parse(itemChild.FirstChild.Value); } else if (itemChild.Name.Equals("immovable")) { immovable = bool.Parse(itemChild.FirstChild.Value); } else if (itemChild.Name.Equals("sideLengths")) { sideLengths = XMLUtil.fromXMLVector2(itemChild); } else if (itemChild.Name.Equals("polygonType")) { polygonType = (PhysicsPolygonType)Enum.Parse(typeof(PhysicsPolygonType), itemChild.FirstChild.Value); } } //else if (itemChild.Name.Equals("vertices")) //{ // vertices = new Vertices(); // foreach (XmlElement vertexElement in itemChild.GetElementsByTagName("vertex")) // vertices.Add(XMLUtil.fromXMLVector2(vertexElement)); //} try { guid = Guid.Parse(element.GetAttribute("guid")); } catch (Exception e) { Console.WriteLine(e.StackTrace); guid = Guid.NewGuid(); } }