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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations