예제 #1
0
        /// <summary>
        /// Creates a tile layer by reading the contentManager we got from the SharpTiles library. This will create our tile layers of type "Floor" and "Objects".
        /// </summary>
        /// <param name="layerContent"></param>
        /// <param name="tileSets"></param>
        /// <returns></returns>
        private TileLayer CreateTileLayer(LayerContent layerContent, IEnumerable<TileSetContent> tileSets)
        {
            if (layerContent == null) throw new ArgumentNullException("layerContent");
            if (tileSets == null) throw new ArgumentNullException("tileSets");

            TileLayerContent tileLayerContent = layerContent as TileLayerContent;

            TileLayer tileLayer = new TileLayer(layerContent.Name, tileLayerContent.Width, tileLayerContent.Height);
            foreach (uint tileID in tileLayerContent.Data)
            {
                uint flippedHorizontallyFlag = 0x80000000;
                uint flippedVerticallyFlag = 0x40000000;
                int tileIndex = (int)(tileID & ~(flippedVerticallyFlag | flippedHorizontallyFlag));
                Tile tile = CreateTile(tileIndex, tileSets);
                tileLayer.AddTile(tile);
            }

            return tileLayer;
        }
예제 #2
0
        /// <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;
        }