public void SetNextDestination() { if (isReturning) { if (positionHistory.Count > 1) { move.SetDestination(positionHistory[positionHistory.Count - 2], DestinationType.EMPTY); } return; } int repetition = 0; Vector3 nextDestinaton; do { if (repetition > 10) { nextDestinaton = (anthill.transform.position - transform.position).normalized * nextPathDistance; break; } nextDestinaton = moveGenerator.GetNextDestination(); repetition++; } while (!moveValidator.CanMove(nextDestinaton)); move.SetDestination(nextDestinaton, DestinationType.EMPTY); }
public override Vector3 GetNextDestination() { if (tracingPheromone == null) { return(defaultGenerator.GetNextDestination()); } Pheromone.PheroPath best = tracingPheromone.pheroPaths[0]; for (int i = 1; i < tracingPheromone.pheroPaths.Count; i++) { if (tracingPheromone.pheroPaths[i].power > best.power) { best = tracingPheromone.pheroPaths[i]; } } return(best.destination); }