com.badlogic.gdx.ai.steer.SteeringBehavior Java Examples

The following examples show how to use com.badlogic.gdx.ai.steer.SteeringBehavior. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrioritySteering.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
@Override
protected SteeringAcceleration<T> calculateRealSteering (SteeringAcceleration<T> steering) {
	// We'll need epsilon squared later.
	float epsilonSquared = epsilon * epsilon;

	// Go through the behaviors until one has a large enough acceleration
	int n = behaviors.size;
	selectedBehaviorIndex = -1;
	for (int i = 0; i < n; i++) {
		selectedBehaviorIndex = i;

		SteeringBehavior<T> behavior = behaviors.get(i);

		// Calculate the behavior's steering
		behavior.calculateSteering(steering);

		// If we're above the threshold return the current steering
		if (steering.calculateSquareMagnitude() > epsilonSquared) return steering;
	}

	// If we get here, it means that no behavior had a large enough acceleration,
	// so return the small acceleration from the final behavior or zero if there are
	// no behaviors in the list.
	return n > 0 ? steering : steering.setZero();
}
 
Example #2
Source File: BlendedSteering.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
/** Removes a steering behavior from the list.
 * @param behavior the steering behavior to remove */
public void remove (SteeringBehavior<T> behavior) {
	for (int i = 0; i < list.size; i++) {
		if(list.get(i).behavior == behavior) {
			list.removeIndex(i);
			return;
		}
	}
}
 
Example #3
Source File: SteeringBulletEntity.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public SteeringBehavior<Vector3> getSteeringBehavior () {
	return steeringBehavior;
}
 
Example #4
Source File: PrioritySteering.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
/** Adds the specified behavior to the priority list.
 * @param behavior the behavior to add
 * @return this behavior for chaining. */
public PrioritySteering<T> add (SteeringBehavior<T> behavior) {
	behaviors.add(behavior);
	return this;
}
 
Example #5
Source File: BlendedSteering.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public void setBehavior (SteeringBehavior<T> behavior) {
	this.behavior = behavior;
}
 
Example #6
Source File: BlendedSteering.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public SteeringBehavior<T> getBehavior () {
	return behavior;
}
 
Example #7
Source File: BlendedSteering.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public BehaviorAndWeight (SteeringBehavior<T> behavior, float weight) {
	this.behavior = behavior;
	this.weight = weight;
}
 
Example #8
Source File: SteeringBulletEntity.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public void setSteeringBehavior (SteeringBehavior<Vector3> steeringBehavior) {
	this.steeringBehavior = steeringBehavior;
}
 
Example #9
Source File: GhostAI.java    From Pacman_libGdx with MIT License 4 votes vote down vote up
public SteeringBehavior<Vector2> getSteeringBehavior() {
    return steeringBehavior;
}
 
Example #10
Source File: SteeringActor.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public void setSteeringBehavior (SteeringBehavior<Vector2> steeringBehavior) {
	this.steeringBehavior = steeringBehavior;
}
 
Example #11
Source File: SteeringActor.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public SteeringBehavior<Vector2> getSteeringBehavior () {
	return steeringBehavior;
}
 
Example #12
Source File: Box2dSteeringEntity.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public void setSteeringBehavior (SteeringBehavior<Vector2> steeringBehavior) {
	this.steeringBehavior = steeringBehavior;
}
 
Example #13
Source File: Box2dSteeringEntity.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public SteeringBehavior<Vector2> getSteeringBehavior () {
	return steeringBehavior;
}
 
Example #14
Source File: CollisionAvoidanceSteererBase.java    From GdxDemo3D with Apache License 2.0 4 votes vote down vote up
@Override
public SteeringBehavior<Vector3> getSteeringBehavior() {
	return prioritySteering;
}
 
Example #15
Source File: GhostAI.java    From Pacman_libGdx with MIT License 4 votes vote down vote up
public void setSteeringBehavior(SteeringBehavior<Vector2> steeringBehavior) {
    this.steeringBehavior = steeringBehavior;
}
 
Example #16
Source File: BlendedSteering.java    From gdx-ai with Apache License 2.0 2 votes vote down vote up
/** Adds a steering behavior and its weight to the list.
 * @param behavior the steering behavior to add
 * @param weight the weight of the behavior
 * @return this behavior for chaining. */
public BlendedSteering<T> add (SteeringBehavior<T> behavior, float weight) {
	return add(new BehaviorAndWeight<T>(behavior, weight));
}
 
Example #17
Source File: Steerer.java    From GdxDemo3D with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the steering behavior of this steerer, usually a priority or a blended steering grouping other steering behaviors. 
 */
public abstract SteeringBehavior<Vector3> getSteeringBehavior();