@Override
  public void start() {
    OwnedObjectData data = new OwnedObjectData();

    data.drawAfter = true;

    if (bullet.getTicksAlive() < 20) animationPlaying = true;

    createTick = game.getTick();

    bullet.addOwnedObject(this, data);

    final Sprite current = (Sprite) this.ani.getKeyFrame(getTicksAlive());

    Polygon hitbox = bullet.getHitbox();
    Rectangle rect =
        hitbox != null ? hitbox.getBoundingRectangle() : current.getBoundingRectangle();

    final float modifier = 3f;
    float width = rect.getWidth() * modifier;
    float height = rect.getHeight() * modifier;

    final float scaleX = width / current.getWidth();
    final float scaleY = height / current.getHeight();

    current.setScale(scaleX, scaleY);
    current.setRotation(bullet.getRotationDeg());

    current.setOriginCenter();

    Color c = bullet.getDeletionColor().cpy();

    float min = Math.min(c.g, Math.min(c.r, c.b));
    c.r -= min;
    c.g -= min;
    c.b -= min;

    float mul = 0.8f;
    float start = (1f - mul) + 0.3f;

    Color color = new Color(start + (c.r * mul), start + (c.g * mul), start + (c.b * mul), 0f);

    current.setColor(color);
    current.setAlpha(1f);

    final SaveableObject<ScaleAlphaPhaseAnimation> sani =
        new SaveableObject<ScaleAlphaPhaseAnimation>();

    Getter<Sprite> getter =
        new Getter<Sprite>() {
          @Override
          public Sprite get() {
            Sprite current = (Sprite) ani.getKeyFrame(getTicksAlive());

            int over = 5;

            int ticks = (int) ((time.toTicks() - over) - getTicksAlive());

            double mul = 1f - (ticks <= 0 ? -(float) ticks / over : 0f);

            ScaleAlphaPhaseAnimation ani = sani.getObject();

            if (ani == null) return current;

            if (ticks <= 0) {
              animationPlaying = false;
              ani.setAlpha((float) Math.max(0, mul));
            }

            current.setPosition(
                bullet.getX() - current.getWidth() / 2f, bullet.getY() - current.getHeight() / 2f);

            current.setOriginCenter();

            current.setRotation(bullet.getRotationDeg());

            return current;
          }
        };

    final ScaleAlphaPhaseAnimation ani = new ScaleAlphaPhaseAnimation(getter, bullet);

    sani.setObject(ani);

    ani.setTime(time);
    ani.setAddedScale(scaleX * 3f, scaleY * 3f);
    ani.setAlpha(-0.1f);
    ani.start();

    bullet.removeOwnedObject(ani);
    bullet.addOwnedObject(ani, data);
  }
Beispiel #2
0
  @Override
  public void executeFight(final AllStarStageScheme scheme) {
    final J2hGame g = Game.getGame();
    final Ringo boss = this;

    final SaveableObject<CircleHealthBar> bar = new SaveableObject<CircleHealthBar>();

    Game.getGame()
        .addTaskGame(
            new Runnable() {
              @Override
              public void run() {
                BossUtil.cloudEntrance(
                    boss,
                    AllStarUtil.from255RGB(255, 183, 0),
                    AllStarUtil.from255RGB(255, 232, 0),
                    60);

                g.addTaskGame(
                    new Runnable() {
                      @Override
                      public void run() {
                        bar.setObject(new CircleHealthBar(boss));

                        g.spawn(boss);
                        g.spawn(bar.getObject());

                        bar.getObject().addSplit(0.8f);

                        AllStarUtil.introduce(boss);

                        boss.healUp();
                        BossUtil.addBossEffects(boss, boss.getAuraColor(), boss.getBgAuraColor());

                        Game.getGame().startSpellCard(new NonSpell(boss));
                      }
                    },
                    60);
              }
            },
            1);

    scheme.wait(
        new WaitConditioner() {
          @Override
          public boolean returnTrueToWait() {
            return !boss.isOnStage();
          }
        });

    SchemeUtil.waitForDeath(scheme, boss);

    bar.getObject().split();
    boss.setHealth(boss.getMaxHealth());

    Game.getGame()
        .addTaskGame(
            new Runnable() {
              @Override
              public void run() {
                boss.playSpecial(false);

                game.clear(ClearType.ALL);

                backgroundSpawner.set(scheme.getBossAura());

                AllStarUtil.presentSpellCard(boss, SPELLCARD_NAME);

                final Spell card = new Spell(boss);

                Game.getGame().startSpellCard(card);

                BossUtil.spellcardCircle(boss, card, scheme.getBossAura());
              }
            },
            1);

    SchemeUtil.waitForDeath(scheme, boss);

    Game.getGame()
        .addTaskGame(
            new Runnable() {
              @Override
              public void run() {
                Game.getGame().clearCircle(800f, boss, ClearType.ALL);
              }
            },
            1);

    scheme.waitTicks(2);

    boss.playSpecial(false);
    SchemeUtil.deathAnimation(scheme, boss, boss.getAuraColor());

    Game.getGame()
        .addTaskGame(
            new Runnable() {
              @Override
              public void run() {
                ObjectUtil.deathAnimation(boss);

                Game.getGame().delete(boss);

                Game.getGame().clear(ClearType.ALL);
              }
            },
            5);

    scheme.waitTicks(10); // Prevent concurrency issues.
  }