//This entire constructor is lol. public LocalMap(Stream file, Assets assets) { StreamReader reader = new StreamReader(file); string line = reader.ReadLine(); //Read the dimensions. string[] dims = line.Split(' '); Width = Convert.ToInt32(dims[0]); Height = Convert.ToInt32(dims[1]); Depth = Convert.ToInt32(dims[2]); tiles = new Tile[Width, Height, Depth]; createTiles(assets); for (int z = 0; z < Depth; ++z) { if (z != 0) { reader.ReadLine(); } for (int y = 0; y < Height; ++y) { string[] tileLine = reader.ReadLine().Split(' '); for (int x = 0; x < Width; ++x) { switch (Convert.ToInt32(tileLine[x])) { case 0: tiles[x, y, z].Declaration = basicTile; tiles[x, y, z].IsPassable = false; break; case 1: tiles[x, y, z].Declaration = basicTile; tiles[x, y, z].IsPassable = true; break; case 2: tiles[x, y, z].Declaration = upStair; tiles[x, y, z].IsPassable = true; break; case 3: tiles[x, y, z].Declaration = downStair; tiles[x, y, z].IsPassable = true; break; } } } } }
public LocalMap(int w, int h, int d, Assets assets) { Width = w; Height = h; Depth = d; tiles = new Tile[w, h, d]; createTiles(assets); for (int z = 0; z < d; ++z) { TileDeclaration decl = (z == 0 ? basicTile : airTile); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { tiles[x, y, z].IsPassable = true; tiles[x, y, z].Declaration = decl; } } } }
public LocalMapView(Assets assets) { LocalMap = new LocalMap(128, 128, 32, assets); }
void createTiles(Assets assets) { basicTile.Material.Texture = assets.MMGrass; upStair.StairType = StairType.Up; upStair.Material.Texture = assets.MMGrass; downStair.StairType = StairType.Down; downStair.Material.Texture = assets.MMGrass; }