예제 #1
0
  public void createMissile() {
    // generate missile id
    String MissileId = IdGenerator.defenseDestractorLauncherMissileIdGenerator(type.charAt(0));

    // create new missile
    currentMissile = new DefenseDestructorMissile(MissileId, toDestroy, this, statistics);

    // register all listeners
    for (WarEventListener l : allListeners) currentMissile.registerListeners(l);
  }
예제 #2
0
  public void launchMissile() throws InterruptedException {
    // create launcher destructor missile
    createMissile();

    // sleep for launch time;
    sleep(Utils.LAUNCH_DURATION);

    if (toDestroy != null && toDestroy.isAlive() && !toDestroy.getIsHidden()) {
      // Throw event
      fireLaunchMissileEvent(currentMissile.getMissileId());

      // Start missile and wait until he will finish to be able
      // to shoot anther one
      currentMissile.start();
      currentMissile.join();
    } else {
      if (toDestroy.getIsHidden()) {
        fireLauncherIsHiddenEvent(toDestroy.getLauncherId());
      } else {
        fireLauncherNotExist(toDestroy.getLauncherId());
      }
    }
  }