Ejemplo n.º 1
0
        public static void loadContent()
        {
            string[] files = Directory.GetFiles("Content/MapItems/");
            foreach (String file in files)
            {
                XmlReader xr = XmlReader.Create(file);
                xr.ReadToFollowing("Entity");
                ToolboxItem newItem;
                newItem = new ToolboxItem(xr.GetAttribute("Name"), xr.GetAttribute("Type"));

                String currentElement = "";
                while (xr.Read())
                {
                    if (xr.IsStartElement())
                        currentElement = xr.Name;
                    else if (xr.NodeType == XmlNodeType.EndElement)
                        if (xr.Name == "Entity")
                            break;
                        else
                            currentElement = "";
                    else if (xr.NodeType == XmlNodeType.Text)
                        newItem.addAttribute(currentElement, xr.Value);
                }
                toolboxContent.Add(newItem);
                xr.Close();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Method to copy attributes from XML parent. MUST invoke this method upon construction in the
 /// map editor. If the object is loaded from a map the properties should be instantiated from the
 /// parent XML type and then set to new values accordingly.
 /// </summary>
 /// <param name="aTemplate">XML parent instance</param>
 public void copyPropertiesFromToolboxTemplate(ToolboxItem aTemplate)
 {
     this.itemClassName = aTemplate.name;
     this.type = aTemplate.type;
     foreach (String attribute in aTemplate.getAttributeNames())
         this.addAttribute(attribute, aTemplate.getAttribute(attribute));
     onAttributeChange();
 }