예제 #1
0
        private int ReadPolygon(XmlNode polyNode, bool closed)
        {
            string attributeContent = GetAttributeContent(polyNode, "points");

            if (attributeContent == "ERROR")
            {
                return(0);
            }
            List <float> list = ParseFloatArray(attributeContent);

            if (list.Count % 2 != 0)
            {
                UnityEngine.Debug.LogWarning("There is an error with one of the polygon shapes.");
                return(0);
            }
            string text = GetAttributeContent(polyNode, "id");

            if (text == "ERROR")
            {
                text = fileName + ((!closed) ? "_polyline" : "_polygon ") + (polygons.Count + 1);
            }
            buffer = new SplineDefinition(text, Spline.Type.Linear);
            int num = list.Count / 2;

            for (int i = 0; i < num; i++)
            {
                buffer.position = new Vector2(list[2 * i], 0f - list[1 + 2 * i]);
                buffer.CreateLinear();
            }
            if (closed)
            {
                buffer.CreateClosingPoint();
                buffer.closed = true;
            }
            int result = ParseTransformation(polyNode);

            WriteBufferTo(polygons);
            return(result);
        }
예제 #2
0
        private int ReadPolygon(XmlNode polyNode, bool closed)
        {
            string contents = GetAttributeContent(polyNode, "points");

            if (contents == "ERROR")
            {
                return(0);
            }
            List <float> coords = ParseFloatArray(contents);

            if (coords.Count % 2 != 0)
            {
                Debug.LogWarning("There is an error with one of the polygon shapes.");
                return(0);
            }
            string elementName = GetAttributeContent(polyNode, "id");

            if (elementName == "ERROR")
            {
                elementName = fileName + (closed ? "_polygon " : "_polyline") + (polygons.Count + 1);
            }
            buffer = new SplineDefinition(elementName, Spline.Type.Linear);
            int count = coords.Count / 2;

            for (int i = 0; i < count; i++)
            {
                buffer.position = new Vector2(coords[0 + 2 * i], -coords[1 + 2 * i]);
                buffer.CreateLinear();
            }
            if (closed)
            {
                buffer.CreateClosingPoint();
                buffer.closed = true;
            }
            int addedTransforms = ParseTransformation(polyNode);

            WriteBufferTo(polygons);
            return(addedTransforms);
        }