public List<Polygon> loadPolygons(TextureItem item, string property) { List<Polygon> polygons = new List<Polygon>(); int numberToLoad = 1; int numberOfLoaded = 0; bool loadNext = true; while (loadNext) { string tempProperty = property + numberToLoad.ToString(); if (item.CustomProperties.ContainsKey(tempProperty)) { //Console.WriteLine(tempProperty); if (item.CustomProperties[tempProperty].type == typeof(Item)) { Console.WriteLine(tempProperty + " Loaded"); PathItem pathItem = (PathItem)item.CustomProperties[tempProperty].value; if (pathItem != null) { List<Vector2> liste = new List<Vector2>(pathItem.WorldPoints); Polygon polygon = new Polygon(); foreach (Vector2 point in liste) { polygon.getPoints().Add(point); } polygon.buildEdges(); polygons.Add(polygon); numberToLoad++; numberOfLoaded++; } else { loadNext = false; } } } else { loadNext = false; } } if (numberOfLoaded == 0) { polygons = null; //Console.WriteLine("Did not load Polygons"); } return polygons; }