ChangeTile() публичный Метод

public ChangeTile ( int tile_x, int tile_y, int tile_id ) : void
tile_x int
tile_y int
tile_id int
Результат void
Пример #1
0
        /// <summary>
        /// Draws the brush onto the given screen at the given tile location.
        /// Returns an "undo brush" - a brush of all tiles that were overwritten.
        /// Returns null if no tiles were changed.
        /// </summary>
        public ITileBrush DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            TileBrush undo    = new TileBrush(Width, Height);
            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.AddTile(old, cell.x, cell.y);
                    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(null);
        }
Пример #2
0
        public virtual ITileBrush DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            var old = screen.TileAt(tile_x, tile_y);

            if (old == null)
            {
                return(null);
            }

            if (old.Id == tile.Id)
            {
                return(null);
            }

            screen.ChangeTile(tile_x, tile_y, tile.Id);
            return(new SingleTileBrush(old));
        }
Пример #3
0
        /// <summary>
        /// Draws the brush onto the given screen at the given tile location.
        /// Returns an "undo brush" - a brush of all tiles that were overwritten.
        /// Returns null if no tiles were changed.
        /// </summary>
        public ITileBrush DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            TileBrush undo = new TileBrush(Width, Height);
            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.AddTile(old, cell.x, cell.y);
                    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 null;
        }
Пример #4
0
        public virtual ITileBrush DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            var old = screen.TileAt(tile_x, tile_y);

            if (old == null)
            {
                return null;
            }

            if (old.Id == tile.Id)
            {
                return null;
            }

            screen.ChangeTile(tile_x, tile_y, tile.Id);
            return new SingleTileBrush(old);
        }