public static int loadMap(string mapIdentifier) { if(!Constants.VFSSkip) vfsDataProvider.Instance.unpackFromVFS("data\\map" + mapIdentifier + "\\region" + mapIdentifier + ".bin", "data\\regions\\region" + mapIdentifier + ".bin"); if(!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "data/regions/region" + mapIdentifier + ".bin")) return 0; int mapID = Convert.ToInt32(mapIdentifier); byte[] data = File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + "data/regions/region" + mapIdentifier + ".bin"); int x = BitConverter.ToInt32(data, 0); int y = BitConverter.ToInt32(data, 4); int fxPos = BitConverter.ToInt32(data, 8 + x * y); int fyPos = BitConverter.ToInt32(data, 8 + x * y + 4); Grid grid = new Grid(); grid.setgID(mapID); grid.setgSize(new int[] { x, y }); grid.setaSize(256); grid.setStartingGridPosition(new float[] { fxPos, fyPos }); grid.setEndingGridPosition(new float[] { fxPos + (grid.getgSize()[0] * grid.getaSize()), fyPos + (grid.getgSize()[1] * grid.getaSize()) }); WMap.Instance.addGrid(grid); int position = 8; for(int i = 0;i < y;i++) { for(int u = 0;u < x;u++) { WMap.Instance.getGrid(mapID).getArea((u * ((x > y) ? (x) : (y))) + i).setRegionID((byte)data[position]); position++; } } return x * y; }
public Area(int aID, int[] areaPosition, Grid grid) { this.aID = aID; this.areaPosition = areaPosition; this.grid = grid; this.startingAreaPosition = new float[] { grid.getStartingGridPosition()[0] + (grid.getaSize() * areaPosition[0]), grid.getStartingGridPosition()[1] + (grid.getaSize() * areaPosition[1]) }; this.endingAreaPosition = new float[] { grid.getStartingGridPosition()[0] + ((grid.getaSize() * areaPosition[0]+1)-1), grid.getStartingGridPosition()[1] + ((grid.getaSize() * areaPosition[1]+1)-1) }; }
public void addGrid(Grid g) { g.initGrid(); this.grids.Add(g.getgID(), g); }
public void removeGrid(Grid g) { if(!this.grids.ContainsKey(g.getgID())) return; this.grids.Remove(g.getgID()); }
public void setGrid(Grid grid) { this.grid = grid; }