@Override
  public void setPosition(Pointt position) {
    super.setPosition(position);
    generatePaint();
    double startAngle = Maths.randomAngle();
    GeneralPath tempRep = new GeneralPath();

    Pointt next = new Pointt(0, 0);
    for (int i = 0; i < vertices.length; i++) {
      vertices[i] =
          next.getArcPointt(
              radius() * Geometry.DISPLAY_REAL_RATIO,
              startAngle + i * 2 * (Math.PI / NUMBER_OF_VERTICES));
    }

    tempRep.moveTo(vertices[0].getX(), vertices[0].getY());

    for (int i = 0; i < vertices.length; i++) {
      next = vertices[(i + 1) % vertices.length];
      tempRep.quadTo(
          vertices[i].midPoint(next).getX()
              + Maths.randomNegative(radius() * Geometry.DISPLAY_REAL_RATIO / 2),
          vertices[i].midPoint(next).getY()
              + Maths.randomNegative(radius() * Geometry.DISPLAY_REAL_RATIO / 2),
          next.getX(),
          next.getY());
    }

    tempRep.closePath();
    rep = new Area(tempRep);

    for (int i = 0; i < vertices.length; i++) {
      vertices[i].translate(position);
    }
  }
  @Override
  public void plot(Graphics2D a, AffineTransform transform, Pointt focus) {
    if (activate()) {
      a.setTransform(transform);
      Pointt display = displayPosition(focus);
      a.translate(display.getX(), display.getY());

      if (ELAPSE_TIME - elapsedTime() < DISAPPEAR_TIME) {
        if (ELAPSE_TIME - elapsedTime() > 0) {
          a.setComposite(
              AlphaComposite.getInstance(
                  AlphaComposite.SRC_OVER, (ELAPSE_TIME - elapsedTime()) / (float) DISAPPEAR_TIME));
        } else {
          return;
        }
      } else {
        a.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f));
      }
      a.setPaint(paint);
      a.fill(getRep());
      a.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));

      if (Math.random() < 0.5) {
        synchronized (game().visualEffects()) {
          game()
              .visualEffects()
              .add(
                  new UniversalEffect(
                      position().randomRange(25),
                      Sarcophagidae.repInstances[0],
                      Sarcophagidae.standardColors,
                      APPEAR_TIME_VISUAL / 100,
                      APPEAR_SPEED_VISUAL,
                      Maths.randomAngle(),
                      UniversalEffect.STAND_STILL,
                      UniversalEffect.FADING,
                      UniversalEffect.FIX_SCALE));
        }
      }
    }
  }
Esempio n. 3
0
  @Override
  public synchronized void moveNoCollision(double time) {
    if (2 * relativeTime >= SKILL_BOUND) { // Half Period
      clearTask();
      owner().increaseSplitFire();
      owner()
          .setAttackSpeed(
              Math.max(owner().attackSpeed() - ATTACK_SPEED_DECREMENT, ATTACK_SPEED_MINIMUM));

      synchronized (owner()) {
        owner().rescheduleAttack(0);
      }

      owner().removeDive();
    } else {
      relativeTime += INCREMENT;
      owner().setHealth(owner().health() + healthIncrement, Units.MAGICAL_DAMAGE);

      Pointt currentPosition = position(relativeTime);
      Pointt veryClose = position(relativeTime + DELTA);
      owner().setMovingAngle(currentPosition.angle(veryClose));
      owner().setPosition(currentPosition);

      for (int i = 1; i < 10; i++) {
        synchronized (game().visualEffects()) {
          game()
              .visualEffects()
              .add(
                  new UniversalEffect(
                      position(relativeTime - i * INCREMENT / 5),
                      DragonFly.repInstances[0],
                      DragonFly.standardColors,
                      (i + 1) / FADE_TIME,
                      0,
                      owner().movingAngle(),
                      UniversalEffect.STAND_STILL,
                      UniversalEffect.FADING,
                      UniversalEffect.FIX_SCALE));
        }
      }

      if (owner().pathOfVenoms().activate()) {
        Venom toBeAdd =
            new Venom(game(), owner(), owner().position(), 0, 0, PathOfVenoms.VENOM_TYPE);
        synchronized (owner().projectiles()) {
          owner().projectiles().add(toBeAdd);
        }

        synchronized (owner().venoms()) {
          owner().venoms().add(toBeAdd);
        }

        toBeAdd.schedule();
      }

      int random = Maths.RANDOM.nextInt(Petaluridae.repInstances[0].parts().size());
      ArrayList<Area> part = new ArrayList<>();
      part.add(new Area(Petaluridae.repInstances[0].parts().get(random)));

      synchronized (game().visualEffects()) {
        game()
            .visualEffects()
            .add(
                new UniversalEffect(
                    owner().position(),
                    new RepInstance(part),
                    Petaluridae.standardColors.get(random),
                    UniversalEffect.DEFAULT_COUNT_DOWN,
                    0,
                    Maths.randomAngle(),
                    UniversalEffect.STAND_STILL,
                    UniversalEffect.FADING,
                    UniversalEffect.FIX_SCALE));
      }
    }
  }