/// <summary> /// Set the base value for this new movement /// </summary> /// <param name="value"> /// If `isDragging` is true, this value is the dragging distance. /// Otherwise, this value is the base velocity for the releasing movement. /// </param> /// <param name="isDragging">Is the list being dragged?</param> public void SetMovement(float value, bool isDragging) { if (isDragging) { _isDragging = true; _draggingDistance = value; // End the last movement when start dragging _aligningMovementCurve.EndMovement(); _releasingMovementCurve.EndMovement(); } else if (_getPositionState() != PositionState.Middle) { _aligningMovementCurve.SetMovement(_getAligningDistance()); } else { _releasingMovementCurve.SetMovement(value); } }
/// <summary> /// Set the moving distance for this new movement /// </summary> /// If there has the distance left in the last movement, /// the moving distance will be accumulated.<para/> /// If the list reaches the end in the linear mode, the moving distance /// will be ignored and use `_bouncingDeltaPos` for the bouncing movement. /// <param name="distanceAdded">Set the additional moving distance</param> /// <param name="flag">No usage</param> public void SetMovement(float distanceAdded, bool flag) { // Ignore any movement when the list is aligning if (!_bouncingMovementCurve.IsMovementEnded()) { return; } var state = _getPositionState(); var movingDirection = Mathf.Sign(distanceAdded); if ((state == PositionState.Top && movingDirection < 0) || (state == PositionState.Bottom && movingDirection > 0)) { _bouncingMovementCurve.SetMovement(movingDirection * _bouncingDeltaPos); _unitMovementCurve.EndMovement(); } else { distanceAdded += _unitMovementCurve.distanceRemaining; _unitMovementCurve.SetMovement(distanceAdded); } }
public void EndMovement() { _unitMovementCurve.EndMovement(); _bouncingMovementCurve.EndMovement(); }