Exemplo n.º 1
0
    @Override
    protected void layout() {

      super.layout();

      shield.x = x;
      shield.y = y + (height - shield.height) / 2;

      position.x = align(shield.x + (shield.width - position.width()) / 2);
      position.y = align(shield.y + (shield.height - position.height()) / 2 + 1);

      if (flare != null) {
        flare.point(shield.center());
      }

      classIcon.x = align(x + width - classIcon.width);
      classIcon.y = shield.y;

      level.x = align(classIcon.x + (classIcon.width - level.width()) / 2);
      level.y = align(classIcon.y + (classIcon.height - level.height()) / 2 + 1);

      steps.x = align(x + width - steps.width - classIcon.width);
      steps.y = shield.y;

      depth.x = align(steps.x + (steps.width - depth.width()) / 2);
      depth.y = align(steps.y + (steps.height - depth.height()) / 2 + 1);

      desc.x = shield.x + shield.width + GAP;
      desc.maxWidth = (int) (steps.x - desc.x);
      desc.measure();
      desc.y = align(shield.y + (shield.height - desc.height()) / 2 + 1);
    }
  @Override
  protected void layout() {

    height = 32;

    shield.size(width, shield.height);

    avatar.x = PixelScene.align(camera(), shield.x + 15 - avatar.width / 2);
    avatar.y = PixelScene.align(camera(), shield.y + 16 - avatar.height / 2);

    compass.x = avatar.x + avatar.width / 2 - compass.origin.x;
    compass.y = avatar.y + avatar.height / 2 - compass.origin.y;

    hp.x = 30;
    hp.y = 3;

    depth.x = width - 24 - depth.width() - 18;
    depth.y = 6;

    keys.y = 6;

    danger.setPos(width - danger.width(), 18);

    buffs.setPos(31, 9);

    btnMenu.setPos(width - btnMenu.width(), 1);
  }
    @Override
    protected void layout() {

      icon.x = width - icon.width;

      depth.x = icon.x - 1 - depth.width();
      depth.y = PixelScene.align(y + (height - depth.height()) / 2);

      icon.y = depth.y - 1;

      feature.y = PixelScene.align(depth.y + depth.baseLine() - feature.baseLine());
    }
    private float statSlot(Group parent, String label, String value, float pos) {

      BitmapText txt = PixelScene.createText(label, 7);
      txt.y = pos;
      parent.add(txt);

      txt = PixelScene.createText(value, 7);
      txt.measure();
      txt.x = WIDTH * 0.65f;
      txt.y = pos;
      parent.add(txt);

      return pos + GAP + txt.baseLine();
    }
Exemplo n.º 5
0
  public WndBadge(Badges.Badge badge) {

    super();

    Image icon = BadgeBanner.image(badge.image);
    icon.scale.set(2);
    add(icon);

    BitmapTextMultiline info = PixelScene.createMultiline(badge.description, 8);
    info.maxWidth = WIDTH - MARGIN * 2;
    info.measure();

    float w = Math.max(icon.width(), info.width()) + MARGIN * 2;

    icon.x = (w - icon.width()) / 2;
    icon.y = MARGIN;

    float pos = icon.y + icon.height() + MARGIN;
    for (BitmapText line : info.new LineSplitter().split()) {
      line.measure();
      line.x = PixelScene.align((w - line.width()) / 2);
      line.y = PixelScene.align(pos);
      add(line);

      pos += line.height();
    }

    resize((int) w, (int) (pos + MARGIN));

    BadgeBanner.highlight(icon, badge.image);
  }
    @Override
    protected void layout() {
      super.layout();

      image.x = x + (width - image.width()) / 2;
      image.y = y;

      label.x = x + (width - label.width()) / 2;
      label.y = image.y + image.height() + 2;
    }
