Пример #1
0
 public static TmxObjectType FromXml(XElement xml)
 {
     return(new TmxObjectType
     {
         Name = TmxHelper.GetAttributeAsString(xml, "name", ""),
         Color = TmxHelper.GetAttributeAsColor(xml, "color", new Color32(128, 128, 128, 255)),
         Properties = TmxObjectTypeProperty.FromObjectTypeXml(xml)
     });
 }
Пример #2
0
        public static TmxObjectType FromXml(XElement xml)
        {
            TmxObjectType tmxObjectType = new TmxObjectType();

            tmxObjectType.Name       = TmxHelper.GetAttributeAsString(xml, "name", "");
            tmxObjectType.Color      = TmxHelper.GetAttributeAsColor(xml, "color", Color.Gray);
            tmxObjectType.Properties = TmxObjectTypeProperty.FromObjectTypeXml(xml);

            return(tmxObjectType);
        }
Пример #3
0
        public static Dictionary <string, TmxObjectTypeProperty> FromObjectTypeXml(XElement xmlObjectType)
        {
            Dictionary <string, TmxObjectTypeProperty> dictionary = new Dictionary <string, TmxObjectTypeProperty>();

            foreach (XElement item in xmlObjectType.Elements("property"))
            {
                TmxObjectTypeProperty tmxObjectTypeProperty = new TmxObjectTypeProperty();
                tmxObjectTypeProperty.Name    = TmxHelper.GetAttributeAsString(item, "name", "");
                tmxObjectTypeProperty.Type    = TmxHelper.GetAttributeAsEnum(item, "type", TmxPropertyType.String);
                tmxObjectTypeProperty.Default = TmxHelper.GetAttributeAsString(item, "default", "");
                dictionary.Add(tmxObjectTypeProperty.Name, tmxObjectTypeProperty);
            }
            return(dictionary);
        }
        // Create a dictionary collection of Object Type Property instances from the parent xml element
        public static Dictionary<string, TmxObjectTypeProperty> FromObjectTypeXml(XElement xmlObjectType)
        {
            Dictionary<string, TmxObjectTypeProperty> tmxObjectTypeProperties = new Dictionary<string, TmxObjectTypeProperty>();

            foreach (var xmlProperty in xmlObjectType.Elements("property"))
            {
                TmxObjectTypeProperty tmxObjectTypeProperty = new TmxObjectTypeProperty();

                tmxObjectTypeProperty.Name = TmxHelper.GetAttributeAsString(xmlProperty, "name", "");
                tmxObjectTypeProperty.Type = TmxHelper.GetAttributeAsEnum(xmlProperty, "type", TmxPropertyType.String);
                tmxObjectTypeProperty.Default = TmxHelper.GetAttributeAsString(xmlProperty, "default", "");

                tmxObjectTypeProperties.Add(tmxObjectTypeProperty.Name, tmxObjectTypeProperty);
            }

            return tmxObjectTypeProperties;
        }