protected override IEnumerator process(BehaviourTreeAgent agent)
    {
        GameObject             toFollow = agent.gameObjectParameters[objectToAttack];
        BehaviourTreeNodeState state    = stateForAgent(agent);

        GameObject.Destroy(toFollow);
        state.actualCondition = processCondition.Sucess;
        yield return(null);
    }
    protected override IEnumerator process(BehaviourTreeAgent agent)
    {
        yield return(null);

        GameObject             interact = agent.gameObjectParameters[objectToInteract];
        BehaviourTreeNodeState state    = stateForAgent(agent);

        interact.GetComponent <Interactable>().interact();
        state.actualCondition = processCondition.Sucess;
    }
示例#3
0
    protected override IEnumerator process(BehaviourTreeAgent agent)
    {
        BehaviourTreeNodeState state = stateForAgent(agent);

        if (agent.listParameters[listToCheck].Count == 0)
        {
            state.actualCondition = processCondition.Sucess;
        }
        else
        {
            state.actualCondition = processCondition.Failure;
        }
        yield return(null);
    }
    protected override IEnumerator process(BehaviourTreeAgent agent)
    {
        yield return(null);

        BehaviourTreeNodeState state = stateForAgent(agent);
        bool query = agent.boolParameters[inspectedBool];

        if (query)
        {
            state.actualCondition = processCondition.Sucess;
        }
        else
        {
            state.actualCondition = processCondition.Failure;
        }
    }
示例#5
0
    protected override IEnumerator process(BehaviourTreeAgent agent)
    {
        BehaviourTreeNodeState state    = stateForAgent(agent);
        NavMeshAgent           navAgent = agent.GetComponent <NavMeshAgent>();
        Vector3 target = agent.vector3Parameters[moveTo];

        Vector3 previousTargetPosition = new Vector3(float.PositiveInfinity, float.PositiveInfinity);

        while (Vector3.Distance(agent.transform.position, target) > reachTolerance)
        {
            if (navAgent.SetDestination(target) == false)
            {
                state.actualCondition = processCondition.Failure;
                yield break;
            }
            yield return(null);
        }
        yield return(null);

        state.actualCondition = processCondition.Sucess;
    }
    protected override IEnumerator process(BehaviourTreeAgent agent)
    {
        BehaviourTreeNodeState state    = stateForAgent(agent);
        GameObject             toFollow = null;

        try {
            toFollow = agent.gameObjectParameters[objectToFollow];
        }
        catch {
            state.actualCondition = processCondition.Failure;
            yield break;
        }
        if (toFollow == null)
        {
            state.actualCondition = processCondition.Failure;
            yield break;
        }
        NavMeshAgent navAgent = agent.GetComponent <NavMeshAgent>();

        Vector3 previousTargetPosition = new Vector3(float.PositiveInfinity, float.PositiveInfinity);

        while (Vector3.SqrMagnitude(agent.transform.position - toFollow.transform.position) > reachTolerance)
        {
            // did target move more than at least a minimum amount since last destination set?
            if (Vector3.SqrMagnitude(previousTargetPosition - toFollow.transform.position) > 0.1f)
            {
                if (navAgent.SetDestination(toFollow.transform.position) == false)
                {
                    state.actualCondition = processCondition.Failure;
                    yield break;
                }
                previousTargetPosition = toFollow.transform.position;
            }
            yield return(null);
        }
        state.actualCondition = processCondition.Sucess;
    }