private void EliminateAColorOfBlocks(int colorIndex) { LeftColors.Remove(colorIndex); if (LeftColors.Count > 0) { NewLineGenerator.GenerateNewGrid(); NewLineGenerator.IncreaseHardLevel(5);//生成方块的杂乱等级,随着游戏过程中某种颜色方块被清除而增加 } AudioManager.Instance.SoundPlay("OnBreak"); StartCoroutine(Co_TimeScaleSlow(0.3f)); if (LeftColors.Count != 0) { GameManager.Instance.CongratulationTextFly(); } List <Block> removeMegaBlocks = new List <Block>(); foreach (Block b in MegaBlocks) { if (b && b.ColorIndex == colorIndex) { removeMegaBlocks.Add(b); } } foreach (Block b in removeMegaBlocks) { RemoveMegaBlockAndChildren(b); } List <Block> removeBlocks = new List <Block>(); foreach (Block b in Blocks) { if (b && b.ColorIndex == colorIndex) { removeBlocks.Add(b); } } foreach (Block b in removeBlocks) { b.removeBlock(); } if (currentBlockGroup != null) { List <Block> removeCurrentBlocks = new List <Block>(); foreach (Block b in currentBlockGroup.bList) { removeCurrentBlocks.Add(b); } foreach (Block b in removeCurrentBlocks) { currentBlockGroup.RemoveBlockFromGroup(b); b.removeBlock(); } currentBlockGroup.PoolRecycle(); creatNewBlockGroup(); } List <BlockGroup> removeCurrentBgs = new List <BlockGroup>(); foreach (BlockGroup bg in currentBlockGroupPieces) { List <Block> removeCurrentBlocks = new List <Block>(); foreach (Block b in bg.bList) { if (b.ColorIndex == colorIndex) { removeCurrentBlocks.Add(b); } } foreach (Block b in removeCurrentBlocks) { bg.RemoveBlockFromGroup(b); b.removeBlock(); } if (bg.bList.Count == 0) { removeCurrentBgs.Add(bg); } } foreach (BlockGroup bg in removeCurrentBgs) { currentBlockGroupPieces.Remove(bg); bg.PoolRecycle(); } //进行一次全block核对,因为有bug还没修复 for (int i = 0; i < Grid.GetLength(0); i++) { for (int j = 0; j < Grid.GetLength(1); j++) { if (Grid[i, j] == -1) { if (Blocks[i, j] != null) { Blocks[i, j].PoolRecycle(); } } else { if (Blocks[i, j] == null || Blocks[i, j].gridPosition[0] != i || Blocks[i, j].gridPosition[1] != j) { if (Blocks[i, j]) { Blocks[i, j].PoolRecycle(); } if (Grid[i, j] == -2) { Blocks[i, j] = GameObjectPoolManager.Instance.Pool_BreakBlockPool.AllocateGameObject <Block>(transform); } else { Blocks[i, j] = GameObjectPoolManager.Instance.Pool_BlockPool[Grid[i, j]].AllocateGameObject <Block>(transform); } Blocks[i, j].InitiateBlockByGridPosition(Grid[i, j], new int[] { i, j }); } } } } if (LeftColors.Count == 0) { GameManager.Instance.GameWin(); } else { RefreshGrid(); } }