IEnumerator Loop() { List <GameObject> cubesToShiftDown = null; while (gameState != GameState.EndGame) { if (gameState == GameState.DroppingPieces) { yield return(new WaitForSeconds(decentInterval)); } else { yield return(new WaitForSeconds(fastDecentInterval)); } piecePosition += Vector3Int.down; if (gameMatrix.IsOverlapping(activePiece, piecePosition)) { piecePosition += Vector3Int.up; if (gameMatrix.StackTetromino(activePiece, piecePosition, out cubesToShiftDown)) { GetPiece(); } else { GameOver(); } } else { activePiece.transform.DOBlendableLocalMoveBy(Vector3Int.down, 0.1f); if (piecePosition.y + activePiece.BottomLocalHeight == 0) { gameMatrix.StackTetromino(activePiece, piecePosition, out cubesToShiftDown); GetPiece(); } } if (cubesToShiftDown != null && cubesToShiftDown.Count > 0) { foreach (GameObject cube in cubesToShiftDown) { cube.transform.DOBlendableMoveBy(Vector3Int.down, 0.1f); cubesToShiftDown = null; } } } }