@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); }
public WndRanking(final String gameFile) { super(); resize(WIDTH, HEIGHT); thread = new Thread() { @Override public void run() { try { Badges.loadGlobal(); Dungeon.loadGame(gameFile); } catch (Exception e) { error = TXT_ERROR; } } }; thread.start(); busy = Icons.BUSY.get(); busy.origin.set(busy.width / 2, busy.height / 2); busy.angularSpeed = 720; busy.x = (WIDTH - busy.width) / 2; busy.y = (HEIGHT - busy.height) / 2; add(busy); }
@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() { super.layout(); image.x = x + 2; image.y = y + 2; }
@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; }
public static Image avatar(HeroClass cl, int armorTier) { RectF patch = tiers().get(armorTier); Image avatar = new Image(cl.spritesheet()); RectF frame = avatar.texture.uvRect(1, 0, FRAME_WIDTH, FRAME_HEIGHT); frame = frame.offset(patch.left, patch.top); avatar.frame(frame); return avatar; }
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 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()); }
@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)); } }
@Override public void update() { super.update(); if (target != null && target.isAlive() && target.sprite.visible) { CharSprite sprite = target.sprite; bg.scale.x = sprite.width; level.scale.x = sprite.width * target.HP / target.HT; bg.x = level.x = sprite.x; bg.y = level.y = sprite.y - HEIGHT - 1; visible = true; } else { visible = false; } }
@Override public void create() { super.create(); BitmapTextMultiline text = createMultiline(TXT, 8); text.maxWidth = Math.min(Camera.main.width, 120); text.measure(); add(text); text.x = align((Camera.main.width - text.width()) / 2); text.y = align((Camera.main.height - text.height()) / 2); BitmapTextMultiline link = createMultiline(LNK, 8); link.maxWidth = Math.min(Camera.main.width, 120); link.measure(); link.hardlight(Window.TITLE_COLOR); add(link); link.x = text.x; link.y = text.y + text.height(); TouchArea hotArea = new TouchArea(link) { @Override protected void onClick(NoosaInputProcessor.Touch touch) { Gdx.net.openURI("http://" + LNK); } }; add(hotArea); Image wata = Icons.WATA.get(); wata.x = align(text.x + (text.width() - wata.width) / 2); wata.y = text.y - wata.height - 8; add(wata); new Flare(7, 64).color(0x112233, true).show(wata, 0).angularSpeed = +20; Archs archs = new Archs(); archs.setSize(Camera.main.width, Camera.main.height); addToBack(archs); ExitButton btnExit = new ExitButton(); btnExit.setPos(Camera.main.width - btnExit.width(), 0); add(btnExit); fadeIn(); }
@Override public void update() { super.update(); if (speed.x > 0 && x > SKY_WIDTH) { x = -width(); } else if (speed.x < 0 && x < -width()) { x = SKY_WIDTH; } }
public static Image get(Type type) { Image icon = new Image(Assets.getBanners()); switch (type) { case PIXEL_DUNGEON: icon.frame(icon.texture.uvRect(0, 0, 128, 70)); break; case BOSS_SLAIN: icon.frame(icon.texture.uvRect(0, 70, 128, 105)); break; case GAME_OVER: icon.frame(icon.texture.uvRect(0, 105, 128, 140)); break; case SELECT_YOUR_HERO: icon.frame(icon.texture.uvRect(0, 140, 128, 161)); break; } return icon; }
public static Image get(Type type) { Image icon = new Image(Assets.EFFECTS); switch (type) { case RIPPLE: icon.frame(icon.texture.uvRect(0, 0, 16, 16)); break; case LIGHTNING: icon.frame(icon.texture.uvRect(16, 0, 32, 8)); break; case WOUND: icon.frame(icon.texture.uvRect(16, 8, 32, 16)); break; case RAY: icon.frame(icon.texture.uvRect(16, 16, 32, 24)); break; } return icon; }
public DashboardItem(String text, int index) { super(); image.frame( image.texture.uvRect(index * IMAGE_SIZE, 0, (index + 1) * IMAGE_SIZE, IMAGE_SIZE)); this.label.text(text); this.label.measure(); setSize(SIZE, SIZE); }
@Override public void update() { super.update(); a += Random.Float(Game.elapsed * 5); angle = (2 + Math.cos(a)) * (forward ? +0.2 : -0.2); scale.y = (float) Math.cos(angle); x = tx + (float) Math.tan(angle) * width; y = ty - scale.y * height; }
@Override public void update() { super.update(); if ((time -= Game.elapsed) <= 0) { kill(); } else { float p = time / TIME_TO_FADE; alpha(p); scale.y = 1 + p / 2; } }
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 WndBadge(Badges.Badge badge) { super(); Image icon = BadgeBanner.image(badge.image); icon.scale.set(2); add(icon); // TODO: this used to be centered, should probably figure that out. RenderedTextMultiline info = PixelScene.renderMultiline(badge.desc(), 8); info.maxWidth(WIDTH - MARGIN * 2); PixelScene.align(info); add(info); float w = Math.max(icon.width(), info.width()) + MARGIN * 2; icon.x = (w - icon.width()) / 2f; icon.y = MARGIN; PixelScene.align(icon); info.setPos((w - info.width()) / 2, icon.y + icon.height() + MARGIN); resize((int) w, (int) (info.bottom() + MARGIN)); BadgeBanner.highlight(icon, badge.image); }
public WndInfoBuff(Buff buff) { super(); IconTitle titlebar = new IconTitle(); icons = TextureCache.get(Assets.BUFFS_LARGE); film = new TextureFilm(icons, 16, 16); Image buffIcon = new Image(icons); buffIcon.frame(film.get(buff.icon())); titlebar.icon(buffIcon); titlebar.label(Messages.titleCase(buff.toString()), Window.TITLE_COLOR); titlebar.setRect(0, 0, WIDTH, 0); add(titlebar); RenderedTextMultiline txtInfo = PixelScene.renderMultiline(buff.desc(), 6); txtInfo.maxWidth(WIDTH); txtInfo.setPos(titlebar.left(), titlebar.bottom() + GAP); add(txtInfo); resize(WIDTH, (int) (txtInfo.top() + txtInfo.height())); }
@Override protected void layout() { clear(); SparseArray<Image> newIcons = new SparseArray<Image>(); for (Buff buff : ch.buffs()) { int icon = buff.icon(); if (icon != NONE) { Image img = new Image(texture); img.frame(film.get(icon)); img.x = x + members.size() * (SIZE + 2); img.y = y; add(img); newIcons.put(icon, img); } } for (Integer key : icons.keyArray()) { if (newIcons.get(key) == null) { Image icon = icons.get(key); icon.origin.set(SIZE / 2); add(icon); add( new AlphaTweener(icon, 0, 0.6f) { @Override protected void updateValues(float progress) { super.updateValues(progress); image.scale.set(1 + 5 * progress); }; }); } } icons = newIcons; }
@Override public void create() { super.create(); BitmapTextMultiline text = null; if (!noText) { text = createMultiline(TXT, 8); text.maxWidth = WIDTH; text.measure(); add(text); } amulet = new Image(Assets.AMULET); add(amulet); RedButton btnExit = new RedButton(TXT_EXIT) { @Override protected void onClick() { Dungeon.win(ResultDescriptions.WIN); Dungeon.deleteGame(Dungeon.hero.heroClass, true); Game.switchScene(noText ? TitleScene.class : RankingsScene.class); } }; btnExit.setSize(WIDTH, BTN_HEIGHT); add(btnExit); RedButton btnStay = new RedButton(TXT_STAY) { @Override protected void onClick() { onBackPressed(); } }; btnStay.setSize(WIDTH, BTN_HEIGHT); add(btnStay); float height; if (noText) { height = amulet.height + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align((Camera.main.width - amulet.width) / 2); amulet.y = align((Camera.main.height - height) / 2); btnExit.setPos( (Camera.main.width - btnExit.width()) / 2, amulet.y + amulet.height + LARGE_GAP); btnStay.setPos(btnExit.left(), btnExit.bottom() + SMALL_GAP); } else { height = amulet.height + LARGE_GAP + text.height() + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align((Camera.main.width - amulet.width) / 2); amulet.y = align((Camera.main.height - height) / 2); text.x = align((Camera.main.width - text.width()) / 2); text.y = amulet.y + amulet.height + LARGE_GAP; btnExit.setPos((Camera.main.width - btnExit.width()) / 2, text.y + text.height() + LARGE_GAP); btnStay.setPos(btnExit.left(), btnExit.bottom() + SMALL_GAP); } new Flare(8, 48).color(0xFFDDBB, true).show(amulet, 0).angularSpeed = +30; fadeIn(); }
@Override protected void layout() { image.x = x; image.y = y; }
@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(); }
@Override protected void updateMatrix() { super.updateMatrix(); Matrix.skewX(matrix, (float) (angle / Matrix.G2RAD)); }
@Override protected void onTouchDown() { image.brightness(1.5f); Sample.INSTANCE.play(Assets.SND_CLICK); }
@Override protected void onTouchUp() { image.resetColor(); }
@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(); }