Ejemplo n.º 1
0
    @Override
    protected void createChildren() {

      super.createChildren();

      shield = new ItemSprite(ItemSpriteSheet.TOMB, null);
      add(shield);

      position = new BitmapText(PixelScene.font1x);
      position.alpha(0.8f);
      add(position);

      desc = createMultiline(7);
      add(desc);

      depth = new BitmapText(PixelScene.font1x);
      depth.alpha(0.8f);

      steps = new Image();

      classIcon = new Image();
      add(classIcon);

      level = new BitmapText(PixelScene.font1x);
      level.alpha(0.8f);
    }
  @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 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);
  }
Ejemplo n.º 4
0
  public void enable(boolean value) {

    active = value;

    float alpha = value ? ENABLED : DISABLED;
    icon.alpha(alpha);
    topLeft.alpha(alpha);
    topRight.alpha(alpha);
    bottomRight.alpha(alpha);
  }
    @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;
    }
  @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));
    }
  }
Ejemplo n.º 7
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);
  }
  public WndJournal() {

    super();
    resize(WIDTH, ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P);

    txtTitle = PixelScene.createText(TXT_TITLE, 9);
    txtTitle.hardlight(Window.TITLE_COLOR);
    txtTitle.measure();
    txtTitle.x = PixelScene.align(PixelScene.uiCamera, (WIDTH - txtTitle.width()) / 2);
    add(txtTitle);

    Component content = new Component();

    Collections.sort(Journal.records);

    float pos = 0;
    for (Journal.Record rec : Journal.records) {
      ListItem item = new ListItem(rec.feature, rec.depth);
      item.setRect(0, pos, WIDTH, ITEM_HEIGHT);
      content.add(item);

      pos += item.height();
    }

    content.setSize(WIDTH, pos);

    list = new ScrollPane(content);
    add(list);

    list.setRect(0, txtTitle.height(), WIDTH, height - txtTitle.height());
  }
Ejemplo n.º 9
0
  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() {

      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());
    }
Ejemplo n.º 11
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
    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();
    }
    public ListItem(Journal.Feature f, int d) {
      super();

      feature.text(f.desc);
      feature.measure();

      depth.text(Integer.toString(d));
      depth.measure();

      if (d == Dungeon.depth) {
        feature.hardlight(TITLE_COLOR);
        depth.hardlight(TITLE_COLOR);
      }
    }
    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();
    }
Ejemplo n.º 15
0
    public Record(int pos, boolean latest, Rankings.Record rec) {
      super();

      this.rec = rec;

      if (latest) {
        flare = new Flare(6, 24);
        flare.angularSpeed = 90;
        flare.color(rec.win ? FLARE_WIN : FLARE_LOSE);
        addToBack(flare);
      }

      if (pos != Rankings.TABLE_SIZE - 1) {
        position.text(Integer.toString(pos + 1));
      } else position.text(" ");
      position.measure();

      desc.text(rec.info);

      desc.measure();

      int odd = pos % 2;

      if (rec.win) {
        shield.view(ItemSpriteSheet.AMULET, null);
        position.hardlight(TEXT_WIN[odd]);
        desc.hardlight(TEXT_WIN[odd]);
        depth.hardlight(TEXT_WIN[odd]);
        level.hardlight(TEXT_WIN[odd]);
      } else {
        position.hardlight(TEXT_LOSE[odd]);
        desc.hardlight(TEXT_LOSE[odd]);
        depth.hardlight(TEXT_LOSE[odd]);
        level.hardlight(TEXT_LOSE[odd]);

        if (rec.depth != 0) {
          depth.text(Integer.toString(rec.depth));
          depth.measure();
          steps.copy(Icons.DEPTH_LG.get());

          add(steps);
          add(depth);
        }
      }

      if (rec.herolevel != 0) {
        level.text(Integer.toString(rec.herolevel));
        level.measure();
        add(level);
      }

      classIcon.copy(Icons.get(rec.heroClass));
    }
  @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();
  }
Ejemplo n.º 17
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();
  }
Ejemplo n.º 18
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);
    }
Ejemplo n.º 19
0
  public void item(Item item) {
    if (item == null) {

      active = false;
      icon.visible = topLeft.visible = topRight.visible = bottomRight.visible = false;

    } else {

      active = true;
      icon.visible = topLeft.visible = topRight.visible = bottomRight.visible = true;

      icon.view(item.image(), item.glowing());

      topLeft.text(item.status());

      boolean isArmor = item instanceof Armor;
      boolean isWeapon = item instanceof Weapon;
      if (isArmor || isWeapon) {

        if (item.levelKnown || (isWeapon && !(item instanceof MeleeWeapon))) {

          int str = isArmor ? ((Armor) item).STR : ((Weapon) item).STR;
          topRight.text(Utils.format(TXT_STRENGTH, str));
          if (str > Dungeon.hero.STR()) {
            topRight.hardlight(DEGRADED);
          } else {
            topRight.resetColor();
          }

        } else {

          topRight.text(
              Utils.format(
                  TXT_TYPICAL_STR,
                  isArmor ? ((Armor) item).typicalSTR() : ((MeleeWeapon) item).typicalSTR()));
          topRight.hardlight(WARNING);
        }
        topRight.measure();

      } else {

        topRight.text(null);
      }

      int level = item.visiblyUpgraded();
      if (level != 0 || (item.cursed && item.cursedKnown)) {
        bottomRight.text(item.levelKnown ? Utils.format(TXT_LEVEL, level) : TXT_CURSED);
        bottomRight.measure();
        bottomRight.hardlight(level > 0 ? UPGRADED : DEGRADED);
      } else {
        bottomRight.text(null);
      }

      layout();
    }
  }