コード例 #1
0
        public static IReplayableOperation CreateLiftAreaOperation(IMapModel map, int x, int y, int width, int height)
        {
            // copy the target area to a new tile
            var tile = new MapTile(width, height);

            GridMethods.Copy(map.Tile.TileGrid, tile.TileGrid, x, y, 0, 0, width, height);
            GridMethods.Copy(map.Tile.HeightGrid, tile.HeightGrid, x * 2, y * 2, 0, 0, width * 2, height * 2);

            var positionedTile = new Positioned <IMapTile>(tile, new Point(x, y));

            var addOp         = new AddFloatingTileOperation(map, positionedTile);
            var clearBitmapOp = new FillAreaOperation <Bitmap>(map.Tile.TileGrid, x, y, width, height, Globals.DefaultTile);
            var clearHeightOp = new FillAreaOperation <int>(map.Tile.HeightGrid, x * 2, y * 2, width * 2, height * 2, 0);

            return(new CompositeOperation(addOp, clearBitmapOp, clearHeightOp));
        }
コード例 #2
0
        public CopyAreaOperation(IGrid <T> source, IGrid <T> destination, int sourceX, int sourceY, int destX, int destY, int width, int height)
        {
            this.source      = source;
            this.destination = destination;

            this.sourceX = sourceX;
            this.sourceY = sourceY;
            this.destX   = destX;
            this.destY   = destY;
            this.width   = width;
            this.height  = height;

            this.oldContents = new Grid <T>(width, height);

            GridMethods.Copy(destination, this.oldContents, destX, destY, 0, 0, width, height);
        }
コード例 #3
0
 public void Undo()
 {
     GridMethods.Copy(this.oldContents, this.destination, this.destX, this.destY);
 }
コード例 #4
0
 public void Execute()
 {
     GridMethods.Copy(this.source, this.destination, this.sourceX, this.sourceY, this.destX, this.destY, this.width, this.height);
 }
コード例 #5
0
 public void Undo()
 {
     GridMethods.Copy(this.oldContents, this.target, this.x, this.y);
 }
コード例 #6
0
 public void Execute()
 {
     this.oldContents = new Grid <T>(this.width, this.height);
     GridMethods.Copy(this.target, this.oldContents, this.x, this.y, 0, 0, this.width, this.height);
     GridMethods.Fill(this.target, this.x, this.y, this.width, this.height, this.fillValue);
 }