예제 #1
0
 protected override void LoadContent()
 {
     _spriteBatch = new SpriteBatch(GraphicsDevice);
     _backgroundTexture = Content.Load<Texture2D>("hills");
     _bitmapFont = Content.Load<BitmapFont>("courier-new-32");
     _tiledMap = Content.Load<TiledMap>("level01");
 }
예제 #2
0
 public TiledLayer(TiledMap tiledMap, GraphicsDevice graphicsDevice, string name, int width, int height, int[] data)
 {
     Name = name;
     Width = width;
     Height = height;
     Properties = new TiledProperties();
     
     _tiledMap = tiledMap;
     _spriteBatch = new SpriteBatch(graphicsDevice);
     _tiles = CreateTiles(data);
 }
예제 #3
0
        internal TiledMapObjectLayer(ContentReader input, TiledMap map)
            : base(input)
        {
            Color     = input.ReadColor();
            DrawOrder = (TiledMapObjectDrawOrder)input.ReadByte();

            var objectCount = input.ReadInt32();

            Objects = new TiledMapObject[objectCount];

            for (var i = 0; i < objectCount; i++)
            {
                TiledMapObject @object;

                var objectType = (TiledMapObjectType)input.ReadByte();
                switch (objectType)
                {
                case TiledMapObjectType.Rectangle:
                    @object = new TiledMapRectangleObject(input);
                    break;

                case TiledMapObjectType.Tile:
                    @object = new TiledMapTileObject(input, map);
                    break;

                case TiledMapObjectType.Ellipse:
                    @object = new TiledMapEllipseObject(input);
                    break;

                case TiledMapObjectType.Polygon:
                    @object = new TiledMapPolygonObject(input);
                    break;

                case TiledMapObjectType.Polyline:
                    @object = new TiledMapPolylineObject(input);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                Objects[i] = @object;
            }
        }
        internal TiledMapTileLayer(ContentReader input, TiledMap map)
            : base(input)
        {
            Width      = input.ReadInt32();
            Height     = input.ReadInt32();
            TileWidth  = map.TileWidth;
            TileHeight = map.TileHeight;

            var tileCount = input.ReadInt32();
            var tiles     = new TiledMapTile[tileCount];

            Tiles = new ReadOnlyCollection <TiledMapTile>(tiles);

            for (var i = 0; i < tileCount; i++)
            {
                var globalTileIdentifierWithFlags = input.ReadUInt32();
                var x = input.ReadUInt16();
                var y = input.ReadUInt16();
                tiles[i] = new TiledMapTile(globalTileIdentifierWithFlags, x, y);
            }
        }