Search in sources :

Example 1 with Spell

use of com.nyrds.pixeldungeon.mechanics.spells.Spell in project pixel-dungeon-remix by NYRDS.

the class WndHeroSpells method addSpell.

private float addSpell(String spellName, final Hero hero, float yPos, int i) {
    final Spell spell = SpellFactory.getSpellByName(spellName);
    if (spell == null || spell.level() > hero.magicLvl()) {
        return yPos;
    }
    int xPos = 0;
    if (i % 2 == 0) {
        xPos = width - 48 - MARGIN * 2;
    }
    Text txtName;
    txtName = PixelScene.createText(spell.name(), GuiProperties.titleFontSize());
    txtName.measure();
    txtName.x = xPos;
    txtName.y = yPos;
    add(txtName);
    Image icon = spell.image();
    icon.frame(spell.film.get(spell.imageIndex));
    icon.y = txtName.bottom();
    icon.x = xPos;
    add(icon);
    SimpleButton btnCast = new SimpleButton(Icons.get(Icons.BTN_TARGET)) {

        protected void onClick() {
            hide();
            spell.cast(hero);
        }
    };
    btnCast.setRect(icon.x + icon.width() + MARGIN, icon.y, 16, 15);
    add(btnCast);
    SimpleButton btnInfo = new SimpleButton(Icons.get(Icons.BTN_QUESTION)) {

        protected void onClick() {
            hide();
            GameScene.show(new WndSpellInfo(hero, spell));
        }
    };
    btnInfo.setRect(icon.x + icon.width() + MARGIN, btnCast.bottom() + MARGIN, 16, 15);
    add(btnInfo);
    Text txtCost;
    txtCost = PixelScene.createText(Game.getVar(R.string.Mana_Cost) + spell.spellCost(), GuiProperties.titleFontSize());
    txtCost.measure();
    txtCost.x = xPos;
    txtCost.y = icon.bottom();
    add(txtCost);
    if (xPos == 0) {
        return yPos;
    }
    return txtCost.bottom() + MARGIN;
}
Also used : SimpleButton(com.watabou.pixeldungeon.ui.SimpleButton) Text(com.watabou.noosa.Text) Image(com.watabou.noosa.Image) Spell(com.nyrds.pixeldungeon.mechanics.spells.Spell)

Aggregations

Spell (com.nyrds.pixeldungeon.mechanics.spells.Spell)1 Image (com.watabou.noosa.Image)1 Text (com.watabou.noosa.Text)1 SimpleButton (com.watabou.pixeldungeon.ui.SimpleButton)1