예제 #1
0
        /// <summary>
        /// Draws the brush onto the given screen at the given tile location.
        /// </summary>
        public IEnumerable <TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            List <TileChange> undo = new List <TileChange>();
            bool changed           = false;

            foreach (TileBrushCell[] col in _cells)
            {
                foreach (TileBrushCell cell in col)
                {
                    var old = screen.TileAt(cell.x + tile_x, cell.y + tile_y);

                    if (old == null)
                    {
                        continue;
                    }

                    undo.Add(new TileChange(screen, cell.x, cell.y, old.Id, cell.tile.Id));
                    if (old.Id != cell.tile.Id)
                    {
                        changed = true;
                        screen.ChangeTile(cell.x + tile_x, cell.y + tile_y, cell.tile.Id);
                    }
                }
            }

            if (changed)
            {
                return(undo);
            }

            return(Enumerable.Empty <TileChange>());
        }
예제 #2
0
        public virtual IEnumerable <TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            var old = screen.TileAt(tile_x, tile_y);

            if (old == null)
            {
                return(Enumerable.Empty <TileChange>());
            }

            if (old.Id == _tile.Id)
            {
                return(Enumerable.Empty <TileChange>());
            }

            var selection = screen.Selection;

            if (selection != null)
            {
                // only paint inside selection
                if (!selection.Value.Contains(tile_x, tile_y))
                {
                    return(null);
                }
            }

            screen.ChangeTile(tile_x, tile_y, _tile.Id);

            return(new[] { new TileChange(screen, tile_x, tile_y, old.Id, _tile.Id) });
        }
예제 #3
0
        private void CreateSelectionBrush(object obj)
        {
            if (_selection == null)
            {
                return;
            }

            var s = _selection.Value;

            var brush = new MultiTileBrush(s.Width, s.Height);

            for (var x = 0; x < s.Width; x++)
            {
                for (var y = 0; y < s.Height; y++)
                {
                    brush.AddTile(_selectionScreen.TileAt(x + s.X, y + s.Y), x, y);
                }
            }

            _tileset.AddBrush(brush);
            _observedBrushes.Add(brush);
        }
예제 #4
0
        /// <summary>
        /// Draws the brush onto the given screen at the given tile location.
        /// </summary>
        public IEnumerable<TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            List<TileChange> undo = new List<TileChange>();
            bool changed = false;
            foreach (TileBrushCell[] col in _cells)
            {
                foreach (TileBrushCell cell in col)
                {
                    var old = screen.TileAt(cell.x + tile_x, cell.y + tile_y);

                    if (old == null) continue;

                    undo.Add(new TileChange(screen, cell.x, cell.y, old.Id, cell.tile.Id));
                    if (old.Id != cell.tile.Id)
                    {
                        changed = true;
                        screen.ChangeTile(cell.x + tile_x, cell.y + tile_y, cell.tile.Id);
                    }
                }
            }

            if (changed)
            {
                return undo;
            }

            return Enumerable.Empty<TileChange>();
        }
예제 #5
0
        public virtual IEnumerable<TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            var old = screen.TileAt(tile_x, tile_y);

            if (old == null)
            {
                return Enumerable.Empty<TileChange>();
            }

            if (old.Id == _tile.Id)
            {
                return Enumerable.Empty<TileChange>();
            }

            var selection = screen.Selection;
            if (selection != null)
            {
                // only paint inside selection
                if (!selection.Value.Contains(tile_x, tile_y)) return null;
            }

            screen.ChangeTile(tile_x, tile_y, _tile.Id);

            return new[] { new TileChange(screen, tile_x, tile_y, old.Id, _tile.Id) };
        }