private static void LoadSinglePolygon(XmlTextReader xmlReader, NavMesh navMesh) { ConvexPolygon polygon = new ConvexPolygon(); xmlReader.MoveToContent(); while (xmlReader.Read()) { if ("point" == xmlReader.Name) { float x = float.Parse(xmlReader.GetAttribute("x")); float y = float.Parse(xmlReader.GetAttribute("y")); polygon.Vertices.Add(new Point(x, y)); } else if ("polygon" == xmlReader.Name) { polygon.GenerateEdges(); navMesh.AddPolygon(polygon); return; } } }