TiledMapLayerContent.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright (c) Craftwork Games. All rights reserved.
  2. // Licensed under the MIT license.
  3. // See LICENSE file in the project root for full license information.
  4. using System.Collections.Generic;
  5. using System.Xml.Serialization;
  6. using MonoGame.Extended.Tiled;
  7. namespace MonoGame.Extended.Content.Tiled;
  8. [XmlInclude(typeof(TiledMapTileLayerContent))]
  9. [XmlInclude(typeof(TiledMapImageLayerContent))]
  10. [XmlInclude(typeof(TiledMapObjectLayerContent))]
  11. public abstract class TiledMapLayerContent
  12. {
  13. protected TiledMapLayerContent(TiledMapLayerType layerType)
  14. {
  15. LayerType = layerType;
  16. Opacity = 1.0f;
  17. ParallaxX = 1.0f;
  18. ParallaxY = 1.0f;
  19. Visible = true;
  20. Properties = new List<TiledMapPropertyContent>();
  21. }
  22. [XmlAttribute(AttributeName = "name")]
  23. public string Name { get; set; }
  24. // Deprecated as of Tiled 1.9.0 (replaced by "class" attribute)
  25. [XmlAttribute(DataType = "string", AttributeName = "type")]
  26. public string Type { get; set; }
  27. [XmlAttribute(DataType = "string", AttributeName = "class")]
  28. public string Class { get; set; }
  29. [XmlAttribute(AttributeName = "opacity")]
  30. public float Opacity { get; set; }
  31. [XmlAttribute(AttributeName = "visible")]
  32. public bool Visible { get; set; }
  33. [XmlAttribute(AttributeName = "offsetx")]
  34. public float OffsetX { get; set; }
  35. [XmlAttribute(AttributeName = "offsety")]
  36. public float OffsetY { get; set; }
  37. [XmlAttribute(AttributeName = "parallaxx")]
  38. public float ParallaxX { get; set; }
  39. [XmlAttribute(AttributeName = "parallaxy")]
  40. public float ParallaxY { get; set; }
  41. [XmlArray("properties")]
  42. [XmlArrayItem("property")]
  43. public List<TiledMapPropertyContent> Properties { get; set; }
  44. [XmlIgnore]
  45. public TiledMapLayerType LayerType { get; }
  46. public override string ToString()
  47. {
  48. return Name;
  49. }
  50. }