public RequestPath ( PathfindingRequest, req, bool &result ) : List |
||
req | PathfindingRequest, | |
result | bool | |
Результат | List |
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; }
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; }
IEnumerator FindPath() { //while (true) { yield return(new WaitForSeconds(1F)); PathfindingManager.RequestPath(transform.position, target.position, OnPathFound); //} }
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); }
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))); } }
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; }
void StartRequest(Vector3 _target) { pathRequested = true; PathfindingManager.RequestPath(transform.position, _target, OnPathFound); pathRequested = false; }
private void MoveHere(Vector3 location) { StopMovingToPrevInteraction(); PathfindingManager.RequestPath(new PathRequest(transform.position, location, uc.OnPathFound)); stateMachine.RequestChangeState(StateMachine.States.Idle); }