Search in sources :

Example 6 with KindOfWeapon

use of com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon in project shattered-pixel-dungeon-gdx by 00-Evan.

the class DisarmingTrap method activate.

@Override
public void activate() {
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        int cell = Dungeon.level.randomRespawnCell();
        if (cell != -1) {
            Item item = heap.pickUp();
            Dungeon.level.drop(item, cell).seen = true;
            for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell + i] = true;
            GameScene.updateFog();
            Sample.INSTANCE.play(Assets.SND_TELEPORT);
            CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
        }
    }
    if (Dungeon.hero.pos == pos) {
        Hero hero = Dungeon.hero;
        KindOfWeapon weapon = hero.belongings.weapon;
        if (weapon != null && !(weapon instanceof Knuckles) && !weapon.cursed) {
            int cell = Dungeon.level.randomRespawnCell();
            if (cell != -1) {
                hero.belongings.weapon = null;
                Dungeon.quickslot.clearItem(weapon);
                weapon.updateQuickslot();
                Dungeon.level.drop(weapon, cell).seen = true;
                for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell + i] = true;
                GameScene.updateFog();
                GLog.w(Messages.get(this, "disarm"));
                Sample.INSTANCE.play(Assets.SND_TELEPORT);
                CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
            }
        }
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Knuckles(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 7 with KindOfWeapon

use of com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Hero method canAttack.

public boolean canAttack(Char enemy) {
    if (enemy == null || pos == enemy.pos)
        return false;
    // can always attack adjacent enemies
    if (Dungeon.level.adjacent(pos, enemy.pos))
        return true;
    KindOfWeapon wep = Dungeon.hero.belongings.weapon;
    if (wep != null && Dungeon.level.distance(pos, enemy.pos) <= wep.reachFactor(this)) {
        boolean[] passable = BArray.not(Dungeon.level.solid, null);
        for (Mob m : Dungeon.level.mobs) passable[m.pos] = false;
        PathFinder.buildDistanceMap(enemy.pos, passable, wep.reachFactor(this));
        return PathFinder.distance[pos] <= wep.reachFactor(this);
    } else {
        return false;
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon)

Aggregations

KindOfWeapon (com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon)7 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)2 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)2 Knuckles (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles)2 Berserk (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Berserk)1 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)1 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)1 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)1 KindofMisc (com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc)1 Armor (com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)1 Weapon (com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon)1 Gauntlet (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Gauntlet)1 Boomerang (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang)1 MissileWeapon (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon)1 ArrayList (java.util.ArrayList)1