Пример #1
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);
    }
Пример #2
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);
    }