JimMorrison723

Map

Sep 24th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. class MapRow
  2.     {
  3.         public List<MapCell> Columns = new List<MapCell>();
  4.     }
  5.  
  6. class Map()
  7.     {
  8.         public List<MapRow> Rows = new List<MapRow>();
  9.  
  10.         private static int GetRowLength(string path)
  11.         {
  12.             var maxLength = File.ReadLines(path).Max(x => x.Length);
  13.             return maxLength;
  14.         }
  15.  
  16.         private int GetRownumber(string path)
  17.         {
  18.             var lineCount = File.ReadAllLines(path).Length;
  19.             return lineCount;
  20.         }
  21.  
  22.         static void Main(string[] args)
  23.         {
  24.             string path = @"map.txt";
  25.             float RowLength = GetRowLength(path);
  26.             float RowNumber = GetRownumber(path);
  27.  
  28.             string[,] item = new string[(int)RowLength, (int)RowNumber]; //(int most került be)
  29.             string[] line = File.ReadAllLines("map.map");
  30.  
  31.             for (int j = 0; j < RowNumber; j++)
  32.             {
  33.                 for (int i = 1; i < RowLength; i++)
  34.                 {
  35.                     item[i, j] = line[j].Substring(i, 1);
  36.  
  37.                     if (item[i, j] == "0")
  38.                         Rows[j].Columns[i].TileID = 0;
  39.                     else if (item[i, j] == "1")
  40.                         Rows[j].Columns[i].TileID = 1;
  41.                 }
  42.             }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment