@Override
  public void onComplete(Animation anim) {
    super.onComplete(anim);

    if (visible && emitter != null && anim == idle) {
      emitter.burst(Speck.factory(Speck.FORGE), 3);
      float volume = 0.2f / (Level.distance(ch.pos, Dungeon.hero.pos));
      Sample.INSTANCE.play(Assets.SND_EVOKE, volume, volume, 0.8f);
    }
  }
 public void add(State state) {
   switch (state) {
     case BURNING:
       burning = emitter();
       burning.pour(FlameParticle.FACTORY, 0.06f);
       if (getVisible()) {
         Sample.INSTANCE.play(Assets.SND_BURNING);
       }
       break;
     case LEVITATING:
       levitation = emitter();
       levitation.pour(Speck.factory(Speck.JET), 0.02f);
       break;
     case INVISIBLE:
       PotionOfInvisibility.melt(ch);
       break;
     case PARALYSED:
       paused = true;
       break;
     case FROZEN:
       iceBlock = IceBlock.freeze(this);
       paused = true;
       break;
     case ILLUMINATED:
       GameScene.effect(halo = new TorchHalo(this));
       break;
   }
 }
  @Override
  protected void createChildren() {

    shield = new NinePatch(Assets.STATUS, 80, 0, 30 + 18, 0);
    add(shield);

    add(
        new TouchArea(0, 1, 31, 31) {
          @Override
          protected void onClick(Touch touch) {
            Image sprite = Dungeon.hero.sprite;
            if (!sprite.isVisible()) {
              Camera.main.focusOn(sprite);
            }
            GameScene.show(new WndHero());
          }
        });

    btnMenu = new MenuButton();
    add(btnMenu);

    avatar = HeroSprite.avatar(Dungeon.hero.heroClass, lastTier);
    add(avatar);

    blood = new Emitter();
    blood.pos(avatar);
    blood.pour(BloodParticle.FACTORY, 0.3f);
    blood.autoKill = false;
    blood.on = false;
    add(blood);

    compass = new Compass(Dungeon.level.exit);
    add(compass);

    hp = new Image(Assets.HP_BAR);
    add(hp);

    exp = new Image(Assets.XP_BAR);
    add(exp);

    level = new BitmapText(PixelScene.font1x);
    level.hardlight(0xFFEBA4);
    add(level);

    depth = new BitmapText(Integer.toString(Dungeon.depth), PixelScene.font1x);
    depth.hardlight(0xCACFC2);
    depth.measure();
    add(depth);

    Dungeon.hero.belongings.countIronKeys();
    keys = new BitmapText(PixelScene.font1x);
    keys.hardlight(0xCACFC2);
    add(keys);

    danger = new DangerIndicator();
    add(danger);

    buffs = new BuffIndicator(Dungeon.hero);
    add(buffs);
  }
 public void remove(State state) {
   switch (state) {
     case BURNING:
       if (burning != null) {
         burning.on = false;
         burning = null;
       }
       break;
     case LEVITATING:
       if (levitation != null) {
         levitation.on = false;
         levitation = null;
       }
       break;
     case INVISIBLE:
       alpha(1f);
       break;
     case PARALYSED:
       paused = false;
       break;
     case FROZEN:
       if (iceBlock != null) {
         iceBlock.melt();
         iceBlock = null;
       }
       paused = false;
       break;
     case ILLUMINATED:
       if (halo != null) {
         halo.putOut();
       }
       break;
   }
 }
  @Override
  public void link(Char ch) {
    super.link(ch);

    emitter = new Emitter();
    emitter.autoKill = false;
    emitter.pos(x + 7, y + 12);
    parent.add(emitter);
  }
Beispiel #6
0
  public static void at(PointF p, final float dir, final float cone, final int color, int n) {

    if (n <= 0) {
      return;
    }

    Emitter emitter = GameScene.emitter();
    emitter.pos(p);

    FACTORY.color = color;
    FACTORY.dir = dir;
    FACTORY.cone = cone;
    emitter.burst(FACTORY, n);
  }
Beispiel #7
0
  public static void at(PointF p, final int color, int n) {

    if (n <= 0) {
      return;
    }

    Emitter emitter = GameScene.emitter();
    emitter.pos(p);

    FACTORY.color = color;
    FACTORY.dir = -3.1415926f / 2;
    FACTORY.cone = 3.1415926f;
    emitter.burst(FACTORY, n);
  }
  @Override
  public void update() {
    super.update();

    if (emitter != null) {
      emitter.visible = visible;
    }
  }
