public void PerformTileMove(Tile t, BoardInput.SwipeDirection dir) { Tile otherTile = null; Action onSwapComplete = () => { List <Match> matches = BoardProcessor.inst.FindMatches(board, t); if (matches.Count > 0) { HighlightMatches(matches, () => { DestroyMatches(matches); }); } else { SwapTiles(t, otherTile); } }; GridPosition otherTilePos = t.gridPos + BoardInput.SwapDirectionToGridOffset(dir); if (board.GridPositionIsWithinBounds(otherTilePos)) { otherTile = board.Tiles[otherTilePos.x][otherTilePos.y]; SwapTiles(t, otherTile, onSwapComplete); } else { MoveTileToItsGridPosition(t); } }