Example #1
0
    public float GetDistance(float deltaTime)
    {
        var distance = 0.0f;

        if (_isDragging)
        {
            _isDragging = false;
            distance    = _draggingDistance;

            if (IsGoingTooFar(_draggingDistance))
            {
                var threshold = _overGoingDistanceThreshold * Mathf.Sign(_overGoingDistance);
                distance -= _overGoingDistance - threshold;
            }
        }
        else if (!_aligningMovement.IsMovementEnded())
        {
            distance = _aligningMovement.GetDistance(deltaTime);
        }
        else if (!_releasingMovement.IsMovementEnded())
        {
            distance = _releasingMovement.GetDistance(deltaTime);

            if (NeedToAlign(distance))
            {
                _releasingMovement.EndMovement();

                _aligningMovement.SetMovement(_getAligningDistance());
                distance = _aligningMovement.GetDistance(deltaTime);
            }
        }

        return(distance);
    }
Example #2
0
    /* Get the moving distance in the given delta time
     */
    public float GetDistance(float deltaTime)
    {
        var distance = 0.0f;

        if (!_bouncingMovement.IsMovementEnded())
        {
            distance = _bouncingMovement.GetDistance(deltaTime);
        }
        else
        {
            distance = _unitMovement.GetDistance(deltaTime);

            if (NeedToAlign(distance))
            {
                // Make the unit movement end
                _unitMovement.EndMovement();

                _bouncingMovement.SetMovement(-1 * _getAligningDistance());
                // Start at the furthest point to move back
                _bouncingMovement.GetDistance(0.125f);
                distance = _bouncingMovement.GetDistance(deltaTime);
            }
        }

        return(distance);
    }
Example #3
0
    /* Get moving distance in the given delta time
     */
    public float GetDistance(float deltaTime)
    {
        var distance = 0.0f;

        /* If it's dragging, return the dragging distance set from `SetMovement()` */
        if (_isDragging)
        {
            _isDragging = false;
            distance    = _draggingDistance;

            if (IsGoingTooFar(_draggingDistance))
            {
                var threshold = _overGoingDistanceThreshold * Mathf.Sign(_overGoingDistance);
                distance -= _overGoingDistance - threshold;
            }
        }
        /* Aligning */
        else if (!_aligningMovement.IsMovementEnded())
        {
            distance = _aligningMovement.GetDistance(deltaTime);
        }
        /* Releasing */
        else if (!_releasingMovement.IsMovementEnded())
        {
            distance = _releasingMovement.GetDistance(deltaTime);

            if (NeedToAlign(distance))
            {
                // Make the releasing movement end
                _releasingMovement.EndMovement();

                // Start the aligning movement instead
                _aligningMovement.SetMovement(_getAligningDistance());
                distance = _aligningMovement.GetDistance(deltaTime);
            }
        }

        return(distance);
    }
Example #4
0
    public float GetDistance(float deltaTime)
    {
        var distance = 0.0f;

        if (!_bouncingMovement.IsMovementEnded())
        {
            distance = _bouncingMovement.GetDistance(deltaTime);
        }
        else
        {
            distance = _unitMovement.GetDistance(deltaTime);

            if (NeedToAlign(distance))
            {
                _unitMovement.EndMovement();

                _bouncingMovement.SetMovement(-1 * _getAligningDistance());
                _bouncingMovement.GetDistance(0.125f);
                distance = _bouncingMovement.GetDistance(deltaTime);
            }
        }

        return(distance);
    }