Beispiel #9
0
    @Override
    public void emit(Emitter emitter, int index, float x, float y) {
      PixelParticle p = (PixelParticle) emitter.recycle(PixelParticle.Shrinking.class);

      p.reset(x, y, color, 4, Random.Float(0.5f, 1.0f));
      p.speed.polar(Random.Float(dir - cone / 2, dir + cone / 2), Random.Float(40, 80));
      p.acc.set(0, +100);
    }
  @Override
  public void die() {
    super.die();

    if (cloud != null) {
      cloud.on = false;
    }
  }
  @Override
  public void update() {

    super.update();

    if (cloud != null) {
      cloud.visible = visible;
    }
  }
  @Override
  public void link(Char ch) {
    super.link(ch);

    if (cloud == null) {
      cloud = emitter();
      cloud.pour(Speck.factory(Speck.TOXIC), 0.7f);
    }
  }
    @Override
    public void update() {
      if (setVisible(Dungeon.visible[pos])) {

        super.update();

        if ((rippleDelay -= Game.elapsed) <= 0) {
          GameScene.ripple(pos + Dungeon.level.getWidth()).y -= DungeonTilemap.SIZE / 2;
          rippleDelay = Random.Float(0.2f, 0.3f);
        }
      }
    }
  @Override
  public void update() {

    super.update();

    if (paused && listener != null) {
      listener.onComplete(curAnim);
    }

    if (flashTime > 0 && (flashTime -= Game.elapsed) <= 0) {
      resetColor();
    }

    boolean visible = getVisible();

    if (burning != null) {
      burning.setVisible(visible);
    }
    if (levitation != null) {
      levitation.setVisible(visible);
    }
    if (iceBlock != null) {
      iceBlock.setVisible(visible);
    }
    if (sleeping) {
      showSleep();
    } else {
      hideSleep();
    }

    if (controlled) {
      showMindControl();
    }

    if (emo != null) {
      emo.setVisible(visible);
    }
  }
  @Override
  public void update() {
    super.update();

    float health = (float) Dungeon.hero.HP / Dungeon.hero.HT;

    if (health == 0) {
      avatar.tint(0x000000, 0.6f);
      blood.on = false;
    } else if (health < 0.25f) {
      avatar.tint(0xcc0000, 0.4f);
      blood.on = true;
    } else {
      avatar.resetColor();
      blood.on = false;
    }

    hp.scale.x = health;
    exp.scale.x = (width / exp.width) * Dungeon.hero.exp / Dungeon.hero.maxExp();

    if (Dungeon.hero.lvl != lastLvl) {

      if (lastLvl != -1) {
        Emitter emitter = (Emitter) recycle(Emitter.class);
        emitter.revive();
        emitter.pos(27, 27);
        emitter.burst(Speck.factory(Speck.STAR), 12);
      }

      lastLvl = Dungeon.hero.lvl;
      level.text(Integer.toString(lastLvl));
      level.measure();
      level.x = PixelScene.align(27.0f - level.width() / 2);
      level.y = PixelScene.align(27.5f - level.baseLine() / 2);
    }

    int k = IronKey.curDepthQuantity;
    if (k != lastKeys) {
      lastKeys = k;
      keys.text(Integer.toString(lastKeys));
      keys.measure();
      keys.x = width - 8 - keys.width() - 18;
    }

    int tier = Dungeon.hero.tier();
    if (tier != lastTier) {
      lastTier = tier;
      avatar.copy(HeroSprite.avatar(Dungeon.hero.heroClass, tier));
    }
  }
 @Override
 public void emit(Emitter emitter, int index, float x, float y) {
   for (int i = 0; i < 3; i++) {
     ((WebParticle) emitter.recycle(WebParticle.class)).reset(x, y);
   }
 }
 @Override
 public void emit(Emitter emitter, int index, float x, float y) {
   ((PoisonParticle) emitter.recycle(PoisonParticle.class)).resetSplash(x, y);
 }
 @Override
 public void emit(Emitter emitter, int index, float x, float y) {
   WaterParticle p = (WaterParticle) emitter.recycle(WaterParticle.class);
   p.reset(x, y);
 }
 @Override
 public void emit(Emitter emitter, int index, float x, float y) {
   LeafParticle p = ((LeafParticle) emitter.recycle(LeafParticle.class));
   p.color(ColorMath.random(Dungeon.level.color1, Dungeon.level.color2));
   p.reset(x, y);
 }
 public Emitter bottomEmitter() {
   Emitter emitter = GameScene.emitter();
   emitter.pos(x, y + height, width, 0);
   return emitter;
 }
 public Emitter centerEmitter() {
   Emitter emitter = GameScene.emitter();
   emitter.pos(center());
   return emitter;
 }
 public Emitter emitter() {
   Emitter emitter = GameScene.emitter();
   emitter.pos(this);
   return emitter;
 }
 @Override
 public void emit(Emitter emitter, int index, float x, float y) {
   ((SnowParticle) emitter.recycle(SnowParticle.class)).reset(x, y);
 }
 @Override
 public void emit(Emitter emitter, int index, float x, float y) {
   LeafParticle p = ((LeafParticle) emitter.recycle(LeafParticle.class));
   p.color(ColorMath.random(0x004400, 0x88CC44));
   p.reset(x, y);
 }