Beispiel #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);
        }
Beispiel #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));
        }
Beispiel #3
0
 public static bool IsCollider(this TiledObject tiledObject)
 {
     return(!tiledObject.Gid.HasValue);
 }
Beispiel #4
0
 public static bool IsImage(this TiledObject tiledObject)
 {
     return(tiledObject.Gid.HasValue);
 }
Beispiel #5
0
 public static bool HasProperty(this TiledObject tiledObject, string propertyName, Dictionary <string, ObjectType> objectTypesByName)
 {
     return(GetProperties(tiledObject, objectTypesByName)
            .ContainsKey(propertyName));
 }