private int findNextAvailableColumn(int startColumn, FindFour.FindFourMoveDirection direction, bool wrap = false) { int num = (direction != FindFour.FindFourMoveDirection.LEFT) ? 1 : (-1); int num2 = startColumn + num; bool flag = false; if (num2 < 0 || num2 > numColumns - 1) { return(startColumn); } while (!isColumnAvailable(num2)) { num2 += num; if (num2 >= numColumns || num2 < 0) { if (!wrap || flag) { break; } num2 = startColumn; num = -num; flag = true; } } return(num2); }
public void MoveToken(FindFour.FindFourMoveDirection direction) { int num = findNextAvailableColumn(currentTokenColumn, direction); if (num >= 0 && num < numColumns) { setTokenColumn(num); } EventManager.Instance.PostEvent(MoveTokenSFXTrigger, EventAction.PlaySound); }