Ejemplo n.º 1
0
 public void CreateNewObjectSet(string ObjectSetName, string TextureFileName)
 {
     ObjectSet = new ObjectSetData
     {
         ObjectSetName   = ObjectSetName,
         TextureFileName = TextureFileName,
         Elements        = new List <ObjectSetElementData>()
     };
 }
        public void LoadFromFile(string FileName)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(FileName);

            XmlElement xml_root = (XmlElement)doc.FirstChild;

            XmlElement xml_object_set_info = (XmlElement)xml_root.FirstChild;

            ObjectSet = new ObjectSetData
            {
                ObjectSetName   = xml_object_set_info.GetAttribute("Name"),
                TextureFileName = xml_object_set_info.GetAttribute("Texture")
            };

            XmlElement xml_object_set = (XmlElement)xml_object_set_info.NextSibling;

            if (xml_object_set == null)
            {
                return;
            }

            ObjectSet.Elements = new List <ObjectSetElementData>();
            XmlElement xml_element = (XmlElement)xml_object_set.FirstChild;

            while (xml_element != null)
            {
                ObjectSetElementData new_element = new ObjectSetElementData
                {
                    ElementName = xml_element.GetAttribute("Name"),
                    OffsetU     = Convert.ToInt32(xml_element.GetAttribute("OffsetU")),
                    OffsetV     = Convert.ToInt32(xml_element.GetAttribute("OffsetV")),
                    Size        = new SSize(
                        Convert.ToInt32(xml_element.GetAttribute("Width")),
                        Convert.ToInt32(xml_element.GetAttribute("Height")))
                };

                ObjectSet.Elements.Add(new_element);

                xml_element = (XmlElement)xml_element.NextSibling;
            }
        }