/// <summary> /// Reads a .MAP file. /// </summary> /// <param name="parts">a list of tileset-parts</param> private void ReadMapFile(List <TilepartBase> parts) { using (var bs = new BufferedStream(File.OpenRead(FullPath))) { int rows = bs.ReadByte(); int cols = bs.ReadByte(); int levs = bs.ReadByte(); MapTiles = new MapTileList(rows, cols, levs); MapSize = new MapSize(rows, cols, levs); for (int lev = 0; lev != levs; ++lev) { for (int row = 0; row != rows; ++row) { for (int col = 0; col != cols; ++col) { this[row, col, lev] = CreateTile( parts, bs.ReadByte(), bs.ReadByte(), bs.ReadByte(), bs.ReadByte()); } } } } }
private void ReadMap(Stream s, List <TileBase> tiles) { var input = new BufferedStream(s); var rows = input.ReadByte(); var cols = input.ReadByte(); var height = input.ReadByte(); MapSize = new MapSize(rows, cols, height); // map = new MapTile[rows,cols,height]; MapData = new MapTileList(rows, cols, height); for (int h = 0; h < height; h++) { for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { int q1 = input.ReadByte(); int q2 = input.ReadByte(); int q3 = input.ReadByte(); int q4 = input.ReadByte(); this[r, c, h] = createTile(tiles, q1, q2, q3, q4); } } } if (input.Position < input.Length) { Rmp.ExtraHeight = (byte)input.ReadByte(); } input.Close(); }
private void GenerateMapTileRow(int currentRow) { for (int currentColumn = 0; currentColumn < MapWidth; ++currentColumn) { MapTileList.Add(GenerateMapTile(currentRow, currentColumn)); } }
private static void FillNewMap( int newR, int newC, int newH, MapTileList newMap) { for (int h = 0; h < newH; h++) { for (int r = 0; r < newR; r++) { for (int c = 0; c < newC; c++) { newMap[r, c, h] = XCMapTile.BlankTile; } } } }
public MapTileList ResizeMap( int newR, int newC, int newH, MapSize mapSize, MapTileList oldMapTileList, bool wrtCeiling) { if (newR != 0 && newC != 0 && newH != 0) { var newMap = new MapTileList(newR, newC, newH); FillNewMap(newR, newC, newH, newMap); for (int h = 0; h < newH && h < mapSize.Height; h++) { for (int r = 0; r < newR && r < mapSize.Rows; r++) { for (int c = 0; c < newC && c < mapSize.Cols; c++) { var copyH = h; var currentH = h; if (wrtCeiling) { copyH = mapSize.Height - h - 1; currentH = newH - h - 1; } newMap[r, c, currentH] = oldMapTileList[r, c, copyH]; } } } return(newMap); } return(null); }
internal static MapTileList ResizeMapDimensions( int rows, int cols, int levs, MapSize sizePre, MapTileList tileListPre, bool ceiling) { if (rows > 0 && cols > 0 && levs > 0) { var tileListPost = new MapTileList(rows, cols, levs); for (int lev = 0; lev != levs; ++lev) { for (int row = 0; row != rows; ++row) { for (int col = 0; col != cols; ++col) { tileListPost[row, col, lev] = XCMapTile.VacantTile; } } } int levelPre; int levelPost; for (int lev = 0; lev != levs && lev < sizePre.Levs; ++lev) { for (int row = 0; row != rows && row < sizePre.Rows; ++row) { for (int col = 0; col != cols && col < sizePre.Cols; ++col) { if (ceiling) { levelPost = levs - lev - 1; levelPre = sizePre.Levs - lev - 1; } else { levelPost = levelPre = lev; } tileListPost[row, col, levelPost] = tileListPre[row, col, levelPre]; } } } return(tileListPost); } return(null); }
internal static MapTileList GetResizedTileList( int rows, int cols, int levs, MapSize sizePre, MapTileList tileListPre, MapResizeZtype zType) { if (rows > 0 && cols > 0 && levs > 0) { var tileListPost = new MapTileList(rows, cols, levs); for (int lev = 0; lev != levs; ++lev) { for (int row = 0; row != rows; ++row) { for (int col = 0; col != cols; ++col) { tileListPost[row, col, lev] = XCMapTile.VacantTile; } } } switch (zType) { case MapResizeZtype.MRZT_BOT: { for (int lev = 0; lev != levs && lev != sizePre.Levs; ++lev) { for (int row = 0; row != rows && row != sizePre.Rows; ++row) { for (int col = 0; col != cols && col != sizePre.Cols; ++col) { tileListPost[row, col, lev] = tileListPre[row, col, lev]; } } } break; } case MapResizeZtype.MRZT_TOP: { int levelsPre = sizePre.Levs - 1; int levelsPost = levs - 1; for (int lev = 0; lev != levs && lev != sizePre.Levs; ++lev) { for (int row = 0; row != rows && row != sizePre.Rows; ++row) { for (int col = 0; col != cols && col != sizePre.Cols; ++col) { tileListPost[row, col, levelsPost - lev] = // copy tiles from bot to top. tileListPre [row, col, levelsPre - lev]; } } } break; } } return(tileListPost); } return(null); }
public MapTileList GetMapTilesForLocation(int x, int y) { String key = GetKeyForLocation(x, y); MapTileList mapTiles = null; if (!_questTiles.ContainsKey(key)) { mapTiles = new MapTileList(); _questTiles[key] = mapTiles; } else { mapTiles = _questTiles[key]; } return mapTiles; }