Aslai

Untitled

Feb 12th, 2012
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.24 KB | None | 0 0
  1. private void button2_Click(object sender, EventArgs e)
  2.         {
  3.             //obj =  ds_list_find_value( frames, frame_num );
  4.             //set_reg( obj, 1,1,198,198, block_black )
  5.  
  6.             block[, ,] tmp = myroom.getlist();
  7.             int _x = 3;
  8.             int _y = 1;
  9.             int pos = 0;
  10.             int[] pos_x = new int[100000];
  11.             int[] pos_y = new int[100000];
  12.             pos_x[0] = _x;
  13.             pos_y[0] = _y;
  14.             int[] find = new int[100000];
  15.             Random r = new Random();
  16.             List<int> rand = new List<int>();
  17.             while (true)
  18.             {
  19.                 int found = 0;
  20.                 if (_x > 3)
  21.                     if (tmp[_x - 2, _y, 1].type != curblock.type)
  22.                     {
  23.                         find[found] = 0; found += 1;
  24.                     }
  25.                 if (_x < worldWidth - 2)
  26.                     if (tmp[_x + 2, _y, 1].type != curblock.type)
  27.                     {
  28.                         find[found] = 2; found += 1;
  29.                     }
  30.                 if (_y > 1)
  31.                     if (tmp[_x, _y - 2, 1].type != curblock.type)
  32.                     {
  33.                         find[found] = 1; found += 1;
  34.                     }
  35.                 if (_y < worldHeight - 2)
  36.                     if (tmp[_x, _y + 2, 1].type != curblock.type)
  37.                     {
  38.                         find[found] = 3; found += 1;
  39.                     }
  40.  
  41.                 rand.Clear();
  42.                 if (found == 0)
  43.                 {
  44.                     pos -= 1;
  45.                     _x = pos_x[pos];
  46.                     _y = pos_y[pos];
  47.                     //if pos > 4000 show_message( pos )
  48.                     if (pos == 0) break;
  49.                 }
  50.                 else
  51.                 {
  52.                     pos += 1;
  53.                     for (int i = 0; i < found; i += 1)
  54.                     {
  55.                         rand.Add(find[i]);
  56.                     }
  57.                     //Listo.Listo.Shuffle<int>(rand);
  58.  
  59.                     rand[0] = rand[r.Next() % rand.Count];
  60.                     switch (rand[0])
  61.                     {
  62.                         case 0:
  63.                             myroom[_x - 1, _y, 1] = curblock;
  64.                             myroom[_x - 1, _y, 1] = curblock;
  65.                             myroom[_x - 2, _y, 1] = curblock;
  66.                             tmp[_x - 1, _y, 1] = curblock;
  67.                             tmp[_x - 1, _y, 1] = curblock;
  68.                             tmp[_x - 2, _y, 1] = curblock;
  69.  
  70.                             _x -= 2;
  71.                             pos_x[pos] = _x;
  72.                             pos_y[pos] = _y;
  73.                             break;
  74.                         case 1:
  75.                             myroom[_x, _y - 1, 1] = curblock;
  76.                             myroom[_x, _y - 2, 1] = curblock;
  77.                             tmp[_x, _y - 1, 1] = curblock;
  78.                             tmp[_x, _y - 2, 1] = curblock;
  79.  
  80.                             _y -= 2;
  81.                             pos_x[pos] = _x;
  82.                             pos_y[pos] = _y;
  83.                             break;
  84.                         case 2:
  85.                             myroom[_x + 1, _y, 1] = curblock;
  86.                             myroom[_x + 2, _y, 1] = curblock;
  87.                             tmp[_x + 1, _y, 1] = curblock;
  88.                             tmp[_x + 2, _y, 1] = curblock;
  89.  
  90.                             _x += 2;
  91.                             pos_x[pos] = _x;
  92.                             pos_y[pos] = _y;
  93.                             break;
  94.                         case 3:
  95.                             myroom[_x, _y + 1, 1] = curblock;
  96.                             myroom[_x, _y + 2, 1] = curblock;
  97.                             tmp[_x, _y + 1, 1] = curblock;
  98.                             tmp[_x, _y + 2, 1] = curblock;
  99.                             _y += 2;
  100.                             pos_x[pos] = _x;
  101.                             pos_y[pos] = _y;
  102.                             break;
  103.                     }
  104.                 }
  105.             }
  106.  
  107.             myroom[1, 1, 1] = curblock;
  108.             myroom[1, 2, 1] = curblock;
  109.             myroom[2, 1, 1] = curblock;
  110.             myroom[2, 2, 1] = curblock;
  111.             myroom.flush();
  112.         }
Advertisement
Add Comment
Please, Sign In to add comment