Exemplo n.º 1
0
        public TMXTileGroup(XMLElement element)
        {
            name    = element.GetAttribute("name", null);
            width   = element.GetIntAttribute("width", 0);
            height  = element.GetIntAttribute("height", 0);
            objects = new List <TMXTile>();

            XMLElement propsElement = element.GetChildrenByName("properties");

            if (propsElement != null)
            {
                List <XMLElement> properties = propsElement.List("property");
                if (properties != null)
                {
                    props = new TMXProperty();
                    for (int p = 0; p < properties.Count; p++)
                    {
                        XMLElement propElement = properties[p];
                        string     name_0      = propElement.GetAttribute("name", null);
                        string     value_ren   = propElement.GetAttribute("value", null);
                        props.SetProperty(name_0, value_ren);
                    }
                }
            }
            List <XMLElement> objectNodes = element.List("object");

            for (int i = 0; i < objectNodes.Count; i++)
            {
                XMLElement objElement = objectNodes[i];
                TMXTile    obj0       = new TMXTile(objElement);
                obj0.index = i;
                CollectionUtils.Add(objects, obj0);
            }
        }
Exemplo n.º 2
0
        public TMXTileGroup(XMLElement element)
        {
            name = element.GetAttribute("name", null);
            width = element.GetIntAttribute("width", 0);
            height = element.GetIntAttribute("height", 0);
            objects = new List<TMXTile>();

            XMLElement propsElement = element.GetChildrenByName("properties");
            if (propsElement != null)
            {
                List<XMLElement> properties = propsElement.List("property");
                if (properties != null)
                {
                    props = new TMXProperty();
                    for (int p = 0; p < properties.Count; p++)
                    {
                        XMLElement propElement = properties[p];
                        string name_0 = propElement.GetAttribute("name", null);
                        string value_ren = propElement.GetAttribute("value", null);
                        props.SetProperty(name_0, value_ren);
                    }
                }
            }
            List<XMLElement> objectNodes = element.List("object");
            for (int i = 0; i < objectNodes.Count; i++)
            {
                XMLElement objElement = objectNodes[i];
                TMXTile obj0 = new TMXTile(objElement);
                obj0.index = i;
                CollectionUtils.Add(objects, obj0);
            }
        }
Exemplo n.º 3
0
 public int GetObjectHeight(int groupID, int objectID)
 {
     if (groupID >= 0 && groupID < objectGroups.Count)
     {
         TMXTileGroup grp = objectGroups[groupID];
         if (objectID >= 0 && objectID < grp.objects.Count)
         {
             TMXTile obj0 = grp.objects[objectID];
             return(obj0.height);
         }
     }
     return(-1);
 }
Exemplo n.º 4
0
 public string GetObjectType(int groupID, int objectID)
 {
     if (groupID >= 0 && groupID < objectGroups.Count)
     {
         TMXTileGroup grp = objectGroups[groupID];
         if (objectID >= 0 && objectID < grp.objects.Count)
         {
             TMXTile obj0 = grp.objects[objectID];
             return(obj0.type);
         }
     }
     return(null);
 }
Exemplo n.º 5
0
 public int GetObjectWidth(int groupID, int objectID)
 {
     if (groupID >= 0 && groupID < objectGroups.Count)
     {
         TMXTileGroup grp = (TMXTileGroup)objectGroups[groupID];
         if (objectID >= 0 && objectID < grp.objects.Count)
         {
             TMXTile obj0 = (TMXTile)grp.objects[objectID];
             return(obj0.width);
         }
     }
     return(-1);
 }
Exemplo n.º 6
0
 public string GetObjectName(int groupID, int objectID)
 {
     if (groupID >= 0 && groupID < objectGroups.Count)
     {
         TMXTileGroup grp = (TMXTileGroup)objectGroups[groupID];
         if (objectID >= 0 && objectID < grp.objects.Count)
         {
             TMXTile obj0 = (TMXTile)grp.objects[objectID];
             return(obj0.name);
         }
     }
     return(null);
 }
Exemplo n.º 7
0
        public string GetObjectProperty(int groupID, int objectID,
                                        string propertyName, string def)
        {
            if (groupID >= 0 && groupID < objectGroups.Count)
            {
                TMXTileGroup grp = objectGroups[groupID];
                if (objectID >= 0 && objectID < grp.objects.Count)
                {
                    TMXTile obj0 = grp.objects[objectID];

                    if (obj0 == null)
                    {
                        return(def);
                    }
                    if (obj0.props == null)
                    {
                        return(def);
                    }

                    return(obj0.props.GetProperty(propertyName, def));
                }
            }
            return(def);
        }