public IEnumerator UpdateCoroutine(int x, int y, int colIndex) { //Block Grid grid.BlockGrid(false, gameView.GetGameGrid(), CELL_COUNT); //List blocks to destroy List <GameObject> toDestroy = new List <GameObject>(); toDestroy.Add(gameView.GetGameGrid()[x, y]); grid.CheckNeighbours(x, y, colIndex, toDestroy, gameView.GetGameGrid(), CELL_COUNT); //Update power points and moves moves--; AddPowerPoints(colIndex, toDestroy.Count, currentPlayer); if (currentPlayer != 1) { gameView.UpdatePowerPointsView(elementsPowerPoints2, moves); } else { gameView.UpdatePowerPointsView(elementsPowerPoints, moves); } //Destroy blocks foreach (GameObject gO in toDestroy) { gO.GetComponent <ButtonScript>().DestroyBut(); } //Wait until destroy animation ends yield return(new WaitForSeconds(0.8f)); //Move blocks in table grid.BlocksFall(gameView.GetGameGrid(), CELL_COUNT); grid.ColumnMove(gameView.GetGameGrid(), CELL_COUNT); //Move blocks in view for (int i = 0; i < CELL_COUNT; i++) { for (int j = 0; j < CELL_COUNT; j++) { if (gameView.GetGameGrid()[i, j] != null) { int _x = i; int _y = j; gameView.GetGameGrid()[i, j].GetComponent <ButtonScript>().SetIndexes(_x, _y); gameView.GetGameGrid()[i, j].GetComponent <ButtonScript>().Move(_x, _y); } } } //Wait until blocks stop moving yield return(new WaitForSeconds(0.7f)); if (moves > 0) { //Unlock grid grid.BlockGrid(true, gameView.GetGameGrid(), CELL_COUNT); } else { Destroy(gameView.GetGamePanel()); UpdatePowerView(); } }