Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. private void Update()
  2.         {
  3.             int colLength = Core.MapGrid.GetLength(0);
  4.             int rowLength = Core.MapGrid.GetLength(1);
  5.  
  6.             this.ContentPanel.Children.Clear();
  7.             if(Core.City.Warehouses[0].X == colLength)
  8.             {
  9.                 Core.City.Warehouses[0].X = colLength;
  10.             }
  11.             else
  12.             {
  13.                 Core.City.Warehouses[0].X += 1;
  14.             }
  15.             Console.WriteLine(Core.City.Warehouses[0].X);
  16.  
  17.             for (int i = 0; i < rowLength; i++)
  18.             {
  19.                 for (int j = 0; j < colLength; j++)
  20.                 {
  21.                     Core.MapGrid[i, j] = "0";
  22.                 }
  23.             }
  24.  
  25.             for (int i = 0; i < Core.City.Warehouses.Count; i++)
  26.             {
  27.                 Core.MapGrid[Core.City.Warehouses[i].Y, Core.City.Warehouses[i].X] = "W";
  28.             }
  29.          
  30.             Grid grid = new Grid();
  31.             for (int i = 0; i < rowLength; i++)
  32.             {
  33.                 RowDefinition gridRow1 = new RowDefinition();
  34.                 gridRow1.Height = new GridLength(1, GridUnitType.Star);
  35.                 grid.RowDefinitions.Add(gridRow1);
  36.             }
  37.  
  38.             for (int j = 0; j < colLength; j++)
  39.             {
  40.                 ColumnDefinition gridCol1 = new ColumnDefinition();
  41.                 gridCol1.Width = new GridLength(1, GridUnitType.Star);
  42.                 grid.ColumnDefinitions.Add(gridCol1);
  43.             }
  44.  
  45.             for (int i = 0; i < rowLength; i++)
  46.             {
  47.                 for (int j = 0; j < colLength; j++)
  48.                 {
  49.                     TextBlock textBlock = new TextBlock();
  50.                     textBlock.Text = Core.MapGrid[i, j];
  51.                     textBlock.SetValue(Grid.RowProperty, i);
  52.                     textBlock.SetValue(Grid.ColumnProperty, j);
  53.                     grid.Children.Add(textBlock);
  54.                 }
  55.  
  56.             }
  57.             this.ContentPanel.Children.Add(grid);
  58.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement