Ejemplo n.º 1
0
        public static Dictionary <string, string> GetProperties(this TiledObject tiledObject, Dictionary <string, ObjectType> objectTypesByName)
        {
            var properties = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase);

            ObjectType objectType;

            if (!string.IsNullOrEmpty(tiledObject.Type) &&
                objectTypesByName.TryGetValue(tiledObject.Type, out objectType))
            {
                foreach (var property in objectType.Properties)
                {
                    properties[property.Name] = property.Default;
                }
            }

            if (tiledObject.PropertyGroup != null)
            {
                foreach (var property in tiledObject.PropertyGroup.Properties)
                {
                    properties[property.Name] = property.Value;
                }
            }

            return(properties);
        }
Ejemplo n.º 2
0
        public static bool HasProperty(this TiledObject tiledObject, string propertyName, string propertyValue, Dictionary <string, ObjectType> objectTypesByName)
        {
            var properties = GetProperties(tiledObject, objectTypesByName);

            string value;

            return(properties.TryGetValue(propertyName, out value) &&
                   string.Equals(propertyValue, value, StringComparison.OrdinalIgnoreCase));
        }
Ejemplo n.º 3
0
 public static bool IsCollider(this TiledObject tiledObject)
 {
     return(!tiledObject.Gid.HasValue);
 }
Ejemplo n.º 4
0
 public static bool IsImage(this TiledObject tiledObject)
 {
     return(tiledObject.Gid.HasValue);
 }
Ejemplo n.º 5
0
 public static bool HasProperty(this TiledObject tiledObject, string propertyName, Dictionary <string, ObjectType> objectTypesByName)
 {
     return(GetProperties(tiledObject, objectTypesByName)
            .ContainsKey(propertyName));
 }