public override void Execute() { List <Vector3> path = null; Vector2Int goal = Vector2Int.zero; foreach (var entrance in CellToGo.Entrances) { var newpath = AbPath.FindPath(subject.transform.position, entrance.Entrance); if (newpath != null && newpath.Any()) { if (path == null) { path = newpath; goal = entrance.Entrance; } else if (newpath.Count < path.Count) { path = newpath; goal = entrance.Entrance; } } } if (goal != Vector2Int.zero) { var bhv = subject.GetComponent <BasicMoving>(); bhv.SetTargetPosition(goal); base.Execute(); } }
public List <Vector3> SetTargetPosition(Vector2Int targetPosition) { currentPathIndex = 0; pathVectorList = AbPath.FindPath(transform.position, targetPosition); if (pathVectorList != null && pathVectorList.Count > 1) { pathVectorList.RemoveAt(0); } pos = transform.position; SetMoveDirection(); return(pathVectorList); }