/// <summary> /// Create a movement control for the unit distance moving /// </summary> /// <param name="movementCurve"> /// The curve that defines the distance factor. /// The x axis is the moving duration, and y axis is the factor value. /// </param> /// <param name="bouncingDeltaPos"> /// The delta position for bouncing effect /// </param> /// <param name="getAligningDistance"> /// The function that evaluates the distance for aligning /// </param> /// <param name="getPositionState"> /// The function that returns the state of the list position /// </param> public UnitMovementCtrl( AnimationCurve movementCurve, float bouncingDeltaPos, Func <float> getAligningDistance, Func <PositionState> getPositionState) { var bouncingCurve = new AnimationCurve( new Keyframe(0.0f, 0.0f, 0.0f, 5.0f), new Keyframe(0.125f, 1.0f, 0.0f, 0.0f), new Keyframe(0.25f, 0.0f, -5.0f, 0.0f)); _unitMovementCurve = new DistanceMovementCurve(movementCurve); _bouncingMovementCurve = new DistanceMovementCurve(bouncingCurve); _bouncingDeltaPos = bouncingDeltaPos; _getAligningDistance = getAligningDistance; _getPositionState = getPositionState; }
/// <summary> /// Create the movement control for the free list movement /// </summary> /// <param name="releasingCurve"> /// The curve that defines the velocity factor for the releasing movement. /// The x axis is the moving duration, and the y axis is the factor. /// </param> /// <param name="toAlign">Is it need to aligning after a movement?</param> /// <param name="exceedingDistanceLimit"> /// How far could the list exceed the end? /// </param> /// <param name="getAligningDistance"> /// The function that evaluates the distance for aligning /// </param> /// <param name="getPositionState"> /// The function that returns the state of the list position /// </param> public FreeMovementCtrl( AnimationCurve releasingCurve, bool toAlign, float exceedingDistanceLimit, Func <float> getAligningDistance, Func <PositionState> getPositionState) { _releasingMovementCurve = new VelocityMovementCurve(releasingCurve); _aligningMovementCurve = new DistanceMovementCurve( new AnimationCurve( new Keyframe(0.0f, 0.0f, 0.0f, 8.0f), new Keyframe(0.25f, 1.0f, 0.0f, 0.0f) )); _toAlign = toAlign; _exceedingDistanceLimit = exceedingDistanceLimit; _getAligningDistance = getAligningDistance; _getPositionState = getPositionState; }