use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WndTradeItem method sellOne.
private void sellOne(Item item) {
if (item.quantity() <= 1) {
sell(item);
} else {
Hero hero = Dungeon.hero;
item = item.detach(hero.belongings.backpack);
new Gold(item.price()).doPickUp(hero);
// selling items in the sell interface doesn't spend time
hero.spend(-hero.cooldown());
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WndTradeItem method buy.
private void buy(Heap heap) {
Hero hero = Dungeon.hero;
Item item = heap.pickUp();
int price = price(item);
Dungeon.gold -= price;
if (!item.doPickUp(hero)) {
Dungeon.level.drop(item, heap.pos).sprite.drop();
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Char method attack.
public boolean attack(Char enemy) {
if (enemy == null || !enemy.isAlive())
return false;
boolean visibleFight = Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[enemy.pos];
if (hit(this, enemy, false)) {
int dr = enemy.drRoll();
if (this instanceof Hero) {
Hero h = (Hero) this;
if (h.belongings.weapon instanceof MissileWeapon && h.subClass == HeroSubClass.SNIPER) {
dr = 0;
}
}
int dmg;
Preparation prep = buff(Preparation.class);
if (prep != null) {
dmg = prep.damageRoll(this, enemy);
} else {
dmg = damageRoll();
}
int effectiveDamage = Math.max(dmg - dr, 0);
effectiveDamage = attackProc(enemy, effectiveDamage);
effectiveDamage = enemy.defenseProc(this, effectiveDamage);
if (visibleFight) {
Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
}
if (enemy == Dungeon.hero) {
Dungeon.hero.interrupt();
}
// This matters as defence procs can sometimes inflict self-damage, such as armor glyphs.
if (!enemy.isAlive()) {
return true;
}
// TODO: consider revisiting this and shaking in more cases.
float shake = 0f;
if (enemy == Dungeon.hero)
shake = effectiveDamage / (enemy.HT / 4);
if (shake > 1f)
Camera.main.shake(GameMath.gate(1, shake, 5), 0.3f);
enemy.damage(effectiveDamage, this);
if (buff(FireImbue.class) != null)
buff(FireImbue.class).proc(enemy);
if (buff(EarthImbue.class) != null)
buff(EarthImbue.class).proc(enemy);
enemy.sprite.bloodBurstA(sprite.center(), effectiveDamage);
enemy.sprite.flash();
if (!enemy.isAlive() && visibleFight) {
if (enemy == Dungeon.hero) {
Dungeon.fail(getClass());
GLog.n(Messages.capitalize(Messages.get(Char.class, "kill", name)));
} else if (this == Dungeon.hero) {
GLog.i(Messages.capitalize(Messages.get(Char.class, "defeat", enemy.name)));
}
}
return true;
} else {
if (visibleFight) {
String defense = enemy.defenseVerb();
enemy.sprite.showStatus(CharSprite.NEUTRAL, defense);
Sample.INSTANCE.play(Assets.SND_MISS);
}
return false;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Foliage method evolve.
@Override
protected void evolve() {
int[] map = Dungeon.level.map;
boolean visible = false;
int cell;
for (int i = area.left; i < area.right; i++) {
for (int j = area.top; j < area.bottom; j++) {
cell = i + j * Dungeon.level.width();
if (cur[cell] > 0) {
off[cell] = cur[cell];
volume += off[cell];
if (map[cell] == Terrain.EMBERS) {
map[cell] = Terrain.GRASS;
GameScene.updateMap(cell);
}
visible = visible || Dungeon.level.heroFOV[cell];
} else {
off[cell] = 0;
}
}
}
Hero hero = Dungeon.hero;
if (hero.isAlive() && hero.visibleEnemies() == 0 && cur[hero.pos] > 0) {
Buff.affect(hero, Shadows.class).prolong();
}
if (visible) {
Notes.add(Notes.Landmark.GARDEN);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Combo method getIcon.
@Override
public Image getIcon() {
Image icon;
if (((Hero) target).belongings.weapon != null) {
icon = new ItemSprite(((Hero) target).belongings.weapon.image, null);
} else {
icon = new ItemSprite(new Item() {
{
image = ItemSpriteSheet.WEAPON_HOLDER;
}
});
}
if (count >= 10)
icon.tint(0xFFFF0000);
else if (count >= 8)
icon.tint(0xFFFFCC00);
else if (count >= 6)
icon.tint(0xFFFFFF00);
else if (count >= 4)
icon.tint(0xFFCCFF00);
else
icon.tint(0xFF00FF00);
return icon;
}
Aggregations