Exemplo n.º 7
0
  @Override
  protected void layout() {
    super.layout();

    icon.x = x + (width - icon.width) / 2;
    icon.y = y + (height - icon.height) / 2;

    if (topLeft != null) {
      topLeft.x = x;
      topLeft.y = y;
    }

    if (topRight != null) {
      topRight.x = x + (width - topRight.width());
      topRight.y = y;
    }

    if (bottomRight != null) {
      bottomRight.x = x + (width - bottomRight.width());
      bottomRight.y = y + (height - bottomRight.height());
    }
  }
  @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));
    }
  }
  public WndList(String[] items) {

    super();

    float pos = MARGIN;
    float dotWidth = 0;
    float maxWidth = 0;

    for (int i = 0; i < items.length; i++) {

      if (i > 0) {
        pos += GAP;
      }

      BitmapText dot = PixelScene.createText(DOT, 6);
      dot.x = MARGIN;
      dot.y = pos;
      if (dotWidth == 0) {
        dot.measure();
        dotWidth = dot.width();
      }
      add(dot);

      BitmapTextMultiline item = PixelScene.createMultiline(items[i], 6);
      item.x = dot.x + dotWidth;
      item.y = pos;
      item.maxWidth = (int) (WIDTH - MARGIN * 2 - dotWidth);
      item.measure();
      add(item);

      pos += item.height();
      float w = item.width();
      if (w > maxWidth) {
        maxWidth = w;
      }
    }

    resize((int) (maxWidth + dotWidth + MARGIN * 2), (int) (pos + MARGIN));
  }
    @Override
    protected void layout() {
      bg.x = x;
      bg.y = y;

      slot.setRect(x, y, HEIGHT, HEIGHT);

      name.x = slot.right() + 2;
      name.y = y + (height - name.baseLine()) / 2;

      String str = Utils.capitalize(item.name());
      name.text(str);
      name.measure();
      if (name.width() > width - name.x) {
        do {
          str = str.substring(0, str.length() - 1);
          name.text(str + "...");
          name.measure();
        } while (name.width() > width - name.x);
      }

      super.layout();
    }
  @Override
  public void create() {

    super.create();

    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(ShatteredPixelDungeon.musicVol() / 10f);

    uiCamera.visible = false;

    int w = Camera.main.width;
    int h = Camera.main.height;

    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);

    Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON);
    add(title);

    float height =
        title.height
            + (ShatteredPixelDungeon.landscape() ? DashboardItem.SIZE : DashboardItem.SIZE * 2);

    title.x = (w - title.width()) / 2;
    title.y = (h - height) / 2;

    placeTorch(title.x + 18, title.y + 20);
    placeTorch(title.x + title.width - 18, title.y + 20);

    Image signs =
        new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) {
          private float time = 0;

          @Override
          public void update() {
            super.update();
            am = (float) Math.sin(-(time += Game.elapsed));
          }

          @Override
          public void draw() {
            GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
            super.draw();
            GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
          }
        };
    signs.x = title.x;
    signs.y = title.y;
    add(signs);

    DashboardItem btnBadges =
        new DashboardItem(TXT_BADGES, 3) {
          @Override
          protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(BadgesScene.class);
          }
        };
    add(btnBadges);

    DashboardItem btnAbout =
        new DashboardItem(TXT_ABOUT, 1) {
          @Override
          protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(AboutScene.class);
          }
        };
    add(btnAbout);

    DashboardItem btnPlay =
        new DashboardItem(TXT_PLAY, 0) {
          @Override
          protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(StartScene.class);
          }
        };
    add(btnPlay);

    DashboardItem btnHighscores =
        new DashboardItem(TXT_HIGHSCORES, 2) {
          @Override
          protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(RankingsScene.class);
          }
        };
    add(btnHighscores);

    if (ShatteredPixelDungeon.landscape()) {
      float y = (h + height) / 2 - DashboardItem.SIZE;
      btnHighscores.setPos(w / 2 - btnHighscores.width(), y);
      btnBadges.setPos(w / 2, y);
      btnPlay.setPos(btnHighscores.left() - btnPlay.width(), y);
      btnAbout.setPos(btnBadges.right(), y);
    } else {
      btnBadges.setPos(w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE);
      btnAbout.setPos(w / 2, (h + height) / 2 - DashboardItem.SIZE);
      btnPlay.setPos(w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE);
      btnHighscores.setPos(w / 2, btnPlay.top());
    }

    BitmapText version = new BitmapText("v " + Game.version + "", pixelFont);
    version.measure();
    version.hardlight(0xCCCCCC);
    version.x = w - version.width();
    version.y = h - version.height();
    add(version);

    Button changes = new ChangesButton();
    changes.setPos(w - changes.width(), h - version.height() - changes.height());
    add(changes);

    PrefsButton btnPrefs = new PrefsButton();
    btnPrefs.setPos(0, 0);
    add(btnPrefs);

    ExitButton btnExit = new ExitButton();
    btnExit.setPos(w - btnExit.width(), 0);
    add(btnExit);

    int gameversion = ShatteredPixelDungeon.version();

    if (gameversion != Game.versionCode) {
      if (gameversion < 65) {
        // TODO special code for 0.3.2 update to notify people about mastery book changes. Remove
        // when not needed
        Badges.loadGlobal();

        if (Badges.isUnlocked(Badges.Badge.MASTERY_WARRIOR)
            || Badges.isUnlocked(Badges.Badge.MASTERY_ROGUE)
            || Badges.isUnlocked(Badges.Badge.MASTERY_MAGE)
            || Badges.isUnlocked(Badges.Badge.MASTERY_HUNTRESS)) {
          add(
              new WndHardNotification(
                  new ItemSprite(ItemSpriteSheet.MASTERY, null),
                  "Mastery Book Changes",
                  "v0.3.2 brings new prison content and some big balance changes to subclasses:\n"
                      + "\n"
                      + "_The Book of Mastery is no longer given at floor 1, it is only dropped by Tengu._\n"
                      + "\n"
                      + "There have been balance tweaks to accommodate this, so the difficulty should be similar.\n"
                      + "\n"
                      + "This change is necessary to allow for more interesting subclasses in the future, "
                      + "apologies for any frustration.",
                  "See All Changes",
                  10) {
                @Override
                public void hide() {
                  super.hide();
                  Game.switchScene(WelcomeScene.class);
                }
              });
        } else {
          Game.switchScene(WelcomeScene.class);
          return;
        }
      } else {
        Game.switchScene(WelcomeScene.class);
        return;
      }
    }

    fadeIn();
  }
