Ejemplo n.º 1
0
 public GridEditor(Game1 game, Levels.MapType type, Rectangle bounds, TilesSet sprites, int[,] grid,
                   Point position, OverlayGrid[] overlays, OverlayGrid[] underlays, int[,] selectionGrid, EditableGrid customInventory)
 {
     this.game            = game;
     this.bounds          = bounds;
     this.sprites         = sprites;
     map                  = new EditableGrid(bounds, grid, position, 8);
     this.type            = type;
     this.selectionGrid   = selectionGrid;
     this.customInventory = customInventory;
     GridEnabled          = true;
     // Load Inventory
     if (type != Levels.MapType.Minimap)
     {
         Point nbTiles = sprites.NumberTiles;
         int[,] inventoryGrid = new int[nbTiles.Y, nbTiles.X];
         int i = 0;
         for (int y = 0; y < nbTiles.Y; y++)
         {
             for (int x = 0; x < nbTiles.X; x++)
             {
                 inventoryGrid[y, x] = i;
                 i++;
             }
         }
         inventory = new EditableGrid(bounds, inventoryGrid, new Point(-8, -8), 16);
     }
     else
     {
         inventory = null;
     }
     Overlays  = overlays;
     Underlays = underlays;
 }
Ejemplo n.º 2
0
 void QuitEditor()
 {
     _lastSelectionGrid = editor.SelectionGrid;
     _lastWorld         = Levels.GetWorldOfLevel(map);
     _lastMapType       = MapType();
     editor             = null;
     mode = Mode.Menu;
     _paraPhysicalMapLogic = null;
     _inventories.Save();
 }
Ejemplo n.º 3
0
        bool LoadGrid()
        {
            int[,] grid;
            List <GridEditor.OverlayGrid> underlays = new List <GridEditor.OverlayGrid>();
            List <GridEditor.OverlayGrid> overlays  = new List <GridEditor.OverlayGrid>();
            string world = Levels.GetWorldOfLevel(map);

            Levels.MapType mapType   = MapType();
            string         levelPath = Levels.GetLevelPath(map, mapType);

            if (!File.Exists(levelPath)) // Should only happen in Paradise
            {
                return(false);
            }
            if (mode == Mode.Minimap)
            {
                grid = Levels.GetGridFromLines(File.ReadAllLines(levelPath), 64, 64,
                                               Levels.TilesOffset(world, Levels.MapType.Minimap));
                sset = new TilesSet(Load.MinimapColors, false, _ssetBounds, 64);
            }
            else
            {
                Load.LoadWorldTiles(GraphicsDevice, world);
                grid = Levels.GetGridFromLines(File.ReadAllLines(levelPath), Levels.TilesOffset(world, mapType));
                sset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, mapType)], true, _ssetBounds, 64);

                if (Settings.Paradise && mode == Mode.Physical)
                {
                    string   objectsPath = Levels.GetObjectsPath(map);
                    string[] objects     = File.Exists(objectsPath) ? File.ReadAllLines(objectsPath) : new string[0];
                    _paraPhysicalMapLogic = new ParadisePhysicalMapLogic(objects);
                }

                int[,] ogrid;
                TilesSet osset;
                if (mode != Mode.Background)
                {
                    try
                    {
                        ogrid = Levels.GetGridFromLines(File.ReadAllLines(Levels.GetLevelPath(map, Levels.MapType.Background)),
                                                        Levels.TilesOffset(world, Levels.MapType.Background));
                        osset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, Levels.MapType.Background)],
                                             true, Rectangle.Empty, 0);
                        underlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false));
                    }
                    catch { }
                }
                if (mode != Mode.Graphical2)
                {
                    try
                    {
                        ogrid = Levels.GetGridFromLines(File.ReadAllLines(Levels.GetLevelPath(map, Levels.MapType.Graphical2)),
                                                        Levels.TilesOffset(world, Levels.MapType.Graphical2));
                        osset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, Levels.MapType.Graphical2)],
                                             true, Rectangle.Empty, 0);
                        if (mode == Mode.Background)
                        {
                            overlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false));
                        }
                        else
                        {
                            underlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false));
                        }
                    }
                    catch { }
                }
                if (mode != Mode.Graphical)
                {
                    try
                    {
                        ogrid = Levels.GetGridFromLines(File.ReadAllLines(Levels.GetLevelPath(map, Levels.MapType.Graphical)),
                                                        Levels.TilesOffset(world, Levels.MapType.Graphical));
                        osset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, Levels.MapType.Graphical)],
                                             true, Rectangle.Empty, 0);
                        if (mode == Mode.Physical)
                        {
                            underlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false));
                        }
                        else
                        {
                            overlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false));
                        }
                    }
                    catch { }
                }
                if (mode != Mode.Physical)
                {
                    try
                    {
                        ogrid = Levels.GetGridFromLines(File.ReadAllLines(Levels.GetLevelPath(map, Levels.MapType.Physical)),
                                                        Levels.TilesOffset(world, Levels.MapType.Physical));
                        osset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, Levels.MapType.Physical)],
                                             true, Rectangle.Empty, 0);
                        overlays.Add(new GridEditor.OverlayGrid(osset, ogrid, true));
                    }
                    catch { }
                }
            }

            int[,] selectionGrid = null;
            if (_lastMapType == mapType /*&& (_lastWorld == world || mapType == Levels.MapType.Physical || mapType == Levels.MapType.Minimap)*/)
            {
                // Sometimes, inter-world copy paste can be relevant even for grounds and backgrounds
                selectionGrid = _lastSelectionGrid;
            }
            editor = new GridEditor(this, MapType(), _gridEditorBounds,
                                    sset, grid, new Point(-8, -8), overlays.ToArray(), underlays.ToArray(), selectionGrid, _inventories.GetInventory(MapType()));
            return(true);
        }
Ejemplo n.º 4
0
 public EditableGrid GetInventory(Levels.MapType type)
 {
     return(grids[type]);
 }
Ejemplo n.º 5
0
 public WorldAndType(string world, Levels.MapType type)
 {
     this.type  = type;
     this.world = world;
 }