void Plan_Patrol() { if (waypoints != null && pathfinder.remainingDistance <= pathfinder.stoppingDistance) { timeWaited += Time.deltaTime; if (timeWaited >= waitTime && pathfinder.remainingDistance <= pathfinder.stoppingDistance) { patrolIndex++; if (patrolIndex >= waypoints.Length) { patrolIndex = 0; if (!patrolIsCircuit) { patrolIndex++; Array.Reverse(waypoints); } } DestinationPlan_Weighted destinationPlan = new DestinationPlan_Weighted(Plan_Weighted.Patrol, waypoints[patrolIndex], 1); destinationPlans.Add(destinationPlan); speedPlans.Add(1, entity.walkSpeed); timeWaited = 0; } } else { DestinationPlan_Weighted destinationPlan = new DestinationPlan_Weighted(Plan_Weighted.Patrol, waypoints[patrolIndex], 1); destinationPlans.Add(destinationPlan); speedPlans.Add(1, entity.walkSpeed); timeWaited = 0; } }
void Plan_Chase(Vector3 plannedDestination, float weight, Vector3 targetPosition, Vector3 directionToTarget, float targetDistance) { plannedDestination = targetPosition - directionToTarget * (collisionRadius + targetCollisionRadius + entity.meleeDistanceThreshold / 2); weight = targetDistance; DestinationPlan_Weighted destinationPlan = new DestinationPlan_Weighted(Plan_Weighted.Chase, plannedDestination, weight); destinationPlans.Add(destinationPlan); speedPlans.Add(weight, entity.runSpeed); }
void Plan_Evade(Vector3 plannedDestination, float weight, Vector3 targetPosition, Vector3 directionToTarget, float targetDistance) { Vector3 directionToSafety = directionToTarget * -1; plannedDestination = targetPosition + (directionToSafety * UnityEngine.Random.Range(5, 15)); weight = desiredCombatDistance / (targetDistance / desiredCombatDistance); DestinationPlan_Weighted destinationPlan = new DestinationPlan_Weighted(Plan_Weighted.Evade, plannedDestination, weight); destinationPlans.Add(destinationPlan); speedPlans.Add(weight, entity.runSpeed); }
void Plan_DontMove(Vector3 plannedDestination, float weight, float targetDistance) { plannedDestination = transform.position; weight = -1; if (visibleLKPs.Contains(target.subject) && targetDistance >= desiredCombatDistance / 2) { weight = desiredCombatDistance + (desiredCombatDistance / 2); } DestinationPlan_Weighted destinationPlan = new DestinationPlan_Weighted(Plan_Weighted.Null, plannedDestination, weight); destinationPlans.Add(destinationPlan); speedPlans.Add(weight, entity.walkSpeed); }