Ejemplo n.º 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);
  }
Ejemplo n.º 2
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);
  }