Exemple #1
0
  /**
   * Tests that the swarm trigger of spawning only when the prior swarms reaches a certain death
   * ratio is working.
   */
  public void testUpdate_withDeadRatioTrigger() {
    MockEnemyShip enemy1 = enemyStockpile.take(MockEnemyShip.class);
    MockEnemyShip enemy2 = enemyStockpile.take(MockEnemyShip.class);
    MockEnemyShip enemy3 = enemyStockpile.take(MockEnemyShip.class);
    enemy1.active = true;
    enemy2.active = true;
    enemy3.active = true;

    priorSwarm.triggered = true;
    priorSwarm.spawnedShips.add(enemy1);
    priorSwarm.spawnedShips.add(enemy2);
    priorSwarm.spawnedShips.add(enemy3);

    swarm.priorSwarm = priorSwarm;
    swarm.triggerType = Swarm.TRIGGER_AFTER_LAST_DEAD_RATIO;
    swarm.triggerDeadRatio = .5f;

    // Test whent they are all still alive
    swarm.update(0);
    assertFalse(swarm.triggered);

    // Kill one
    enemy1.kill();
    swarm.update(0);
    assertFalse(swarm.triggered);

    // Kill the second one, this should put the dead over the ratio.
    enemy2.kill();
    swarm.update(0);
    assertTrue(swarm.triggered);
  }
Exemple #2
0
  /** Tests that swarm spawn delays are working. */
  public void testUpdate_withDelayTrigger_withDelay() {
    priorSwarm.triggered = true;

    swarm.triggerType = Swarm.TRIGGER_AFTER_DELAY;
    swarm.triggerDelay = 100;

    assertFalse(swarm.triggered);

    swarm.update(0);
    assertFalse(swarm.triggered);

    swarm.update(50);
    assertFalse(swarm.triggered);

    swarm.update(60);
    assertTrue(swarm.triggered);
  }
Exemple #3
0
  /** Tests that a swarm is triggered automatically when the prior one is dead. */
  public void testUpdate_withNoPriorSwarm() {
    assertFalse(swarm.triggered);

    swarm.priorSwarm = null;
    swarm.update(0);

    assertTrue(swarm.triggered);
  }
Exemple #4
0
  /** Tests that a swarm is not triggered when the prior swarm is still alive. */
  public void testUpdate_withUntriggeredPriorSwarm() {
    priorSwarm.triggered = false;

    swarm.triggerType = Swarm.TRIGGER_AFTER_DELAY;
    swarm.triggerDelay = 0;

    swarm.update(0);

    assertFalse(swarm.triggered);
  }
Exemple #5
0
  /**
   * Tests that the swarm trigger of spawning only when all the prior swarms elements are dead is
   * working.
   */
  public void testUpdate_withAllDeadTrigger() {
    MockEnemyShip enemy = enemyStockpile.take(MockEnemyShip.class);
    enemy.active = true;

    priorSwarm.triggered = true;
    priorSwarm.spawnedShips.add(enemy);

    swarm.priorSwarm = priorSwarm;
    swarm.triggerType = Swarm.TRIGGER_AFTER_LAST_DEAD;
    swarm.triggerDelay = 0;

    // Start with the prior swarm still alive.
    swarm.update(0);
    assertFalse(swarm.triggered);

    // Kill the prior swarm and assert that the swarm is triggered now.
    enemy.kill();
    swarm.update(0);
    assertTrue(swarm.triggered);
  }