public void FinishedVerticalMatch() { finishedVerticalMatch += 1; if (finishedVerticalMatch == gridSize) { if (this.matchedCells.Count > 0) { this.timesShuffled = 0; lastSwap = null; StartCoroutine(DestroyGems()); } else if (lastSwap != null) { UndoSwap(); } else if (!HasPossibleMovement()) { ShuffleGems(); } else { SetCanSwap(true); showPossibleMoventCoroutine = StartCoroutine(ShowPossibleMovent()); } } }
public void GetGemsToSwap(int columnIndex, int cellIndex, DirectionEnum direction) { if (!CanSwap()) { return; } Cell currentCell = boardGrid[columnIndex, cellIndex]; Cell nextCell = GetCell(columnIndex, cellIndex, direction); if (currentCell != null && nextCell != null) { SwapGems(currentCell, nextCell); lastSwap = new LastSwap(direction, currentCell, nextCell); } }
void UndoSwap() { SwapGems(lastSwap.cellOne, lastSwap.cellTwo); lastSwap = null; }