Ejemplo n.º 1
0
        private void RemoveInstructions(MapPropertiesBrush brush, MapProperties properties)
        {
            brush.Selection.HasDifferentHasInstructions = false;
            brush.ActiveTileInfo.HasInstructions        = false;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.GetTile(new Vector2Int(position.x, position.y));
                if (tile != null)
                {
                    tile.HasInstructions = false;
                }
            }

            properties.UpdateBounds();
        }
Ejemplo n.º 2
0
        private void ChangeCollisionLayers(MapPropertiesBrush brush, MapProperties properties, CollisionLayer layer)
        {
            brush.Selection.HasDifferentCollisionLayer = false;
            brush.ActiveTileInfo.CollisionLayer        = layer;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                if (layer == CollisionLayer.None)
                {
                    var tile = properties.GetTile(new Vector2Int(position.x, position.y));
                    if (tile != null)
                    {
                        tile.CollisionLayer = CollisionLayer.None;
                    }
                }
                else
                {
                    var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                    tile.CollisionLayer = layer;
                }
            }

            var size      = brush.Selection.Bounds.size.x * brush.Selection.Bounds.size.y;
            var tileArray = Enumerable.Repeat(brush.CollisionTile, size).ToArray();
            var nullArray = new TileBase[size];

            for (int index = 0, value = 1; index < CollisionLayerData.LayerCount; index++, value *= 2)
            {
                if ((value & (int)layer) > 0)
                {
                    var tilemap = properties.AddOrGetCollisionLayer(index);
                    tilemap.SetTilesBlock(brush.Selection.Bounds, tileArray);
                }
                else
                {
                    var tilemap = properties.GetCollisionLayer(index);
                    if (tilemap)
                    {
                        tilemap.SetTilesBlock(brush.Selection.Bounds, nullArray);
                        properties.CheckForCollisionRemoval(tilemap, index);
                    }
                }
            }

            properties.UpdateBounds();
        }
Ejemplo n.º 3
0
        private void SetCollisionIncrements(MapPropertiesBrush brush, MapProperties properties, int index)
        {
            var layer = index == 0 ? CollisionLayer.None : (CollisionLayer)MathHelper.IntExponent(2, index - 1);

            brush.Selection.HasDifferentCollisionIncrement = false;
            brush.ActiveTileInfo.CollisionLayerIncrement   = layer;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                if (layer == CollisionLayer.None)
                {
                    var tile = properties.GetTile(new Vector2Int(position.x, position.y));
                    tile.CollisionLayerIncrement = CollisionLayer.None;
                }
                else
                {
                    var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                    tile.CollisionLayerIncrement = layer;
                }
            }

            properties.UpdateBounds();
        }