boardSquare GetNextGemToFall(boardSquare square) { boardAnalyzer bA = new boardAnalyzer(board, currentDirection); return(bA.RecurseToNextGem((int)square.transform.position.x, (int)square.transform.position.y, bA.DirectionX, bA.DirectionY)); }
//Returns list of adjacent gems marked destructable List <boardSquare> RecurseAdjacencyCheck(int x, int y, int dirX, int dirY, List <boardSquare> squareList, boardSquare originalSquare, bool searchStart) //Template method { boardSquare square = board.GetBoardStruct().StructCoreSquare[board.Get1DIndexFrom2D(x, y, board.Width)]; if (searchStart) //Recurse again if able { //Debug.Log("Attempting recursion on original square"); if ((x + dirX < board.Width && x + dirX >= 0) && (y + dirY < board.Height && y + dirY >= 0)) { return(RecurseAdjacencyCheck(x + dirX, y + dirY, dirX, dirY, squareList, originalSquare, false)); } } else //If not the starting object, compare and check { //Debug.Log(square + " is not equal to " + originalSquare); if (square.gemPrefab == originalSquare.gemPrefab && originalSquare.gemPrefab != null) { if (!squareList.Contains(square)) { squareList.Add(square); //square.Comboable = true; square.Destructable = true; return(CheckSquareForAdjacency(square, squareList)); } } } return(squareList); //Default escape }
IEnumerator DelayedGemFallingAnimation(boardSquare square, int index, float delay) { yield return(new WaitForSeconds(delay)); StartCoroutine(GemFallingAnimation(square, index)); }