Search in sources :

Example 46 with Ship

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);
}
Also used : Asteroid(spacesettlers.objects.Asteroid) Vector2D(spacesettlers.utilities.Vector2D) Position(spacesettlers.utilities.Position) Ship(spacesettlers.objects.Ship) Test(org.junit.Test)

Example 47 with Ship

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);
}
Also used : Asteroid(spacesettlers.objects.Asteroid) Beacon(spacesettlers.objects.Beacon) Ship(spacesettlers.objects.Ship) Base(spacesettlers.objects.Base)

Example 48 with Ship

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();
}
Also used : Ship(spacesettlers.objects.Ship)

Example 49 with Ship

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();
}
Also used : Ship(spacesettlers.objects.Ship)

Aggregations

Ship (spacesettlers.objects.Ship)49 UUID (java.util.UUID)20 Base (spacesettlers.objects.Base)19 Position (spacesettlers.utilities.Position)18 HashMap (java.util.HashMap)16 AbstractAction (spacesettlers.actions.AbstractAction)15 DoNothingAction (spacesettlers.actions.DoNothingAction)15 AbstractObject (spacesettlers.objects.AbstractObject)15 AbstractActionableObject (spacesettlers.objects.AbstractActionableObject)9 Asteroid (spacesettlers.objects.Asteroid)9 Vector2D (spacesettlers.utilities.Vector2D)8 Test (org.junit.Test)7 MoveToObjectAction (spacesettlers.actions.MoveToObjectAction)7 PurchaseTypes (spacesettlers.actions.PurchaseTypes)7 Beacon (spacesettlers.objects.Beacon)7 AiCore (spacesettlers.objects.AiCore)6 Flag (spacesettlers.objects.Flag)5 Team (spacesettlers.clients.Team)4 ResourcePile (spacesettlers.objects.resources.ResourcePile)4 ExecutionException (java.util.concurrent.ExecutionException)2