Exemplo n.º 1
0
        private void InitializeBrush(DynamicTileBrush brush)
        {
            _layerControl.ReferenceWidth  = brush.BrushClass.TemplateWidth * brush.TileWidth + 1;
            _layerControl.ReferenceHeight = brush.BrushClass.TemplateHeight * brush.TileHeight + 1;

            _layer = new MultiTileGridLayer("Default", brush.TileWidth, brush.TileHeight, brush.BrushClass.TemplateWidth, brush.BrushClass.TemplateHeight);
            for (int i = 0; i < brush.BrushClass.SlotCount; i++)
            {
                LocatedTile tile = brush.GetLocatedTile(i);
                if (tile.Tile != null)
                {
                    _layer.AddTile(tile.X, tile.Y, tile.Tile);
                }
            }

            _rootLayer.Layers.Clear();
            _rootLayer.Layers.Add(new TileGridLayerPresenter(_layerContext, _layer));
            _rootLayer.Layers.Add(new LocalRenderLayerPresenter(new OverlayRenderCore(this)));
            _rootLayer.Layers.Add(new GridLayerPresenter()
            {
                GridSpacingX = brush.TileWidth,
                GridSpacingY = brush.TileHeight,
            });

            _nameField.Text = brush.Name;

            _brush = brush;

            SelectCurrentPrototype();
            SelectCurrentTileSize();
        }
Exemplo n.º 2
0
            public override void RenderContent(RenderLayer renderContext, SpriteBatch spriteBatch)
            {
                Dictionary <string, Texture2D> brushClassOverlays = _form._brushClassOverlays;
                DynamicTileBrush brush = _form._brush;

                if (!brushClassOverlays.ContainsKey(brush.BrushClass.ClassName))
                {
                    System.Drawing.Bitmap overlayBitmap = null;
                    if (brush.BrushClass.ClassName == "Basic")
                    {
                        overlayBitmap = Properties.Resources.DynBrushBasic;
                    }
                    else if (brush.BrushClass.ClassName == "Extended")
                    {
                        overlayBitmap = Properties.Resources.DynBrushExtended;
                    }
                    else
                    {
                        return;
                    }

                    TextureResource overlayResource = TextureResourceBitmapExt.CreateTextureResource(overlayBitmap);
                    brushClassOverlays.Add(brush.BrushClass.ClassName, overlayResource.CreateTexture(spriteBatch.GraphicsDevice));
                }

                Texture2D overlay = brushClassOverlays[brush.BrushClass.ClassName];

                int width  = (int)(overlay.Width * renderContext.LevelGeometry.ZoomFactor * (brush.TileWidth / 16.0));
                int height = (int)(overlay.Height * renderContext.LevelGeometry.ZoomFactor * (brush.TileHeight / 16.0));

                Microsoft.Xna.Framework.Rectangle dstRect = new Microsoft.Xna.Framework.Rectangle(0, 0, width, height);
                spriteBatch.Draw(overlay, dstRect, new Microsoft.Xna.Framework.Color(1f, 1f, 1f, .5f));
            }
Exemplo n.º 3
0
 private void RemoveTileFromBrush(DynamicTileBrush brush, Tile tile)
 {
     if (brush != null)
     {
         for (int i = 0; i < _brush.BrushClass.SlotCount; i++)
         {
             if (_brush.GetTile(i) == tile)
             {
                 _brush.SetTile(i, null);
             }
         }
     }
 }
Exemplo n.º 4
0
        public DynamicBrushForm(DynamicTileBrush brush)
        {
            InitializeForm();

            InitializeBrush(brush);

            _prototypeList.SelectedIndexChanged += HandlePrototypeChanged;
            _tileSizeList.SelectedIndexChanged  += HandleTileSizeChanged;

            _prototypeList.Enabled = false;
            _tileSizeList.Enabled  = false;

            _validateController.Validate();
        }
        private void CommandCloneBrush()
        {
            if (CommandCanCloneBrush())
            {
                string name = FindCloneBrushName(SelectedBrush.Name);

                Guid newBrushId = Guid.Empty;
                if (SelectedBrush is DynamicTileBrush)
                {
                    DynamicTileBrush oldBrush = SelectedBrush as DynamicTileBrush;
                    DynamicTileBrush newBrush = new DynamicTileBrush(name, oldBrush.TileWidth, oldBrush.TileHeight, oldBrush.BrushClass);
                    for (int i = 0; i < oldBrush.BrushClass.SlotCount; i++)
                    {
                        newBrush.SetTile(i, oldBrush.GetTile(i));
                    }

                    TileBrushManager.DefaultDynamicBrushCollection.Brushes.Add(newBrush);
                    newBrushId = newBrush.Uid;
                }
                else if (SelectedBrush is StaticTileBrush)
                {
                    StaticTileBrush oldBrush = SelectedBrush as StaticTileBrush;
                    StaticTileBrush newBrush = new StaticTileBrush(name, oldBrush.TileWidth, oldBrush.TileHeight);
                    foreach (LocatedTile tile in oldBrush.Tiles)
                    {
                        newBrush.AddTile(tile.Location, tile.Tile);
                    }
                    newBrush.Normalize();

                    TileBrushManager.DefaultStaticBrushCollection.Brushes.Add(newBrush);
                    newBrushId = newBrush.Uid;
                }
                else
                {
                    return;
                }

                OnSyncTileBrushCollection(EventArgs.Empty);
                SelectBrush(newBrushId);
                OnTileBrushSelected(EventArgs.Empty);
            }
        }