Exemple #1
0
 public int hashCode() {
   int result;
   long temp;
   result = sourceState != null ? sourceState.hashCode() : 0;
   result = 31 * result + (targetState != null ? targetState.hashCode() : 0);
   result = 31 * result + (int) (launchTime ^ (launchTime >>> 32));
   temp = (long) (speed * 100);
   result = 31 * result + (int) (temp ^ (temp >>> 32));
   return result;
 }
Exemple #2
0
 public boolean check() {
   final double width = targetState.getRobot().getWidth();
   final double height = targetState.getRobot().getHeight();
   final Rectangle targetRect =
       new Rectangle(
           (int) (targetState.getRobot().getX() - width / 2),
           (int) (targetState.getRobot().getY() - height / 2),
           (int) width,
           (int) height);
   final LXXPoint bulletPos =
       (LXXPoint)
           sourceState.project(sourceState.angleTo(targetState.getRobot()), getTraveledDistance());
   final boolean contains = targetRect.contains(bulletPos);
   if (contains) {
     final double bo = LXXUtils.bearingOffset(sourceState, targetState, targetState.getRobot());
     final double targetWidth =
         LXXUtils.getRobotWidthInRadians(sourceState, targetState.getRobot());
     final IntervalDouble currentInterval =
         new IntervalDouble(bo - targetWidth / 2, bo + targetWidth / 2);
     if (hitBearingOffsetInterval == null) {
       hitBearingOffsetInterval = currentInterval;
     } else {
       hitBearingOffsetInterval.a = min(hitBearingOffsetInterval.a, currentInterval.a);
       hitBearingOffsetInterval.b = max(hitBearingOffsetInterval.b, currentInterval.b);
     }
   }
   return contains;
 }
Exemple #3
0
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Wave wave = (Wave) o;

    if (launchTime != wave.launchTime) return false;
    if (!Utils.isNear(wave.speed, speed)) return false;
    if (sourceState != null ? !sourceState.equals(wave.sourceState) : wave.sourceState != null)
      return false;
    if (targetState != null ? !targetState.equals(wave.targetState) : wave.targetState != null)
      return false;

    return true;
  }
Exemple #4
0
 public double getTraveledDistance() {
   return (sourceState.getRobot().getTime() - launchTime + 1) * speed;
 }