use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.
the class BadgesScene method create.
@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 archs = new Archs();
archs.setSize(w, h);
add(archs);
int pw = (int) Math.min(w, (PixelDungeon.landscape() ? MIN_WIDTH_L : MIN_WIDTH_P) * 3) - 16;
int ph = (int) Math.min(h, (PixelDungeon.landscape() ? MIN_HEIGHT_L : MIN_HEIGHT_P) * 3) - 32;
float size = (float) Math.sqrt(pw * ph / 27f);
int nCols = (int) Math.ceil(pw / size);
int nRows = (int) Math.ceil(ph / size);
size = Math.min(pw / nCols, ph / nRows);
float left = (w - size * nCols) / 2;
float top = (h - size * nRows) / 2;
BitmapText title = PixelScene.createText(TXT_TITLE, 9);
title.hardlight(Window.TITLE_COLOR);
title.measure();
title.x = align((w - title.width()) / 2);
title.y = align((top - title.baseLine()) / 2);
add(title);
Badges.loadGlobal();
List<Badges.Badge> badges = Badges.filtered(true);
for (int i = 0; i < nRows; i++) {
for (int j = 0; j < nCols; j++) {
int index = i * nCols + j;
Badges.Badge b = index < badges.size() ? badges.get(index) : null;
BadgeButton button = new BadgeButton(b);
button.setPos(left + j * size + (size - button.width()) / 2, top + i * size + (size - button.height()) / 2);
add(button);
}
}
ExitButton btnExit = new ExitButton();
btnExit.setPos(Camera.main.width - btnExit.width(), 0);
add(btnExit);
fadeIn();
Badges.loadingListener = new Callback() {
@Override
public void call() {
if (Game.scene() == BadgesScene.this) {
PixelDungeon.switchNoFade(BadgesScene.class);
}
}
};
}
use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.
the class StartScene method create.
@Override
public void create() {
super.create();
Badges.loadGlobal();
uiCamera.visible = false;
int w = Camera.main.width;
int h = Camera.main.height;
float width, height;
if (PixelDungeon.landscape()) {
width = WIDTH_L;
height = HEIGHT_L;
} else {
width = WIDTH_P;
height = HEIGHT_P;
}
float left = (w - width) / 2;
float top = (h - height) / 2;
float bottom = h - top;
Archs archs = new Archs();
archs.setSize(w, h);
add(archs);
Image title = BannerSprites.get(Type.SELECT_YOUR_HERO);
title.x = align((w - title.width()) / 2);
title.y = align(top);
add(title);
buttonX = left;
buttonY = bottom - BUTTON_HEIGHT;
btnNewGame = new GameButton(TXT_NEW) {
@Override
protected void onClick() {
if (GamesInProgress.check(curClass) != null) {
StartScene.this.add(new WndOptions(TXT_REALLY, TXT_WARNING, TXT_YES, TXT_NO) {
@Override
protected void onSelect(int index) {
if (index == 0) {
startNewGame();
}
}
});
} else {
startNewGame();
}
}
};
add(btnNewGame);
btnLoad = new GameButton(TXT_LOAD) {
@Override
protected void onClick() {
InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
Game.switchScene(InterlevelScene.class);
}
};
add(btnLoad);
float centralHeight = buttonY - title.y - title.height();
HeroClass[] classes = { HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS };
for (HeroClass cl : classes) {
ClassShield shield = new ClassShield(cl);
shields.put(cl, shield);
add(shield);
}
if (PixelDungeon.landscape()) {
float shieldW = width / 4;
float shieldH = Math.min(centralHeight, shieldW);
top = title.y + title.height + (centralHeight - shieldH) / 2;
for (int i = 0; i < classes.length; i++) {
ClassShield shield = shields.get(classes[i]);
shield.setRect(left + i * shieldW, top, shieldW, shieldH);
}
ChallengeButton challenge = new ChallengeButton();
challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
add(challenge);
} else {
float shieldW = width / 2;
float shieldH = Math.min(centralHeight / 2, shieldW * 1.2f);
top = title.y + title.height() + centralHeight / 2 - shieldH;
for (int i = 0; i < classes.length; i++) {
ClassShield shield = shields.get(classes[i]);
shield.setRect(left + (i % 2) * shieldW, top + (i / 2) * shieldH, shieldW, shieldH);
}
ChallengeButton challenge = new ChallengeButton();
challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
add(challenge);
}
unlock = new Group();
add(unlock);
if (!(huntressUnlocked = Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_3))) {
BitmapTextMultiline text = PixelScene.createMultiline(TXT_UNLOCK, 9);
text.maxWidth = (int) width;
text.measure();
float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.height()) / 2;
for (BitmapText line : text.new LineSplitter().split()) {
line.measure();
line.hardlight(0xFFFF00);
line.x = PixelScene.align(w / 2 - line.width() / 2);
line.y = PixelScene.align(pos);
unlock.add(line);
pos += line.height();
}
}
ExitButton btnExit = new ExitButton();
btnExit.setPos(Camera.main.width - btnExit.width(), 0);
add(btnExit);
curClass = null;
updateClass(HeroClass.values()[PixelDungeon.lastClass()]);
fadeIn();
Badges.loadingListener = new Callback() {
@Override
public void call() {
if (Game.scene() == StartScene.this) {
PixelDungeon.switchNoFade(StartScene.class);
}
}
};
}
use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.
the class RankingsScene method create.
@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();
if (Rankings.INSTANCE.records.size() > 0) {
float rowHeight = PixelDungeon.landscape() ? ROW_HEIGHT_L : ROW_HEIGHT_P;
float left = (w - Math.min(MAX_ROW_WIDTH, w)) / 2 + GAP;
float top = align((h - rowHeight * Rankings.INSTANCE.records.size()) / 2);
BitmapText title = PixelScene.createText(TXT_TITLE, 9);
title.hardlight(Window.TITLE_COLOR);
title.measure();
title.x = align((w - title.width()) / 2);
title.y = align(top - title.height() - GAP);
add(title);
int pos = 0;
for (Rankings.Record rec : Rankings.INSTANCE.records) {
Record row = new Record(pos, pos == Rankings.INSTANCE.lastRecord, rec);
row.setRect(left, 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(DEFAULT_COLOR);
label.measure();
add(label);
BitmapText won = PixelScene.createText(Integer.toString(Rankings.INSTANCE.wonNumber), 8);
won.hardlight(Window.TITLE_COLOR);
won.measure();
add(won);
BitmapText total = PixelScene.createText("/" + Rankings.INSTANCE.totalNumber, 8);
total.hardlight(DEFAULT_COLOR);
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(top + pos * rowHeight + GAP);
}
} else {
BitmapText title = PixelScene.createText(TXT_NO_GAMES, 8);
title.hardlight(DEFAULT_COLOR);
title.measure();
title.x = align((w - title.width()) / 2);
title.y = align((h - title.height()) / 2);
add(title);
}
ExitButton btnExit = new ExitButton();
btnExit.setPos(Camera.main.width - btnExit.width(), 0);
add(btnExit);
fadeIn();
}
use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.
the class SurfaceScene method create.
@Override
public void create() {
super.create();
Music.INSTANCE.play(Assets.HAPPY, true);
Music.INSTANCE.volume(1f);
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 = !Dungeon.nightMode;
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);
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();
}
use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.
the class TitleScene method create.
@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 archs = new Archs();
archs.setSize(w, h);
add(archs);
Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON);
add(title);
float height = title.height + (PixelDungeon.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() {
PixelDungeon.switchNoFade(BadgesScene.class);
}
};
add(btnBadges);
DashboardItem btnAbout = new DashboardItem(TXT_ABOUT, 1) {
@Override
protected void onClick() {
PixelDungeon.switchNoFade(AboutScene.class);
}
};
add(btnAbout);
DashboardItem btnPlay = new DashboardItem(TXT_PLAY, 0) {
@Override
protected void onClick() {
PixelDungeon.switchNoFade(StartScene.class);
}
};
add(btnPlay);
DashboardItem btnHighscores = new DashboardItem(TXT_HIGHSCORES, 2) {
@Override
protected void onClick() {
PixelDungeon.switchNoFade(RankingsScene.class);
}
};
add(btnHighscores);
if (PixelDungeon.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, font1x);
version.measure();
version.hardlight(0x888888);
version.x = w - version.width();
version.y = h - version.height();
add(version);
PrefsButton btnPrefs = new PrefsButton();
btnPrefs.setPos(0, 0);
add(btnPrefs);
ExitButton btnExit = new ExitButton();
btnExit.setPos(w - btnExit.width(), 0);
add(btnExit);
fadeIn();
}
Aggregations