AddTile() public method

public AddTile ( TileCoord coord, Tile tile ) : void
coord TileCoord
tile Tile
return void
コード例 #1
0
ファイル: TileDrawTool.cs プロジェクト: jaquadro/Treefrog
        private void EndDrag(PointerEventInfo info, ILevelGeometry viewport)
        {
            Rectangle selection = ClampSelection(_band.Selection);

            StaticTileBrush anonBrush = new StaticTileBrush("User Selected", Layer.TileWidth, Layer.TileHeight);
            foreach (LocatedTile tile in Layer.TilesAt(_band.Selection))
                anonBrush.AddTile(new TileCoord(tile.X - _band.Selection.Left, tile.Y - _band.Selection.Top), tile.Tile);

            anonBrush.Normalize();

            _activeBrush = anonBrush;

            _annots.Remove(_selectionAnnot);
            _selectionAnnot = null;

            //EndAutoScroll(info, viewport);
        }
コード例 #2
0
        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);
            }
        }