Example usage for com.badlogic.gdx.ai.steer.behaviors Seek Seek

List of usage examples for com.badlogic.gdx.ai.steer.behaviors Seek Seek

Introduction

In this page you can find the example usage for com.badlogic.gdx.ai.steer.behaviors Seek Seek.

Prototype

public Seek(Steerable<T> owner, Steerable<T> target) 

Source Link

Document

Creates a Seek behavior for the specified owner and target.

Usage

From source file:com.mygdx.entities.DynamicEntities.enemies.EnemyEntity.java

@Override
public void init(World world) {
    super.init(world);

    seekWanderTarget = new SeekWanderTarget(new Vector2(pos.x, pos.y));
    EnvironmentManager.currentEnv.spawnEntity(seekWanderTarget);

    seekWanderSB = new Seek<Vector2>(this, seekWanderTarget);
}

From source file:com.mygdx.entities.DynamicEntities.enemies.Enemy_TestMon.java

public Enemy_TestMon(Vector2 pos) {
    super(pos, 40f, 40f);

    idleTexture = MainGame.am.get(ResourceManager.ENEMY_PH);
    deadTexture = MainGame.am.get(ResourceManager.ENEMY_PH_DEAD);

    texture = idleTexture;/*from  w w w .  j av  a  2s .co  m*/

    //AI
    wanderSB = new Wander<Vector2>(this).setFaceEnabled(false).setAlignTolerance(0.001f)
            .setDecelerationRadius(5).setTimeToTarget(0.1f).setWanderOffset(90).setWanderOrientation(10)
            .setWanderRadius(40f).setWanderRate(MathUtils.PI2 * 4);

    seekWanderSB = new Seek<Vector2>(this, seekWanderTarget);
    fleeSB = new Flee<Vector2>(this, EnvironmentManager.player);

    this.maxLinearSpeed = 150f;
    this.maxLinearAcceleration = 500f;
    this.maxAngularSpeed = 30f;
    this.maxAngularAcceleration = 5f;
}

From source file:com.mygdx.entities.DynamicEntities.enemies.En_Goober.java

public En_Goober(Vector2 pos) {
    super(pos, 30f * RATIO, 30f * RATIO);
    fd.restitution = 0.2f;//from  w  ww. ja v a2  s  .c  om

    float sscale = 0.38f * RATIO;

    moveSprite = new ImageSprite("goober_move", true);
    moveSprite.sprite.setScale(sscale);
    isprite = moveSprite;

    prepSprite = new ImageSprite("goober_prep", true);
    prepSprite.sprite.setScale(sscale);

    attackSprite = new ImageSprite("goober-attack2", false);
    attackSprite.sprite.setScale(sscale);

    bodyDamageSprite = new ImageSprite("goober-dmg", false);
    bodyDamageSprite.sprite.setScale(sscale);

    prepTime = 1.0f;
    attTime = 0.3f;
    recovTime = 3f;

    attackFC = new FrameCounter_Attack(prepTime, attTime, recovTime);

    //attack sensors
    attFd1 = new FixtureDef();
    PolygonShape vertBox = new PolygonShape();
    vertBox.setAsBox(width * 0.4f / PPM, (75f / PPM) * RATIO, new Vector2(0, (75f / PPM) * RATIO), 0);
    attFd1.shape = vertBox;
    attFd1.isSensor = true;
    attFd1.filter.categoryBits = BIT_EN;
    attFd1.filter.maskBits = BIT_PLAYER;

    attFd2 = new FixtureDef();
    PolygonShape horzBox = new PolygonShape();
    horzBox.setAsBox((75f / PPM) * RATIO, width * 0.4f / PPM, new Vector2((75f / PPM) * RATIO, 0), 0);
    attFd2.shape = horzBox;
    attFd2.isSensor = true;
    attFd2.filter.categoryBits = BIT_EN;
    attFd2.filter.maskBits = BIT_PLAYER;

    attFd3 = new FixtureDef();
    PolygonShape vertBoxSouth = new PolygonShape();
    vertBoxSouth.setAsBox(width * 0.4f / PPM, (75f / PPM) * RATIO, new Vector2(0, -(75f / PPM) * RATIO), 0);
    attFd3.shape = vertBoxSouth;
    attFd3.isSensor = true;
    attFd3.filter.categoryBits = BIT_EN;
    attFd3.filter.maskBits = BIT_PLAYER;

    attFd4 = new FixtureDef();
    PolygonShape horzBoxWest = new PolygonShape();
    horzBoxWest.setAsBox((75f / PPM) * RATIO, width * 0.4f / PPM, new Vector2(-(75f / PPM) * RATIO, 0), 0);
    attFd4.shape = horzBoxWest;
    attFd4.isSensor = true;
    attFd4.filter.categoryBits = BIT_EN;
    attFd4.filter.maskBits = BIT_PLAYER;

    //ai
    moveToSB = new Arrive<Vector2>(this, EnvironmentManager.player).setTimeToTarget(0.01f)
            .setArrivalTolerance(2f).setDecelerationRadius(10);

    wanderSB = new Wander<Vector2>(this).setFaceEnabled(false).setAlignTolerance(0.001f)
            .setDecelerationRadius(5).setTimeToTarget(0.1f).setWanderOffset(90).setWanderOrientation(10)
            .setWanderRadius(40f).setWanderRate(MathUtils.PI2 * 4);

    seekWanderSB = new Seek<Vector2>(this, seekWanderTarget);

    //ai
    this.maxLinearSpeed = 150f;
    this.maxLinearAcceleration = 500f;
    this.maxAngularSpeed = 30f;
    this.maxAngularAcceleration = 5f;

}