private void _ReadMapFromFile() { int topDownModifier = HEIGHT - 1; string[] layerPaths = new string[]{ @"Content\Map0.txt", @"Content\Map1.txt", @"Content\Map2.txt", @"Content\Map3.txt" }; for (int i = 0; i < LAYER_COUNT; i++) { using (StreamReader reader = new StreamReader(layerPaths[i])) { List<float> mapTileList = new List<float>(); while (!reader.EndOfStream) { var tmpArray = reader.ReadLine().Split(','); for (int j = 0; j < tmpArray.Length; j++) { if (!tmpArray[j].Equals("\r\n")) { mapTileList.Add(Convert.ToSingle(tmpArray[j])); } } } for (int col = 0; col < HEIGHT; col++) { for (int row = 0; row < WIDTH; row++) { tiles[row + (col * WIDTH) + (i * WIDTH * HEIGHT)] = new Tile(row, topDownModifier - col, mapTileList[row + (col * WIDTH)]); } } } } }
private void _ReadMapFromFile() { using (StreamReader reader = new StreamReader(@"Content\Map.txt")) { List<float> tileArray = new List<float>(); while (!reader.EndOfStream) { var tmpArray = reader.ReadLine().Split(','); for (int i = 0; i < tmpArray.Length; i++) { if (!tmpArray[i].Equals("\r\n")) { tileArray.Add(Convert.ToSingle(tmpArray[i])); } } } tileArray.Reverse(); for (int col = 0; col < HEIGHT; col++) { for (int row = 0; row < WIDTH; row++) { tiles[row + col * WIDTH] = new Tile(row, col, tileArray[row + col * WIDTH]); } } } }