//MovePiecesCo coroutine is called in FixedUpdate if isTurning bool is true for the tile. //It rotates the selected 3 tiles until one of them gets a match or it is a full 360. //If there is a match it means 1 player move happened and if there are bombs on the screen //it ticks bomb timer. private IEnumerator MovePiecesCo() { if (selectedTiles[0] != null && selectedTiles[1] != null && selectedTiles[2] != null) { Vector3 rotatePos = (selectedTiles[0].transform.position + selectedTiles[1].transform.position + selectedTiles[2].transform.position) / 3; foreach (GameObject tile in selectedTiles) { tile.transform.RotateAround(rotatePos, turningWay * Vector3.forward, rotateSpeed * Time.deltaTime); } turn1++; turn2++; if (turn1 == turnCounter) { SnapTiles(); FindMatches(); isTurning = false; turn1 = 0; if (board.DestroyMatches()) { turn1 = turn2 = 0; for (int i = 0; i < board.width; i++) { for (int j = 0; j < board.height; j++) { if (board.allTiles[i, j] != null) { if (board.allTiles[i, j].GetComponent <TileBehavior>().isBomb) { board.allTiles[i, j].GetComponent <BombBehavior>().TickBombTimer(); } } } } } else if (turn2 < turnCounter * 3) { isTurning = true; } else { turn2 = 0; for (int i = 0; i < selectedTiles.Length; i++) { selectedTiles[i] = null; } yield return(new WaitForSeconds(.5f)); board.currentState = GameState.move; } } } }