use of spacesettlers.objects.Ship in project spacesettlers by amymcgovern.
the class TestCollisionHandler method testElasticCollisionsShipToMoveableAsteroidY.
@Test
public void testElasticCollisionsShipToMoveableAsteroidY() {
Ship ship1;
Asteroid asteroid;
Position ship1Pos = new Position(0, 0, Math.PI / 4);
ship1Pos.setTranslationalVelocity(new Vector2D(0, 20));
ship1 = new Ship("team1", Color.BLUE, ship1Pos);
Position asteroid2Pos = new Position(0, 10, -Math.PI / 4);
asteroid2Pos.setTranslationalVelocity(new Vector2D(0, -10));
asteroid = new Asteroid(asteroid2Pos, false, 10, true, .33, .33, .34);
ship1.setMass(asteroid.getMass());
collisionHandler.collide(ship1, asteroid, space);
assertEquals(ship1.getPosition().getTranslationalVelocityX(), 0, 0.01);
assertEquals(ship1.getPosition().getTranslationalVelocityY(), -10.0, 0.01);
assertEquals(asteroid.getPosition().getTranslationalVelocityX(), 0, 0.01);
assertEquals(asteroid.getPosition().getTranslationalVelocityY(), 20, 0.01);
}
use of spacesettlers.objects.Ship in project spacesettlers by amymcgovern.
the class ObjectInfoPanel method updateData.
/**
* Update the GUI for this step using the simulator data as needed
* @param simulator
*/
public void updateData(SpaceSettlersSimulator simulator) {
// do not update if there is no selected object
if (this.selectedObject == null) {
return;
}
String name = "";
if (selectedObject.getClass() == Asteroid.class) {
Asteroid asteroid = (Asteroid) selectedObject;
if (asteroid.isMineable()) {
name = "Mineable asteroid";
} else {
name = "Non-mineable asteroid";
}
} else if (selectedObject.getClass() == Base.class) {
Base base = (Base) selectedObject;
name = "Base for " + base.getTeamName();
} else if (selectedObject.getClass() == Ship.class) {
Ship ship = (Ship) selectedObject;
name = "Ship for " + ship.getTeamName();
} else if (selectedObject.getClass() == Beacon.class) {
Beacon beacon = (Beacon) selectedObject;
name = "Beacon";
}
objectName.setText(name);
innerPanel.updateData(simulator);
resourcesPanel.updateData(selectedObject);
}
use of spacesettlers.objects.Ship in project spacesettlers by amymcgovern.
the class EMP method applyPowerup.
/**
* Can't fire with shields on so drop them.
* Then give it the cost of use
*/
@Override
public void applyPowerup(AbstractActionableObject actionableObject) {
// can't fire with shields up so automatically drop them
actionableObject.setShielded(false);
// only ships fire weapons (right now) (TODO: fix this when/if bases can)
Ship ship = (Ship) actionableObject;
ship.updateEnergy(getCostToUse());
ship.incrementWeaponCount();
}
use of spacesettlers.objects.Ship in project spacesettlers by amymcgovern.
the class Missile method applyPowerup.
/**
* Apply the power up. For a bullet,
* the means unshielding the ship if it is shielded and updating the energy of the ship.
*/
@Override
public void applyPowerup(AbstractActionableObject actionableObject) {
// can't fire with shields up so automatically drop them
actionableObject.setShielded(false);
// only ships fire bullets (TODO: fix this when/if bases can)
Ship ship = (Ship) actionableObject;
ship.updateEnergy(getCostToUse());
ship.incrementWeaponCount();
}
Aggregations