Inheritance: Operations.OperationBase, Operations.IOperation
Exemple #1
0
        void executeMove()
        {
            Map   map = Global.ActiveMap;
            Vsp24 vsp = Global.ActiveVsp;

            Operations.OperationManager om = Global.opManager;

            om.beginGroup("VSP Manager: Smart Tile Move");

            Ops.SetTileGroup     stg  = new Ops.SetTileGroup(0);
            Ops.SetTiledataGroup stdg = new Ops.SetTiledataGroup(Global.ActiveVsp);

            //move tiles
            for (int y = 0; y < originalSelection.height; y++)
            {
                for (int x = 0; x < originalSelection.width; x++)
                {
                    int xs = x + originalSelection.x;
                    int ys = y + originalSelection.y;
                    int xd = x + selection.x;
                    int yd = y + selection.y;
                    int ts = ys * TilesWide + xs;
                    int td = yd * TilesWide + xd;

                    if (ts >= vsp.Tiles.Count || ts < 0)
                    {
                        continue;
                    }

                    stdg.addRecord(td, ((Vsp24Tile)vsp.Tiles[ts]).Image.GetArray());

                    for (int l = 0; l < map.Layers.Count; l++)
                    {
                        MapLayer ml = (MapLayer)map.Layers[l];
                        if (ml.type != LayerType.Tile)
                        {
                            continue;
                        }
                        for (int yi = 0; yi < ml.Height; yi++)
                        {
                            for (int xi = 0; xi < ml.Width; xi++)
                            {
                                int t = ml.getTile(xi, yi);
                                if (t == ts)
                                {
                                    stg.addRecord(l, xi, yi, td);
                                }
                            }
                        }
                    }
                }
            }

            om.add(stg);
            om.add(stdg);
            om.endGroupExec();
        }
Exemple #2
0
        void executeMove()
        {
            Map map = Global.ActiveMap;
            Vsp24 vsp = Global.ActiveVsp;
            Operations.OperationManager om = Global.opManager;

            om.beginGroup("VSP Manager: Smart Tile Move");

            Ops.SetTileGroup stg = new Ops.SetTileGroup(0);
            Ops.SetTiledataGroup stdg = new Ops.SetTiledataGroup(Global.ActiveVsp);

            //move tiles
            for (int y = 0; y < originalSelection.height; y++)
                for (int x = 0; x < originalSelection.width; x++) {
                    int xs = x + originalSelection.x;
                    int ys = y + originalSelection.y;
                    int xd = x + selection.x;
                    int yd = y + selection.y;
                    int ts = ys * TilesWide + xs;
                    int td = yd * TilesWide + xd;

                    if (ts >= vsp.Tiles.Count || ts < 0) continue;

                    stdg.addRecord(td, ((Vsp24Tile)vsp.Tiles[ts]).Image.GetArray());

                    for (int l = 0; l < map.Layers.Count; l++) {
                        MapLayer ml = (MapLayer)map.Layers[l];
                        if (ml.type != LayerType.Tile) {
                            continue;
                        }
                        for (int yi = 0; yi < ml.Height; yi++) {
                            for (int xi = 0; xi < ml.Width; xi++) {
                                int t = ml.getTile(xi, yi);
                                if (t == ts) {
                                    stg.addRecord(l, xi, yi, td);
                                }
                            }
                        }
                    }
                }

            om.add(stg);
            om.add(stdg);
            om.endGroupExec();
        }