v3.0.0: implemented a basic early window for cleric spell selection
This commit is contained in:
+8
@@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HolyTome;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
import com.watabou.utils.Callback;
|
import com.watabou.utils.Callback;
|
||||||
@@ -37,6 +38,13 @@ import com.watabou.utils.Random;
|
|||||||
|
|
||||||
public class GuidingLight extends ClericSpell {
|
public class GuidingLight extends ClericSpell {
|
||||||
|
|
||||||
|
public static GuidingLight INSTANCE = new GuidingLight();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int icon() {
|
||||||
|
return HeroIcon.ELEMENTAL_BLAST; //TODO unique icon
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String targetingPrompt() {
|
public String targetingPrompt() {
|
||||||
return Messages.get(this, "prompt");
|
return Messages.get(this, "prompt");
|
||||||
|
|||||||
+8
-5
@@ -24,13 +24,15 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.spells.GuidingLight;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.spells.ClericSpell;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEnergy;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEnergy;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndClericSpells;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -74,21 +76,22 @@ public class HolyTome extends Artifact {
|
|||||||
if (hero.buff(MagicImmune.class) != null) return;
|
if (hero.buff(MagicImmune.class) != null) return;
|
||||||
|
|
||||||
if (action.equals(AC_CAST)) {
|
if (action.equals(AC_CAST)) {
|
||||||
usesTargeting = false;
|
|
||||||
|
|
||||||
if (!isEquipped(hero)) GLog.i(Messages.get(Artifact.class, "need_to_equip"));
|
if (!isEquipped(hero)) GLog.i(Messages.get(Artifact.class, "need_to_equip"));
|
||||||
else if (charge == 0) GLog.i(Messages.get(this, "no_charge"));
|
else if (charge == 0) GLog.i(Messages.get(this, "no_charge"));
|
||||||
else {
|
else {
|
||||||
|
|
||||||
//TODO need to flow into spell selection and not just auto-cast guiding light
|
GameScene.show(new WndClericSpells(this, hero, false));
|
||||||
usesTargeting = true;
|
|
||||||
new GuidingLight().use(this, hero);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canCast( Hero hero, ClericSpell spell ){
|
||||||
|
return (charge >= spell.chargeUse(hero));
|
||||||
|
}
|
||||||
|
|
||||||
public void spendCharge( float chargesSpent ){
|
public void spendCharge( float chargesSpent ){
|
||||||
partialCharge -= chargesSpent;
|
partialCharge -= chargesSpent;
|
||||||
while (partialCharge < 0){
|
while (partialCharge < 0){
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.ArmorAbility;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.ArmorAbility;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.spells.ClericSpell;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
import com.watabou.noosa.TextureFilm;
|
import com.watabou.noosa.TextureFilm;
|
||||||
|
|
||||||
@@ -75,6 +76,9 @@ public class HeroIcon extends Image {
|
|||||||
public static final int WEAPON_SWAP = 37;
|
public static final int WEAPON_SWAP = 37;
|
||||||
public static final int MONK_ABILITIES = 38;
|
public static final int MONK_ABILITIES = 38;
|
||||||
|
|
||||||
|
//cleric spells
|
||||||
|
|
||||||
|
|
||||||
public HeroIcon(HeroSubClass subCls){
|
public HeroIcon(HeroSubClass subCls){
|
||||||
super( Assets.Interfaces.HERO_ICONS );
|
super( Assets.Interfaces.HERO_ICONS );
|
||||||
if (film == null){
|
if (film == null){
|
||||||
@@ -99,4 +103,12 @@ public class HeroIcon extends Image {
|
|||||||
frame(film.get(action.actionIcon()));
|
frame(film.get(action.actionIcon()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HeroIcon(ClericSpell spell){
|
||||||
|
super( Assets.Interfaces.HERO_ICONS );
|
||||||
|
if (film == null){
|
||||||
|
film = new TextureFilm(texture, SIZE, SIZE);
|
||||||
|
}
|
||||||
|
frame(film.get(spell.icon()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Pixel Dungeon
|
||||||
|
* Copyright (C) 2012-2015 Oleg Dolya
|
||||||
|
*
|
||||||
|
* Shattered Pixel Dungeon
|
||||||
|
* Copyright (C) 2014-2024 Evan Debenham
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.spells.ClericSpell;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.spells.GuidingLight;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HolyTome;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.IconButton;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class WndClericSpells extends Window {
|
||||||
|
|
||||||
|
protected static final int WIDTH = 120;
|
||||||
|
|
||||||
|
public WndClericSpells(HolyTome tome, Hero cleric, boolean info){
|
||||||
|
|
||||||
|
IconTitle title = new IconTitle(new ItemSprite(tome), info ? "Spell Info" : "Cast A Spell");
|
||||||
|
|
||||||
|
title.setRect(0, 0, WIDTH, 0);
|
||||||
|
add(title);
|
||||||
|
|
||||||
|
IconButton btnInfo = new IconButton(Icons.INFO.get()){
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
GameScene.show(new WndClericSpells(tome, cleric, !info));
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnInfo.setRect(WIDTH-16, 0, 16, 16);
|
||||||
|
add(btnInfo);
|
||||||
|
|
||||||
|
//TODO we might want to intercept quickslot hotkeys and auto-cast the last spell if relevant
|
||||||
|
RenderedTextBlock msg = PixelScene.renderTextBlock( info ? "Select a spell to learn about it, or press the info button to switch to cast mode." : "Select a spell to cast it, or press the info button to switch to info mode.", 6);
|
||||||
|
msg.maxWidth(WIDTH);
|
||||||
|
msg.setPos(0, title.bottom()+4);
|
||||||
|
add(msg);
|
||||||
|
|
||||||
|
//TODO build spell list
|
||||||
|
ArrayList<ClericSpell> spells = new ArrayList<>();
|
||||||
|
spells.add(GuidingLight.INSTANCE);
|
||||||
|
|
||||||
|
ArrayList<IconButton> spellBtns = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ClericSpell spell : spells){
|
||||||
|
IconButton spellBtn = new IconButton(new HeroIcon(spell)){
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
if (info){
|
||||||
|
ShatteredPixelDungeon.scene().addToFront(new WndTitledMessage(new HeroIcon(spell), spell.name(), spell.desc()));
|
||||||
|
} else {
|
||||||
|
hide();
|
||||||
|
spell.use(tome, cleric);
|
||||||
|
|
||||||
|
//TODO, probably need targeting logic here
|
||||||
|
if (spell.useTargeting() && Dungeon.quickslot.contains(tome)){
|
||||||
|
QuickSlotButton.useTargeting(Dungeon.quickslot.getSlot(tome));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!info && !tome.canCast(cleric, spell)){
|
||||||
|
spellBtn.enable(false);
|
||||||
|
}
|
||||||
|
add(spellBtn);
|
||||||
|
spellBtns.add(spellBtn);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO rows?
|
||||||
|
int left = 0;
|
||||||
|
for (IconButton btn : spellBtns){
|
||||||
|
btn.setRect(left, msg.bottom()+4, 20, 20);
|
||||||
|
left += btn.width()+4;
|
||||||
|
}
|
||||||
|
|
||||||
|
resize(WIDTH, (int)spellBtns.get(0).bottom());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO we probably want to offset this window for mobile so it appears closer to quickslots
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user