Exemplo n.º 12
0
  @Override
  public void create() {

    super.create();

    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(1f);

    uiCamera.visible = false;

    int w = Camera.main.width;
    int h = Camera.main.height;

    archs = new Archs();
    archs.setSize(w, h);
    add(archs);

    Rankings.INSTANCE.load();

    BitmapText title = PixelScene.createText(TXT_TITLE, 9);
    title.hardlight(Window.SHPX_COLOR);
    title.measure();
    title.x = align((w - title.width()) / 2);
    title.y = align(GAP);
    add(title);

    if (Rankings.INSTANCE.records.size() > 0) {

      // attempts to give each record as much space as possible, ideally as much space as portrait
      // mode
      float rowHeight =
          GameMath.gate(
              ROW_HEIGHT_MIN,
              (uiCamera.height - 26) / Rankings.INSTANCE.records.size(),
              ROW_HEIGHT_MAX);

      float left = (w - Math.min(MAX_ROW_WIDTH, w)) / 2 + GAP;
      float top = align((h - rowHeight * Rankings.INSTANCE.records.size()) / 2);

      int pos = 0;

      for (Rankings.Record rec : Rankings.INSTANCE.records) {
        Record row = new Record(pos, pos == Rankings.INSTANCE.lastRecord, rec);
        float offset = rowHeight <= 14 ? pos % 2 == 1 ? 5 : -5 : 0;
        row.setRect(left + offset, top + pos * rowHeight, w - left * 2, rowHeight);
        add(row);

        pos++;
      }

      if (Rankings.INSTANCE.totalNumber >= Rankings.TABLE_SIZE) {
        BitmapText label = PixelScene.createText(TXT_TOTAL, 8);
        label.hardlight(0xCCCCCC);
        label.measure();
        add(label);

        BitmapText won = PixelScene.createText(Integer.toString(Rankings.INSTANCE.wonNumber), 8);
        won.hardlight(Window.SHPX_COLOR);
        won.measure();
        add(won);

        BitmapText total = PixelScene.createText("/" + Rankings.INSTANCE.totalNumber, 8);
        total.hardlight(0xCCCCCC);
        total.measure();
        total.x = align((w - total.width()) / 2);
        total.y = align(top + pos * rowHeight + GAP);
        add(total);

        float tw = label.width() + won.width() + total.width();
        label.x = align((w - tw) / 2);
        won.x = label.x + label.width();
        total.x = won.x + won.width();
        label.y = won.y = total.y = align(h - label.height() - GAP);
      }

    } else {

      BitmapText noRec = PixelScene.createText(TXT_NO_GAMES, 8);
      noRec.hardlight(0xCCCCCC);
      noRec.measure();
      noRec.x = align((w - noRec.width()) / 2);
      noRec.y = align((h - noRec.height()) / 2);
      add(noRec);
    }

    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);

    fadeIn();
  }