Exemplo n.º 1
0
 public static void strokeWidth(ref PathOutline pO, float nextValf)
 {
     if (pO != null)
     {
         pO.outlineSize = nextValf;
     }
 }
Exemplo n.º 2
0
 public static void y2(ref PathOutline pO, float nextValf)
 {
     if (pO == null)
     {
         pO = new PathOutline();
     }
     pO.points[1].Y = nextValf;
 }
Exemplo n.º 3
0
 public static void style(ref GameObjectData obj, ref PathOutline pO, string nextVal)
 {
     string[] split = nextVal.Split(';', ':');
     for (int i = 0; i < split.Length; i += 2)
     {
         ApplyThisAttributeValue(ref obj, ref pO, split[i], split[i + 1], 0f);
     }
 }
Exemplo n.º 4
0
 public static void PathOutline(ref PathOutline obj, string nextVal)
 {
     obj = new PathOutline();
     float[]   xArray;
     float[]   yArray;
     Vector2[] points;
     CustomConversions.DPathToPoints(nextVal, out xArray, out yArray, out points);
     obj.points = points;
 }
Exemplo n.º 5
0
        static void XMLToGameObjectData(string _path, out List <GameObjectData> gameObjectsData, out List <PathOutline> pathOutlinesData)
        {
            gameObjectsData  = new List <GameObjectData>();
            pathOutlinesData = new List <PathOutline>();

            string      xml = File.ReadAllText(_path);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            var nodes = doc.LastChild.ChildNodes;

            for (int i = 0; i < nodes.Count; i++)
            {
                if (nodes.Item(i).Name == "g")
                {
                    nodes = nodes.Item(i).ChildNodes;
                }
            }

            for (int i = 0; i < nodes.Count; i++)
            {
                var item = nodes.Item(i);
                if (isTypeConvertableToPAObject(item.Name))
                {
                    var  attributes = nodes.Item(i).Attributes;
                    bool isShapeNull;
                    gameObjectsData.Add(new GameObjectData()
                    {
                        ID             = GenerateID(999).ToString(),
                        Shape          = GetVarFromShapeName.Shape(item.Name, out isShapeNull),
                        offset         = GetVarFromShapeName.Offset(item.Name),
                        isShapeUnknown = isShapeNull
                    });
                    if (nodes.Item(i).Name == "path")
                    {
                        pathOutlinesData.Add(new PathOutline());
                    }
                    else
                    {
                        pathOutlinesData.Add(null);
                    }

                    GameObjectData obj = gameObjectsData[gameObjectsData.Count - 1];
                    PathOutline    pO  = pathOutlinesData[pathOutlinesData.Count - 1];
                    for (int a = 0; a < attributes.Count; a++)
                    {
                        LineWriter.WriteLine(attributes.Item(a).Name + ", " + attributes.Item(a).Value);
                        float valuef = GameObjectData.IsFloatAttribute(attributes.Item(a).Value) ? float.Parse(attributes.Item(a).Value) : 0;
                        DataAppliers.ApplyThisAttributeValue(ref obj, ref pO, attributes.Item(a).Name, attributes.Item(a).Value, valuef);
                    }
                    gameObjectsData[i]  = obj;
                    pathOutlinesData[i] = pO;
                }
                LineWriter.WriteLine("NEW OBJECT!! type:{" + item.Name + "}" + i);
            }
        }
Exemplo n.º 6
0
        public static void ApplyThisAttributeValue(ref GameObjectData obj, ref PathOutline pO, string attribute, string value, float valueFloat)
        {
            Shapes?shape = null;

            if (attribute == "d")
            {
                D(ref obj, value, out shape);
                if (shape == null)
                {
                    Multi.PathOutline(ref pO, value);
                }
            }
            if (shape != null)
            {
                obj.Shape = shape.Value;
            }
            switch (attribute)
            {
            case "x":
            case "cx": X(ref obj, valueFloat); break;

            case "y":
            case "cy": Y(ref obj, valueFloat); break;

            case "width":
            case "rx": sizeX(ref obj, valueFloat, attribute); break;

            case "height":
            case "ry": sizeY(ref obj, valueFloat, attribute); break;

            case "transform": translate(ref obj, value); break;

            case "r": size(ref obj, valueFloat); break;

            case "stroke": fill(ref obj, value); stroke(ref obj); break;

            case "stroke-width": strokeWidth(ref pO, valueFloat); break;

            case "fill": fill(ref obj, value); break;

            case "x1": x1(ref pO, valueFloat); break;

            case "x2": x2(ref pO, valueFloat); break;

            case "y1": y1(ref pO, valueFloat); break;

            case "y2": y2(ref pO, valueFloat); break;

            case "points": points(ref pO, value); break;

            case "style": style(ref obj, ref pO, value); break;
            }
        }
Exemplo n.º 7
0
 public static void points(ref PathOutline pO, string nextVal)
 {
     string[]  pointsStr = nextVal.Split(' ', ',');
     Vector2[] points    = new Vector2[pointsStr.Length / 2];
     for (int i = 0; i < pointsStr.Length / 2; i++)
     {
         points[i] = new Vector2(float.Parse(pointsStr[i * 2]), float.Parse(pointsStr[(i * 2) + 1]));
     }
     if (pO == null)
     {
         pO = new PathOutline();
     }
     pO.points = points;
 }