use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon by watabou.
the class Dungeon method init.
public static void init() {
challenges = PixelDungeon.challenges();
Actor.clear();
PathFinder.setMapSize(Level.WIDTH, Level.HEIGHT);
Scroll.initLabels();
Potion.initColors();
Wand.initWoods();
Ring.initGems();
Statistics.reset();
Journal.reset();
depth = 0;
gold = 0;
droppedItems = new SparseArray<ArrayList<Item>>();
potionOfStrength = 0;
scrollsOfUpgrade = 0;
scrollsOfEnchantment = 0;
dewVial = true;
chapters = new HashSet<Integer>();
Ghost.Quest.reset();
Wandmaker.Quest.reset();
Blacksmith.Quest.reset();
Imp.Quest.reset();
Room.shuffleTypes();
QuickSlot.primaryValue = null;
QuickSlot.secondaryValue = null;
hero = new Hero();
hero.live();
Badges.reset();
StartScene.curClass.initHero(hero);
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon by watabou.
the class Burning method act.
@Override
public boolean act() {
if (target.isAlive()) {
if (target instanceof Hero) {
Buff.prolong(target, Light.class, TICK * 1.01f);
}
target.damage(Random.Int(1, 5), this);
if (target instanceof Hero) {
Item item = ((Hero) target).belongings.randomUnequipped();
if (item instanceof Scroll) {
item = item.detach(((Hero) target).belongings.backpack);
GLog.w(TXT_BURNS_UP, item.toString());
Heap.burnFX(target.pos);
} else if (item instanceof MysteryMeat) {
item = item.detach(((Hero) target).belongings.backpack);
ChargrilledMeat steak = new ChargrilledMeat();
if (!steak.collect(((Hero) target).belongings.backpack)) {
Dungeon.level.drop(steak, target.pos).sprite.drop();
}
GLog.w(TXT_BURNS_UP, item.toString());
Heap.burnFX(target.pos);
}
} else if (target instanceof Thief && ((Thief) target).item instanceof Scroll) {
((Thief) target).item = null;
target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
}
} else {
detach();
}
if (Level.flamable[target.pos]) {
GameScene.add(Blob.seed(target.pos, 4, Fire.class));
}
spend(TICK);
left -= TICK;
if (left <= 0 || Random.Float() > (2 + (float) target.HP / target.HT) / 3 || (Level.water[target.pos] && !target.flying)) {
detach();
}
return true;
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon by watabou.
the class Frost method attachTo.
@Override
public boolean attachTo(Char target) {
if (super.attachTo(target)) {
target.paralysed = true;
Burning.detach(target, Burning.class);
if (target instanceof Hero) {
Hero hero = (Hero) target;
Item item = hero.belongings.randomUnequipped();
if (item instanceof MysteryMeat) {
item = item.detach(hero.belongings.backpack);
FrozenCarpaccio carpaccio = new FrozenCarpaccio();
if (!carpaccio.collect(hero.belongings.backpack)) {
Dungeon.level.drop(carpaccio, target.pos).sprite.drop();
}
}
}
return true;
} else {
return false;
}
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class AttackIndicator method checkEnemies.
private void checkEnemies() {
Hero hero = Dungeon.hero;
candidates.clear();
int v = hero.visibleEnemies();
for (int i = 0; i < v; i++) {
Mob mob = hero.visibleEnemy(i);
if (hero.canAttack(mob) && !mob.friendly(hero)) {
candidates.add(mob);
}
}
if (!candidates.contains(lastTarget)) {
if (candidates.isEmpty()) {
lastTarget = null;
} else {
lastTarget = Random.element(candidates);
updateImage();
flash();
}
} else {
if (!bg.getVisible()) {
flash();
}
}
visible(lastTarget != null);
enable(bg.getVisible());
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class Fadeleaf method effect.
public void effect(int pos, Char ch) {
if (ch instanceof Hero) {
Hero hero = (Hero) ch;
ScrollOfTeleportation.teleportHero(hero);
hero.spendAndNext(1);
hero.curAction = null;
} else if (ch instanceof Mob && ch.isMovable()) {
int newPos = Dungeon.level.randomRespawnCell();
if (Dungeon.level.cellValid(newPos)) {
ch.setPos(newPos);
ch.getSprite().place(ch.getPos());
ch.getSprite().setVisible(Dungeon.visible[pos]);
}
}
if (Dungeon.visible[pos]) {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
}
}
Aggregations