Exemplo n.º 1
0
  @Override
  public void execute() {
    coolDownTimer.update();
    if (GameInfo.player.isDead() || GameInfo.player.IsGhost || ((FishEntity) mOwner).IsEnsnared)
      return;

    if (!isActive
        && Utility.areObjectsWithinRange(
            mOwner, GameInfo.player, 60 + 120 * mOwner.entityScale.getEffectValue())
        && coolDownTimer.isTimeUp()) {

      isActive = true;

      SpeedPowerUpAffect power =
          ObjectRegistry.superPool.affectSpeedPowerUpPool
              .get(); // ObjectRegistry.superPool.affectLurePowerUpPool.get();
      power.setTimeToFinish(POWER_DURATION);
      mOwner.addAffect(power);

      coolDownTimer.set(COOLDOWN_TIME);
      coolDownTimer.reset();
    }
    // makes sure affect is not applied twice
    // in case when coolDowntimer is faster than power duration
    else if (coolDownTimer.isTimeUp() && isActive) {
      isActive = false;
    }
  }
Exemplo n.º 2
0
  @Override
  public boolean checkCondition() {

    rate.update();
    boolean ret = rate.isTimeUp();

    if (ret) {
      rate.reset();
    }

    return ret;
  }