Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[] columnMatched = new int[Map.Instance.Layout.Width]; // Create an array with a length equal to our column count
- // Iterate over the blocks the player matched
- while (selectedBlocks.Count > 0)
- {
- Block block = selectedBlocks.Dequeue();
- columnMatched[block.Position.X]++; // Increase the recorded matches in our column array
- block.Matched();
- }
- // Iterate over our column array
- for (int x = 0; x < columnMatched.Length; x++)
- {
- // Create a new block to replace each one matched
- int newBlockCount = 0;
- for (int i = 0; i < columnMatched[x]; i++)
- {
- 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
- newBlockCount++;
- }
- if (columnMatched[x] > 0) Map.Instance.CollapseColumn(x); // Collapse the column
- yield return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement