/// <summary> /// Creates the proper map object layer based on the layer name such as collidables and path nodes. /// </summary> /// <param name="layer"></param> /// <param name="orientation"></param> /// <returns></returns> private MapObjectLayer CreateObjectLayer(LayerContent layer, Orientation orientation) { if (layer == null) { throw new ArgumentNullException("layer"); } ObjectLayerContent objectLayerContent = layer as ObjectLayerContent; MapObjectLayer mapObjectLayer = new MapObjectLayer(objectLayerContent.Name); foreach (ObjectContent objectContent in objectLayerContent.MapObjects) { MapObject mapObject = new MapObject(objectContent.Name, objectContent.Bounds, orientation, objectContent.Properties); mapObjectLayer.AddMapObject(mapObject); } return(mapObjectLayer); }
/// <summary> /// Create tile layers and object layers based on what we find in the Tiled Map TMX file. /// </summary> /// <param name="mapContent">Map contentManager.</param> private void CreateLayers(MapContent mapContent) { if (mapContent == null) { throw new ArgumentNullException("mapContent"); } foreach (LayerContent layerContent in mapContent.Layers) { if (layerContent is TileLayerContent) { TileLayer tileLayer = CreateTileLayer(layerContent, mapContent.TileSets); tileLayers.Add(tileLayer); } else if (layerContent is ObjectLayerContent) { MapObjectLayer mapObjectLayer = CreateObjectLayer(layerContent, mapContent.Orientation); mapObjectLayers.Add(mapObjectLayer); } } }
/// <summary> /// Creates the proper map object layer based on the layer name such as collidables and path nodes. /// </summary> /// <param name="layer"></param> /// <param name="orientation"></param> /// <returns></returns> private MapObjectLayer CreateObjectLayer(LayerContent layer, Orientation orientation) { if (layer == null) throw new ArgumentNullException("layer"); ObjectLayerContent objectLayerContent = layer as ObjectLayerContent; MapObjectLayer mapObjectLayer = new MapObjectLayer(objectLayerContent.Name); foreach (ObjectContent objectContent in objectLayerContent.MapObjects) { MapObject mapObject = new MapObject(objectContent.Name, objectContent.Bounds, orientation, objectContent.Properties); mapObjectLayer.AddMapObject(mapObject); } return mapObjectLayer; }