private Attachment ReadAttachment(Skin skin, String name, Dictionary <String, Object> map) { if (map.ContainsKey("name")) { name = (String)map["name"]; } AttachmentType type = AttachmentType.region; if (map.ContainsKey("type")) { type = (AttachmentType)Enum.Parse(typeof(AttachmentType), (String)map["type"], false); } Attachment attachment = attachmentLoader.NewAttachment(skin, type, name); if (attachment is RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment)attachment; regionAttachment.X = GetFloat(map, "x", 0) * Scale; regionAttachment.Y = GetFloat(map, "y", 0) * Scale; regionAttachment.ScaleX = GetFloat(map, "scaleX", 1); regionAttachment.ScaleY = GetFloat(map, "scaleY", 1); regionAttachment.Rotation = GetFloat(map, "rotation", 0); regionAttachment.Width = GetFloat(map, "width", 32) * Scale; regionAttachment.Height = GetFloat(map, "height", 32) * Scale; regionAttachment.UpdateOffset(); } return(attachment); }
private Attachment ReadAttachment(Skin skin, String name, Dictionary <String, Object> map) { if (map.ContainsKey("name")) { name = (String)map["name"]; } AttachmentType type = AttachmentType.region; if (map.ContainsKey("type")) { type = (AttachmentType)Enum.Parse(typeof(AttachmentType), (String)map["type"], false); } Attachment attachment = attachmentLoader.NewAttachment(skin, type, name); RegionAttachment regionAttachment = attachment as RegionAttachment; if (regionAttachment != null) { regionAttachment.x = GetFloat(map, "x", 0) * Scale; regionAttachment.y = GetFloat(map, "y", 0) * Scale; regionAttachment.scaleX = GetFloat(map, "scaleX", 1); regionAttachment.scaleY = GetFloat(map, "scaleY", 1); regionAttachment.rotation = GetFloat(map, "rotation", 0); regionAttachment.width = GetFloat(map, "width", 32) * Scale; regionAttachment.height = GetFloat(map, "height", 32) * Scale; regionAttachment.UpdateOffset(); } BoundingBoxAttachment boundingBox = attachment as BoundingBoxAttachment; if (boundingBox != null) { List <Object> values = (List <Object>)map["vertices"]; float[] vertices = new float[values.Count]; for (int i = 0, n = values.Count; i < n; i++) { vertices[i] = (float)values[i] * Scale; } boundingBox.Vertices = vertices; } return(attachment); }