Пример #1
0
        public void ResizeTiles(int tileWidth, int tileHeight)
        {
            var cols = TileConfiguration.MapWidth / TileConfiguration.TileWidth;
            var rows = TileConfiguration.MapHeight / TileConfiguration.TileHeight;

            TileConfiguration = new TileConfiguration(cols * tileWidth, rows * tileHeight, tileWidth, tileHeight);


            var newCollisionLayer = new TileLayer <CollisionTile>(0, TileConfiguration);

            foreach (var collisionTile in CollisionLayer)
            {
                var bounds = new RectangleF(
                    collisionTile.Column * TileConfiguration.TileWidth,
                    collisionTile.Row * TileConfiguration.TileHeight,
                    TileConfiguration.TileWidth,
                    TileConfiguration.TileHeight
                    );

                newCollisionLayer.Add(new CollisionTile(collisionTile.Row, collisionTile.Column, bounds));
            }

            CollisionLayer = newCollisionLayer;

            Resized?.Invoke();
        }
Пример #2
0
 public TileMap(TileConfiguration tileConfiguration)
 {
     TileConfiguration = tileConfiguration;
     CollisionLayer    = new TileLayer <CollisionTile>(0, TileConfiguration)
     {
         IsVisible = false
     };
 }
Пример #3
0
        public TileLayer(int index, TileConfiguration tileConfiguration)
        {
            Index             = index;
            TileConfiguration = tileConfiguration;

            _tiles = new Grid <T>(
                tileConfiguration.MapWidth,
                tileConfiguration.MapHeight,
                tileConfiguration.TileWidth,
                tileConfiguration.TileHeight
                );
        }
Пример #4
0
        public void Resize(int rows, int cols)
        {
            if (cols < 0 || rows < 0)
            {
                return;
            }

            var tileWidth  = TileConfiguration.TileWidth;
            var tileHeight = TileConfiguration.TileHeight;

            TileConfiguration = new TileConfiguration(tileWidth * cols, rows * tileHeight, tileWidth, tileHeight);

            for (var i = 0; i < _tileLayers.Count; i++)
            {
                _tileLayers[i].Resize(rows, cols);
            }

            CollisionLayer.Resize(rows, cols);

            Resized?.Invoke();
        }