Example #1
0
 private void PathStart(string name, string coords, bool relative)
 {
     if (buffer != null)
     {
         WriteBufferTo(paths);
     }
     buffer = new SplineDefinition(name, Spline.Type.Bezier);
     if (relative)
     {
         buffer.position = paths.Last().GetLastPoint().position;
     }
     Vector2[] vectors = ParseVector2(coords);
     foreach (Vector3 vector in vectors)
     {
         if (relative)
         {
             buffer.position += vector;
         }
         else
         {
             buffer.position = vector;
         }
         buffer.CreateLinear();
     }
 }
Example #2
0
        private int ReadLine(XmlNode lineNode)
        {
            float  result           = 0f;
            float  result2          = 0f;
            float  result3          = 0f;
            float  result4          = 0f;
            string attributeContent = GetAttributeContent(lineNode, "x1");

            if (attributeContent == "ERROR")
            {
                return(0);
            }
            float.TryParse(attributeContent, out result);
            attributeContent = GetAttributeContent(lineNode, "y1");
            if (attributeContent == "ERROR")
            {
                return(0);
            }
            float.TryParse(attributeContent, out result2);
            attributeContent = GetAttributeContent(lineNode, "x2");
            if (attributeContent == "ERROR")
            {
                return(0);
            }
            float.TryParse(attributeContent, out result3);
            attributeContent = GetAttributeContent(lineNode, "y2");
            if (attributeContent == "ERROR")
            {
                return(0);
            }
            float.TryParse(attributeContent, out result4);
            string text = GetAttributeContent(lineNode, "id");

            if (text == "ERROR")
            {
                text = fileName + "_line" + (ellipses.Count + 1);
            }
            buffer          = new SplineDefinition(text, Spline.Type.Linear);
            buffer.position = new Vector2(result, 0f - result2);
            buffer.CreateLinear();
            buffer.position = new Vector2(result3, 0f - result4);
            buffer.CreateLinear();
            int result5 = ParseTransformation(lineNode);

            WriteBufferTo(lines);
            return(result5);
        }
Example #3
0
        private int ReadLine(XmlNode lineNode)
        {
            float  startX = 0f, startY = 0f, endX = 0f, endY = 0f;
            string attribute = GetAttributeContent(lineNode, "x1");

            if (attribute == "ERROR")
            {
                return(0);
            }
            float.TryParse(attribute, out startX);
            attribute = GetAttributeContent(lineNode, "y1");
            if (attribute == "ERROR")
            {
                return(0);
            }
            float.TryParse(attribute, out startY);
            attribute = GetAttributeContent(lineNode, "x2");
            if (attribute == "ERROR")
            {
                return(0);
            }
            float.TryParse(attribute, out endX);
            attribute = GetAttributeContent(lineNode, "y2");
            if (attribute == "ERROR")
            {
                return(0);
            }
            float.TryParse(attribute, out endY);
            string elementName = GetAttributeContent(lineNode, "id");

            if (elementName == "ERROR")
            {
                elementName = fileName + "_line" + (ellipses.Count + 1);
            }
            buffer          = new SplineDefinition(elementName, Spline.Type.Linear);
            buffer.position = new Vector2(startX, -startY);
            buffer.CreateLinear();
            buffer.position = new Vector2(endX, -endY);
            buffer.CreateLinear();
            int addedTransforms = ParseTransformation(lineNode);

            WriteBufferTo(lines);
            return(addedTransforms);
        }
Example #4
0
 private void PathStart(string name, string coords, bool relative)
 {
     if (buffer != null)
     {
         WriteBufferTo(paths);
     }
     buffer = new SplineDefinition(name, Spline.Type.Bezier);
     Vector2[] array  = ParseVector2(coords);
     Vector2[] array2 = array;
     foreach (Vector3 vector in array2)
     {
         if (relative)
         {
             buffer.position += vector;
         }
         else
         {
             buffer.position = vector;
         }
         buffer.CreateLinear();
     }
 }
Example #5
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);
        }
Example #6
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);
        }