コード例 #1
0
  @Override
  public void destroy() {
    Badges.saveGlobal();

    Camera.remove(viewport);
    super.destroy();
  }
コード例 #2
0
  @Override
  public void die(Object cause) {
    Dungeon.level.drop(new MysteryMeat(), pos).sprite.drop();
    super.die(cause);

    Statistics.piranhasKilled++;
    Badges.validatePiranhasKilled();
  }
コード例 #3
0
    public boolean checkOwner(Char owner) {
      if (!owner.isAlive() && owner instanceof Hero) {

        Dungeon.fail(Utils.format(ResultDescriptions.GLYPH, name()));
        GLog.n("%s killed you...", name());

        Badges.validateDeathFromGlyph();
        return true;

      } else {
        return false;
      }
    }
コード例 #4
0
  public int proc(Char attacker, Char defender, int damage) {

    if (glyph != null) {
      damage = glyph.proc(this, attacker, defender, damage);
    }

    if (!levelKnown) {
      if (--hitsToKnow <= 0) {
        levelKnown = true;
        GLog.w(TXT_IDENTIFY, name(), toString());
        Badges.validateItemLevelAquired(this);
      }
    }

    return damage;
  }
コード例 #5
0
  @Override
  public void create() {

    super.create();

    Music.INSTANCE.play(Assets.HAPPY, 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.reversed = true;
    archs.setSize(w, h);
    add(archs);

    float vx = align((w - SKY_WIDTH) / 2);
    float vy = align((h - SKY_HEIGHT - BUTTON_HEIGHT) / 2);

    Point s = Camera.main.cameraToScreen(vx, vy);
    viewport = new Camera(s.x, s.y, SKY_WIDTH, SKY_HEIGHT, defaultZoom);
    Camera.add(viewport);

    Group window = new Group();
    window.camera = viewport;
    add(window);

    boolean dayTime = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7;

    Sky sky = new Sky(dayTime);
    sky.scale.set(SKY_WIDTH, SKY_HEIGHT);
    window.add(sky);

    if (!dayTime) {
      for (int i = 0; i < NSTARS; i++) {
        float size = Random.Float();
        ColorBlock star = new ColorBlock(size, size, 0xFFFFFFFF);
        star.x = Random.Float(SKY_WIDTH) - size / 2;
        star.y = Random.Float(SKY_HEIGHT) - size / 2;
        star.am = size * (1 - star.y / SKY_HEIGHT);
        window.add(star);
      }
    }

    float range = SKY_HEIGHT * 2 / 3;
    for (int i = 0; i < NCLOUDS; i++) {
      Cloud cloud =
          new Cloud((NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float(range / NCLOUDS), dayTime);
      window.add(cloud);
    }

    int nPatches = (int) (sky.width() / GrassPatch.WIDTH + 1);

    for (int i = 0; i < nPatches * 4; i++) {
      GrassPatch patch =
          new GrassPatch((i - 0.75f) * GrassPatch.WIDTH / 4, SKY_HEIGHT + 1, dayTime);
      patch.brightness(dayTime ? 0.7f : 0.4f);
      window.add(patch);
    }

    Avatar a = new Avatar(Dungeon.hero.heroClass);
    // Removing semitransparent contour
    a.am = 2;
    a.aa = -1;
    a.x = PixelScene.align((SKY_WIDTH - a.width) / 2);
    a.y = SKY_HEIGHT - a.height;
    window.add(a);

    final Pet pet = new Pet();
    pet.rm = pet.gm = pet.bm = 1.2f;
    pet.x = SKY_WIDTH / 2 + 2;
    pet.y = SKY_HEIGHT - pet.height;
    window.add(pet);

    window.add(
        new TouchArea(sky) {
          protected void onClick(Touch touch) {
            pet.jump();
          };
        });

    for (int i = 0; i < nPatches; i++) {
      GrassPatch patch = new GrassPatch((i - 0.5f) * GrassPatch.WIDTH, SKY_HEIGHT, dayTime);
      patch.brightness(dayTime ? 1.0f : 0.8f);
      window.add(patch);
    }

    Image frame = new Image(Assets.SURFACE);

    frame.frame(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
    frame.x = vx - FRAME_MARGIN_X;
    frame.y = vy - FRAME_MARGIN_TOP;
    add(frame);

    if (dayTime) {
      a.brightness(1.2f);
      pet.brightness(1.2f);
    } else {
      frame.hardlight(0xDDEEFF);
    }

    RedButton gameOver =
        new RedButton("Game Over") {
          protected void onClick() {
            Game.switchScene(TitleScene.class);
          }
        };
    gameOver.setSize(SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT);
    gameOver.setPos(frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4);
    add(gameOver);

    Badges.validateHappyEnd();

    fadeIn();
  }
コード例 #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();
  }