public Vector2Int LoadMapByCoords(int x, int y, int assumed_width, int assumed_height) { bool redo = false; this.LoadedMap = new int[assumed_width, assumed_height]; TempMap MapLoader = new TempMap(assumed_width, assumed_height); if (Pos_Exist(x, y)) { string filename = "Assets/" + x + "_" + y + ".txt"; MapLoader.LoadMap(filename); Vector2Int RegionSize = MapLoader.GetLoadedRegionSize(); if (RegionSize.x > assumed_width) { redo = true; } if (redo) { Vector2Int FinalSize = LoadMapByCoords(x, y, RegionSize.x, RegionSize.y); return(FinalSize); } MapLoader.ConvertTo2DMap(assumed_width, assumed_height); LoadedMap = MapLoader.GetTileMapArray(); this.LoadedAreaWidth = RegionSize.x; this.LoadedAreaHeight = RegionSize.y; return(new Vector2Int(RegionSize.x, RegionSize.y)); } else { Debug.Log("Loading of map failed at" + x + ", " + y); } return(new Vector2Int(-1, -1)); }
public TileSet(Texture2D TileImage_, int offsetx, int offsety, int area_width, int area_height) //Fill it with a constructor =p { //Texture2D TestTex = new Texture2D(16 * 20, 16 * 20, TextureFormat.ARGB32, false); //Apparently we have to create the textures as well InitTileMapTextures(); //Debug.Log(TileImage.GetType().ToString()); this.TileImage = TileImage_; SplitTilesLocally(TileImage_, 32, 32); SetTileIdMap(); map = new TempMap(area_width, area_height); DimensionalMap = new int[area_width, area_height]; DisplayMap = new GameObject[area_width, area_height]; this.area_width_ = area_width; this.area_height_ = area_height; }