Exemple #1
0
        //UPDATE
        TextureDrawer getTDXML(string name)
        {
            XDocument texes = XDocument.Load("Content/Textures.xml");

            foreach (XElement tex in texes.Element("Textures").Elements("Texture"))
            {
                if (tex.Attribute("name").Value == name)
                {
                    if (tex.Element("Center") == null)
                    {
                        return(new TextureDrawer(Content.Load <Texture2D>(tex.Attribute("source").Value), tex.Attribute("truename").Value));
                    }
                    else if (tex.Element("Anim") == null)
                    {
                        int fc = int.Parse(tex.Attribute("fc").Value);
                        List <Rectangle> rs = new List <Rectangle>();
                        foreach (XElement r in tex.Elements("Dim"))
                        {
                            rs.Add(new Rectangle(
                                       int.Parse(r.Attribute("x").Value),
                                       int.Parse(r.Attribute("y").Value),
                                       int.Parse(r.Attribute("w").Value),
                                       int.Parse(r.Attribute("h").Value)
                                       ));
                        }

                        List <Point> cs = new List <Point>();
                        foreach (XElement r in tex.Elements("Center"))
                        {
                            cs.Add(new Point(
                                       int.Parse(r.Attribute("x").Value),
                                       int.Parse(r.Attribute("y").Value)
                                       ));
                        }
                        return(new TextureDrawer(Content.Load <Texture2D>(tex.Attribute("source").Value),
                                                 rs.ToArray(),
                                                 cs.ToArray(),
                                                 float.Parse(tex.Attribute("ft").Value),
                                                 fc,
                                                 true,
                                                 tex.Attribute("truename").Value
                                                 ));
                    }
                    else
                    {
                    }
                }
            }
            return(null);
        }