Esempio n. 1
0
  /* (non-Javadoc)
   * @see com.soartech.simjr.sim.entities.AbstractEntity#tick(double)
   */
  @Override
  public void processTick(double dt) {
    if (hit) {
      return;
    }

    Vector3 targetPos = target != null ? target.getPosition() : staticTarget;
    Vector3 dir = targetPos.subtract(getPosition()).normalized();

    setHeading(Math.atan2(dir.y, dir.x));
    setVelocity(dir.multiply(speed));

    super.processTick(dt);

    Vector3 newPos = getPosition();
    if (newPos.subtract(targetPos).length() < speed * dt * 1.5) {
      hit = true;

      getSimulation().detonate(new Detonation(getSimulation(), weapon, target, staticTarget));
      // if (shooter != null)
      // {
      //    removeFlyOut(shooter, this);
      // }
      weapon.removeFlyout(this);
      getSimulation().removeEntity(this);
    }
  }
Esempio n. 2
0
 public double getRangeToTarget() {
   Vector3 targetPos = target != null ? target.getPosition() : staticTarget;
   return targetPos.distance(getPosition());
 }
Esempio n. 3
0
 public double getBearingToTarget() {
   Vector3 targetPos = target != null ? target.getPosition() : staticTarget;
   targetPos.subtract(getPosition());
   return Math.toDegrees(Angles.boundedAngleRadians(Angles.getBearing(targetPos)));
 }
Esempio n. 4
0
 public int getTimeToTarget() {
   Vector3 targetPos = target != null ? target.getPosition() : staticTarget;
   return (int) Math.round(targetPos.distance(getPosition()) / this.getClosingSpeed());
 }