use of de.adesso.anki.battle.world.bodies.Mine in project anki-battle-showcase by adessoAG.
the class SimulationInitializer method addVehicles.
private void addVehicles() {
Vehicle vehicle = new Vehicle();
vehicle.setName("vehicle1");
vehicle.setWorld(world);
vehicle.setTrack(3);
vehicle.setCurrentRoadpiece(world.getRoadmap().getAnchor().reverse());
vehicle.setPosition(world.getRoadmap().getAnchor().getEntry().reverse());
vehicle.setTargetSpeed(250);
vehicle.setMineReady(true);
vehicle.setRocketReady(true);
world.addBody(vehicle);
/* Vehicle vehicle2 = new Vehicle();
vehicle2.setName("vehicle2");
vehicle2.setWorld(world);
vehicle2.setTrack(3);
vehicle2.setCurrentRoadpiece(world.getRoadmap().getAnchor().reverse());
vehicle2.setPosition(world.getRoadmap().getAnchor().getEntry().reverse());
vehicle2.setTargetSpeed(800);
vehicle2.setMineReady(true);
vehicle2.setRocketReady(true);
world.addBody(vehicle2);*/
Mine mine = new Mine();
mine.setWorld(world);
mine.setTargetSpeed(0);
mine.setCurrentRoadpiece(world.getRoadmap().getAnchor().getNext().getNext().getNext().getNext().getNext().reverse());
mine.setPosition(world.getRoadmap().getAnchor().getNext().getNext().getNext().getNext().getNext().getEntry().reverse());
world.addBody(mine);
Mine mine2 = new Mine();
mine2.setWorld(world);
mine2.setTargetSpeed(0);
mine2.setCurrentRoadpiece(world.getRoadmap().getAnchor().getNext().getNext().getNext().reverse());
mine2.setPosition(world.getRoadmap().getAnchor().getNext().getNext().getNext().getEntry().reverse());
world.addBody(mine2);
/*Vehicle vehicle2 = new Vehicle();
vehicle2.setName("vehicle2");
vehicle2.setWorld(world);
vehicle2.setTrack(1);
vehicle2.setCurrentRoadpiece(world.getRoadmap().getAnchor());
vehicle2.setPosition(world.getRoadmap().getAnchor().getEntry());
vehicle2.setTargetSpeed(750);
vehicle2.setRocketReady(true);
world.addBody(vehicle2);
*/
}
use of de.adesso.anki.battle.world.bodies.Mine 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);
}
use of de.adesso.anki.battle.world.bodies.Mine in project anki-battle-showcase by adessoAG.
the class GameEngine method checkCollision.
private boolean checkCollision(Body weapon) {
if (weapon instanceof Vehicle) {
return false;
}
// merge into new superclass weapon ?
if (weapon instanceof Rocket && !((Rocket) weapon).isActive()) {
return false;
}
if (weapon instanceof Mine && !((Mine) weapon).isActive()) {
return false;
}
List<Vehicle> vehicles = world.getVehicles();
Position pos1 = weapon.getPosition();
boolean succesfulHit = false;
// TODO find damage values for weapon types
int damage = ((weapon instanceof Rocket) ? 10 : 20);
for (Vehicle vehicle : vehicles) {
Position pos2 = vehicle.getPosition();
double distance = pos1.distance(pos2);
// TODO find distance value that indicates a collision
double dummyValue = 30;
if (distance < dummyValue) {
System.out.println("BOOM: " + weapon.getClass().getSimpleName());
vehicle.setEnergy(vehicle.getEnergy() - damage);
System.out.println(vehicle.getEnergy());
succesfulHit = true;
}
}
return succesfulHit;
}