コード例 #1
0
  public void drop() {

    if (heap.isEmpty()) {
      return;
    }

    dropInterval = DROP_INTERVAL;

    speed.set(0, -100);
    acc.set(0, -speed.y / DROP_INTERVAL * 2);

    if (visible && heap != null && heap.peek() instanceof Gold) {
      CellEmitter.center(heap.pos).burst(Speck.factory(Speck.COIN), 5);
      Sample.INSTANCE.play(Assets.SND_GOLD, 1, 1, Random.Float(0.9f, 1.1f));
    }
  }
コード例 #2
0
  @Override
  public void update() {
    super.update();

    visible = (heap == null || Dungeon.visible[heap.pos]);

    if (dropInterval > 0 && (dropInterval -= Game.elapsed) <= 0) {

      speed.set(0);
      acc.set(0);
      place(heap.pos);

      if (visible) {
        boolean water = Level.water[heap.pos];

        if (water) {
          GameScene.ripple(heap.pos);
        } else {
          int cell = Dungeon.level.map[heap.pos];
          water = (cell == Terrain.WELL || cell == Terrain.ALCHEMY);
        }

        if (!(heap.peek() instanceof Gold)) {
          Sample.INSTANCE.play(water ? Assets.SND_WATER : Assets.SND_STEP, 0.8f, 0.8f, 1.2f);
        }
      }
    }

    if (visible && glowing != null) {
      if (glowUp && (phase += Game.elapsed) > glowing.period) {

        glowUp = false;
        phase = glowing.period;

      } else if (!glowUp && (phase -= Game.elapsed) < 0) {

        glowUp = true;
        phase = 0;
      }

      float value = phase / glowing.period * 0.6f;

      rm = gm = bm = 1 - value;
      ra = glowing.red * value;
      ga = glowing.green * value;
      ba = glowing.blue * value;
    }
  }
コード例 #3
0
 public void link(Heap heap) {
   this.heap = heap;
   view(heap.image(), heap.glowing());
   place(heap.pos);
 }