Ejemplo n.º 1
0
    public Vector2 CalculateDesiredPosition(AIAgent requester, float deltaTime)
    {
        Vector2 requesterPosition = GetPostion(requester);
        Vector2 currentDesiredPosition;

        if (useStuckBehaviour)
        {
            if (requester.UseStuckBehaviour(out Vector2? sbDestination))
            {
                currentDesiredPosition = SteeringBehaviour.Arribe(requester, requesterPosition, sbDestination.Value, deltaTime, false, false);
            }
            else
            {
                currentDesiredPosition = SteeringBehaviour.GetDesiredPosition(baseBehaviour, requesterPosition, requester, deltaTime);
                currentDesiredPosition = Vector2.Lerp(currentDesiredPosition,
                                                      SteeringBehaviour.GetDesiredPosition(closeUpBehaviour, requesterPosition, requester, deltaTime), GetCloseUpWeight(requester, closeUpLinearWeight));
            }
        }
        else
        {
            currentDesiredPosition = SteeringBehaviour.GetDesiredPosition(baseBehaviour, requesterPosition, requester, deltaTime);
            currentDesiredPosition = Vector2.Lerp(currentDesiredPosition,
                                                  SteeringBehaviour.GetDesiredPosition(closeUpBehaviour, requesterPosition, requester, deltaTime), GetCloseUpWeight(requester, closeUpLinearWeight));
        }



        if (applySeparation)
        {
            currentDesiredPosition = ApplySeparation(requester, requesterPosition, currentDesiredPosition, linearSeparationWeight);
        }
        if (applyAvoidance)
        {
            if (!ignoreIfHeading)
            {
                currentDesiredPosition = ApplyAvoidance(requester, requesterPosition, currentDesiredPosition, linearAvoidanceWeight);
            }
            else
            {
                currentDesiredPosition = ApplyAvoidance(requester, requesterPosition, currentDesiredPosition, linearAvoidanceWeight, ingnoreAnglesAvoidance);
            }
        }
        return(currentDesiredPosition);
    }