Search in sources :

Example 1 with World

use of de.adesso.anki.battle.world.World in project anki-battle-showcase by adessoAG.

the class UseReflectorCommand method execute.

public void execute(Vehicle vehicle) {
    /*TODO implement  reflection 
		*/
    World world = vehicle.getWorld();
    for (DynamicBody dbody : world.getDynamicBodies()) {
        // reverse  when near
        double distance = vehicle.getPosition().distance(dbody.getPosition());
        if (distance < 100) {
        // reverse roadmap
        }
    }
    vehicle.setReflectorReady(false);
}
Also used : DynamicBody(de.adesso.anki.battle.world.DynamicBody) World(de.adesso.anki.battle.world.World)

Example 2 with World

use of de.adesso.anki.battle.world.World in project anki-battle-showcase by adessoAG.

the class VehicleStateProvider method getObstacleFacts.

public List<GameState> getObstacleFacts(Vehicle vehicle) {
    ArrayList<GameState> facts = new ArrayList<>();
    World world = vehicle.getWorld();
    for (Body body : world.getBodies()) {
        if (vehicle == body) {
            // skip self
            continue;
        }
        // generating  facts for vehicle
        // body all other in the current world
        String obstacleType = body.getClass().getSimpleName();
        Position position1 = vehicle.getPosition();
        Position position2 = body.getPosition();
        double distance = position1.distance(position2);
        double angle1 = position1.angle();
        // blickrichtung x cos(angle)  y sine (angle)
        double angleRad = Math.toRadians(angle1);
        double viewVectorX = Math.cos(angleRad);
        double viewVectorY = Math.sin(angleRad);
        double transX = position2.getX() - position1.getX();
        double transY = position2.getY() - position1.getY();
        double dotProduct = viewVectorX * transX + viewVectorY * transY;
        if (dotProduct < 0) {
            ObjectBehind obstacle = new ObjectBehind(distance, obstacleType);
            facts.add(obstacle);
        } else {
            ObjectInFront obstacle = new ObjectInFront(distance, obstacleType);
            facts.add(obstacle);
        }
    }
    return facts;
}
Also used : Position(de.adesso.anki.battle.util.Position) ArrayList(java.util.ArrayList) World(de.adesso.anki.battle.world.World) Body(de.adesso.anki.battle.world.Body)

Example 3 with World

use of de.adesso.anki.battle.world.World in project anki-battle-showcase by adessoAG.

the class FireRocketCommand method execute.

public void execute(Vehicle vehicle) {
    // TODO: set Positions
    if (!vehicle.isRocketReady()) {
        return;
    }
    World world = vehicle.getWorld();
    Rocket rocket = new Rocket(this.direction);
    // TODO speed of rocket
    rocket.setTargetSpeed(300);
    rocket.setPosition(vehicle.getPosition());
    // rocket.setCurrentRoadpiece(vehicle.getCurrentRoadpiece());
    rocket.setWorld(world);
    world.addBody(rocket);
    vehicle.setRocketReady(false);
}
Also used : World(de.adesso.anki.battle.world.World) Rocket(de.adesso.anki.battle.world.bodies.Rocket)

Example 4 with World

use of de.adesso.anki.battle.world.World in project anki-battle-showcase by adessoAG.

the class ShieldCommand method execute.

public void execute(Vehicle vehicle) {
    // TODO:destroy Rocket, mine
    World world = vehicle.getWorld();
    // amount that the shield absorbs
    // vehicle.setEnergy(vehicle.getEnergy()+25);
    vehicle.setShieldReady(false);
}
Also used : World(de.adesso.anki.battle.world.World)

Example 5 with World

use of de.adesso.anki.battle.world.World in project anki-battle-showcase by adessoAG.

the class PutMineCommand method execute.

public void execute(Vehicle vehicle) {
    // TODO: set Positions}
    if (!vehicle.isMineReady()) {
        return;
    }
    World world = vehicle.getWorld();
    Mine mine = new Mine();
    mine.setPosition(vehicle.getPosition());
    world.addBody(mine);
    mine.setWorld(world);
    vehicle.setMineReady(false);
}
Also used : Mine(de.adesso.anki.battle.world.bodies.Mine) World(de.adesso.anki.battle.world.World)

Aggregations

World (de.adesso.anki.battle.world.World)5 Position (de.adesso.anki.battle.util.Position)1 Body (de.adesso.anki.battle.world.Body)1 DynamicBody (de.adesso.anki.battle.world.DynamicBody)1 Mine (de.adesso.anki.battle.world.bodies.Mine)1 Rocket (de.adesso.anki.battle.world.bodies.Rocket)1 ArrayList (java.util.ArrayList)1