Advertisement
Guest User

Untitled

a guest
Jul 7th, 2013
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1.         int[] columnMatched = new int[Map.Instance.Layout.Width]; // Create an array with a length equal to our column count
  2.        
  3.         // Iterate over the blocks the player matched
  4.         while (selectedBlocks.Count > 0)
  5.         {
  6.             Block block = selectedBlocks.Dequeue();
  7.             columnMatched[block.Position.X]++; // Increase the recorded matches in our column array
  8.             block.Matched();
  9.         }
  10.        
  11.         // Iterate over our column array
  12.         for (int x = 0; x < columnMatched.Length; x++)
  13.         {
  14.            
  15.             // Create a new block to replace each one matched
  16.             int newBlockCount = 0;
  17.             for (int i = 0; i < columnMatched[x]; i++)
  18.             {
  19.                 Map.Instance.CreateBlock(new GridPos(x, Map.Instance.Height+newBlockCount)); // Spawn it at visible grid height plus the amount of blocks we've created so far
  20.                 newBlockCount++;
  21.             }
  22.             if (columnMatched[x] > 0) Map.Instance.CollapseColumn(x); // Collapse the column
  23.            
  24.             yield return null;
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement