コード例 #1
0
  @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);
  }
コード例 #2
0
ファイル: ItemSlot.java プロジェクト: QuattroX/pixel-dungeon
  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();
    }
  }
コード例 #3
0
    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);
      }
    }
コード例 #4
0
  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());
  }
コード例 #5
0
ファイル: RankingsScene.java プロジェクト: royleon4/PD-ice
    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));
    }
コード例 #6
0
  @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();
  }
コード例 #7
0
ファイル: RankingsScene.java プロジェクト: royleon4/PD-ice
  @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();
  }