Example #1
0
 @Override
 public void restart(ReferenceTime time) {
   if (this.delayStart == 0) {
     this.nextPlayTime =
         time.getMilliseconds() + (long) (random.nextFloat() * this.delayMax * 1000);
   } else {
     this.nextPlayTime = time.getMilliseconds() + (long) (this.delayStart * 1000);
   }
 }
Example #2
0
  @Override
  public void play(ReferenceTime time, float fadeFactor) {
    if (time.getMilliseconds() < this.nextPlayTime) return;

    if (this.provider.exists(this.event)) {
      this.provider.get(this.event).playSound(this.volMod * fadeFactor, this.pitchMod);
    }

    if (this.delayMin == this.delayMax && this.delayMin > 0) {
      while (this.nextPlayTime < time.getMilliseconds()) {
        this.nextPlayTime = this.nextPlayTime + (long) (this.delayMin * 1000);
      }
    } else {
      this.nextPlayTime =
          time.getMilliseconds()
              + (long)
                  ((this.delayMin + random.nextFloat() * (this.delayMax - this.delayMin)) * 1000);
    }
  }