RequestPath() public method

public RequestPath ( PathfindingRequest, req, bool &result ) : List
req PathfindingRequest,
result bool
return List
コード例 #1
0
    private IEnumerator MoveToInteraction(Interactable interactable, string interaction)
    {
        Collider2D c = GetComponent <Collider2D>();

        Debug.LogWarning("Moving to interaction " + interactable.ToString());
        while (interactable)
        {
            if (!c.IsTouching(interactable.GetComponent <Collider2D>()))
            {
                PathfindingManager.RequestPath(new PathRequest(transform.position, interactable.transform.position, uc.OnPathFound));
                yield return(new WaitForSeconds(.2f)); //might be able to extend this here? no need to be as precise?
            }
            else
            {
                uc.StopMoving();
                break;
            }
        }

        //if the interactable is still there when we get there
        if (interactable != null)
        {
            interactable.Interaction(interaction);
        }

        yield break;
    }
コード例 #2
0
ファイル: GoTo.cs プロジェクト: fylux/GameAI
    public void SetNewTarget(Vector3 new_target, bool modify = true)
    {
        if (modify)
        {
            int i = 0;
            do
            {
                Vector2 offsetXY = UnityEngine.Random.insideUnitCircle * offset;
                target = Map.Clamp(new Vector3(new_target.x + offsetXY[0], 1f, new_target.z + offsetXY[1]));
                i++;
            } while (!Map.NodeFromPosition(target).isWalkable() && i < 20);
            if (!Map.NodeFromPosition(target).isWalkable())
            {
                Debug.LogError("GoTo target not walkable " + new_target);                 //error
                finished = true;
                return;
            }
        }

        processing = true;
        if (defensive)
        {
            PathfindingManager.RequestPath(agent, target, agent.faction, ProcessPath);
        }
        else
        {
            PathfindingManager.RequestPath(agent, target, Faction.C, ProcessPath);
        }

        finished = false;
    }
コード例 #3
0
ファイル: TestUnit.cs プロジェクト: Tiny-Spider/Project-3
    IEnumerator FindPath()
    {
        //while (true) {
        yield return(new WaitForSeconds(1F));

        PathfindingManager.RequestPath(transform.position, target.position, OnPathFound);
        //}
    }
コード例 #4
0
ファイル: FlightState.cs プロジェクト: jfonz412/combatTest
    private IEnumerator Flee()
    {
        Vector3 closestExit = GetClosestExit();
        float   z           = transform.position.z;

        PathfindingManager.RequestPath(new PathRequest(transform.position, closestExit, usm.unitController.OnPathFound));
        while (Vector3.Distance(transform.position, closestExit) > 0.5f)
        {
            yield return(null);
        }
        usm.RequestChangeState(StateMachine.States.Routed);
    }
コード例 #5
0
    private IEnumerator Wander()
    {
        while (true)
        {
            Vector3 lastPos = transform.position;
            PathfindingManager.RequestPath(new PathRequest(transform.position, RandomWanderSpot(), usm.unitController.OnPathFound));
            //Debug.Log(gameObject + " is wandering");
            yield return(new WaitForSeconds(Random.Range(3.0f, 7.0f)));

            PathfindingManager.RequestPath(new PathRequest(transform.position, lastPos, usm.unitController.OnPathFound));
            yield return(new WaitForSeconds(Random.Range(3.0f, 7.0f)));
        }
    }
コード例 #6
0
    private IEnumerator Engage(Transform _targetTransform)
    {
        //Debug.LogError(gameObject.name + " is engaging " + _targetTransform.name);
        bool inRange;

        targetTransform = _targetTransform;
        targetBody      = targetTransform.GetComponent <BodyPartController>();
        attack1Parts    = usm.attack1Parts;
        attack2Parts    = usm.attack2Parts;

        UnitController     uc       = usm.unitController;
        BodyPartController opponent = targetTransform.GetComponent <BodyPartController>();
        Collider2D         col      = GetComponent <Collider2D>();

        usm.unitAnim.FaceDirection(transform.position, targetTransform.position);

        while (!opponent.Incapacitated())
        {
            //eventually this will be a function that will check if ranged or melee, then decide if in range or not
            //for ranged we can use a raycast of some sort to check for obstabcles
            inRange = col.IsTouching(targetTransform.GetComponent <Collider2D>());

            if (!inRange)
            {
                PathfindingManager.RequestPath(new PathRequest(transform.position, targetTransform.position, uc.OnPathFound));
                yield return(new WaitForSeconds(.1f));
            }
            else if (!usm.attackTimer.coolingDown)
            {
                Attack();
            }
            yield return(null);
        }
        usm.RequestChangeState(StateMachine.States.Idle);
        yield break;
    }
コード例 #7
0
ファイル: Entity.cs プロジェクト: ly774508966/AI-Companion
 void StartRequest(Vector3 _target)
 {
     pathRequested = true;
     PathfindingManager.RequestPath(transform.position, _target, OnPathFound);
     pathRequested = false;
 }
コード例 #8
0
 private void MoveHere(Vector3 location)
 {
     StopMovingToPrevInteraction();
     PathfindingManager.RequestPath(new PathRequest(transform.position, location, uc.OnPathFound));
     stateMachine.RequestChangeState(StateMachine.States.Idle);
 }