public override void Execute(Steerable steerable) { base.Execute(steerable); if (targetTransform) { // Override the steerable's min/max speed if (overrideSteerableSpeed) { steerable.MinSpeed = minSpeed; steerable.MaxSpeed = maxSpeed; } // Override the steerable's max force if (overrideMaxForce) { steerable.MaxForce = maxForce; } // If player's lights are on, seek player if (targetTransform.gameObject.CompareTag("Player")) { Player player = targetTransform.gameObject.GetComponent<Player>(); if (player.IsDetectable()) { steerable.AddSeekForce(targetTransform.position, strengthMultiplier); AkSoundEngine.PostEvent("Fish_Detection", targetTransform.gameObject); } } else { steerable.AddSeekForce(targetTransform.position, strengthMultiplier); } } }
/// <summary> /// Makes the steerable seek the current 'targetTransform' instance /// </summary> public override void Execute(Steerable steerable) { base.Execute(steerable); if (targetTransform) { // Override the steerable's min/max speed if (overrideSteerableSpeed) { steerable.MinSpeed = minSpeed; steerable.MaxSpeed = maxSpeed; } // Override the steerable's max force if (overrideMaxForce) { steerable.MaxForce = maxForce; } // If player's lights are on, seek player if (targetTransform.gameObject.CompareTag("Player")) { Player player = targetTransform.gameObject.GetComponent <Player>(); if (player.IsDetectable) { steerable.AddSeekForce(targetTransform.position, strengthMultiplier); PlaySeekSound(); } } else { steerable.AddSeekForce(targetTransform.position, strengthMultiplier); } } }
public override void Execute(Steerable steerable) { Player player = targetLightSource.gameObject.GetComponent <Player>(); if (!player.isSafe) { base.Execute(steerable); if (overrideSteerableSpeed) { steerable.MinSpeed = minSpeed; steerable.MaxSpeed = maxSpeed; } // Override the steerable's max force if (overrideMaxForce) { steerable.MaxForce = maxForce; } Vector3 position = targetLightSource.transform.position; if (overrideBossSpeed(steerable, position)) { steerable.MinSpeed = speedMinIncreased; steerable.MaxSpeed = speedMaxIncreased; } steerable.AddSeekForce(position, strengthMultiplier); } else { ActionCompleted(); } wallAvoidance.Execute(steerable); }
public override TaskStatus OnUpdate() { // Cycle through each steering behavior to apply on this GameObject for (int i = 0; i < steeringBehaviors.Length; i++) { // Stores the steering behavior to apply SteeringBehavior steeringBehavior = steeringBehaviors[i]; // Switch the type of the steering behavior and add it to the GameObject switch (steeringBehavior.type) { case SteeringBehaviorType.Seek: steerable.AddSeekForce(steeringBehavior.targetTransform.Value.position, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Arrival: steerable.AddArrivalForce(steeringBehavior.targetTransform.Value.position, steeringBehavior.slowingRadius, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Pursue: steerable.AddPursueForce(steeringBehavior.targetSteerable, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Flee: steerable.AddFleeForce(steeringBehavior.targetTransform.Value.position, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Evade: steerable.AddEvadeForce(steeringBehavior.targetSteerable, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Wander: steerable.AddWanderForce(steeringBehavior.circleDistance, steeringBehavior.circleRadius, steeringBehavior.angleChange, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.ObstacleAvoidance: steerable.AddObstacleAvoidanceForce(steeringBehavior.obstacleAvoidanceForce, steeringBehavior.maxObstacleViewDistance, steeringBehavior.obstacleLayer, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Separation: steerable.AddSeparationForce(steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Alignment: steerable.AddAlignmentForce(steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Cohesion: steerable.AddCohesionForce(steeringBehavior.strengthMultiplier); break; } } // Apply the forces on the steerable that is performing this action steerable.ApplyForces(Time.deltaTime); // If the stopping condition has been met, return success if (stoppingCondition.Complete()) { // Once the stopping condition is met, stop the steerable movement steerable.StopMoving(); return(TaskStatus.Success); } // Else, if the stopping condition has not yet been met else { // Return 'TaskStatus.Running', so that the 'Steer' action can run until the stopping condition is met return(TaskStatus.Running); } }
public override void Execute(Steerable steerable) { Player player = targetLightSource.gameObject.GetComponent<Player>(); if (!player.isSafe) { base.Execute(steerable); if (overrideSteerableSpeed) { steerable.MinSpeed = minSpeed; steerable.MaxSpeed = maxSpeed; } // Override the steerable's max force if (overrideMaxForce) { steerable.MaxForce = maxForce; } Vector3 position = targetLightSource.transform.position; if (overrideBossSpeed(steerable, position)) { steerable.MinSpeed = speedMinIncreased; steerable.MaxSpeed = speedMaxIncreased; } steerable.AddSeekForce(position, strengthMultiplier); } else { ActionCompleted(); } wallAvoidance.Execute(steerable); }
void FixedUpdate() { // If the stopping condition has been met, stop moving if (stoppingCondition.Complete()) { return; } // Cycle through the steering behaviors to apply on this GameObject for (int i = 0; i < steeringBehaviors.Length; i++) { // Stores the steering behavior to apply SteeringBehavior steeringBehavior = steeringBehaviors[i]; // Switch the type of the steering behavior and add it to the GameObject switch (steeringBehavior.type) { case SteeringBehaviorType.Seek: steerable.AddSeekForce(steeringBehavior.targetTransform.position, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Arrival: steerable.AddArrivalForce(steeringBehavior.targetTransform.position, steeringBehavior.slowingRadius, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Pursue: steerable.AddPursueForce(steeringBehavior.targetSteerable, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Flee: steerable.AddFleeForce(steeringBehavior.targetTransform.position, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Evade: steerable.AddEvadeForce(steeringBehavior.targetSteerable, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Wander: steerable.AddWanderForce(steeringBehavior.circleDistance, steeringBehavior.circleRadius, steeringBehavior.angleChange, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.ObstacleAvoidance: steerable.AddObstacleAvoidanceForce(steeringBehavior.obstacleAvoidanceForce, steeringBehavior.maxObstacleViewDistance, steeringBehavior.obstacleLayer, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.WallAvoidance: steerable.AddWallAvoidanceForce(steeringBehavior.obstacleAvoidanceForce, steeringBehavior.maxObstacleViewDistance, steeringBehavior.obstacleLayer, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Separation: steerable.AddSeparationForce(steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Alignment: steerable.AddAlignmentForce(steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Cohesion: steerable.AddCohesionForce(steeringBehavior.strengthMultiplier); break; } } // Apply the forces on the steerable that is performing this action steerable.ApplyForces(Time.fixedDeltaTime); }