Search in sources :

Example 31 with Char

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

the class Mimic method spawnAt.

public static Mimic spawnAt(int pos, List<Item> items) {
    if (Dungeon.level.pit[pos])
        return null;
    Char ch = Actor.findChar(pos);
    if (ch != null) {
        ArrayList<Integer> candidates = new ArrayList<>();
        for (int n : PathFinder.NEIGHBOURS8) {
            int cell = pos + n;
            if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
                candidates.add(cell);
            }
        }
        if (candidates.size() > 0) {
            int newPos = Random.element(candidates);
            Actor.addDelayed(new Pushing(ch, ch.pos, newPos), -1);
            ch.pos = newPos;
            Dungeon.level.press(newPos, ch);
        } else {
            return null;
        }
    }
    Mimic m = new Mimic();
    m.items = new ArrayList<>(items);
    m.adjustStats(Dungeon.depth);
    m.pos = pos;
    m.state = m.HUNTING;
    GameScene.add(m, 1);
    m.sprite.turnTo(pos, Dungeon.hero.pos);
    if (Dungeon.level.heroFOV[m.pos]) {
        CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
        Sample.INSTANCE.play(Assets.SND_MIMIC);
    }
    // generate an extra reward for killing the mimic
    Item reward = null;
    do {
        switch(Random.Int(5)) {
            case 0:
                reward = new Gold().random();
                break;
            case 1:
                reward = Generator.randomMissile();
                break;
            case 2:
                reward = Generator.randomArmor();
                break;
            case 3:
                reward = Generator.randomWeapon();
                break;
            case 4:
                reward = Generator.random(Generator.Category.RING);
                break;
        }
    } while (reward == null || Challenges.isItemBlocked(reward));
    m.items.add(reward);
    return m;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 32 with Char

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

the class Skeleton method die.

@Override
public void die(Object cause) {
    super.die(cause);
    if (cause == Chasm.class)
        return;
    boolean heroKilled = false;
    for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
        Char ch = findChar(pos + PathFinder.NEIGHBOURS8[i]);
        if (ch != null && ch.isAlive()) {
            int damage = Math.max(0, damageRoll() - (ch.drRoll() / 2));
            ch.damage(damage, this);
            if (ch == Dungeon.hero && !ch.isAlive()) {
                heroKilled = true;
            }
        }
    }
    if (Dungeon.level.heroFOV[pos]) {
        Sample.INSTANCE.play(Assets.SND_BONES);
    }
    if (heroKilled) {
        Dungeon.fail(getClass());
        GLog.n(Messages.get(this, "explo_kill"));
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Example 33 with Char

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

the class LloydsBeacon method execute.

@Override
public void execute(Hero hero, String action) {
    super.execute(hero, action);
    if (action == AC_SET || action == AC_RETURN) {
        if (Dungeon.bossLevel()) {
            hero.spend(LloydsBeacon.TIME_TO_USE);
            GLog.w(Messages.get(this, "preventing"));
            return;
        }
        for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
            Char ch = Actor.findChar(hero.pos + PathFinder.NEIGHBOURS8[i]);
            if (ch != null && ch.alignment == Char.Alignment.ENEMY) {
                GLog.w(Messages.get(this, "creatures"));
                return;
            }
        }
    }
    if (action == AC_ZAP) {
        curUser = hero;
        int chargesToUse = Dungeon.depth > 20 ? 2 : 1;
        if (!isEquipped(hero)) {
            GLog.i(Messages.get(Artifact.class, "need_to_equip"));
            QuickSlotButton.cancel();
        } else if (charge < chargesToUse) {
            GLog.i(Messages.get(this, "no_charge"));
            QuickSlotButton.cancel();
        } else {
            GameScene.selectCell(zapper);
        }
    } else if (action == AC_SET) {
        returnDepth = Dungeon.depth;
        returnPos = hero.pos;
        hero.spend(LloydsBeacon.TIME_TO_USE);
        hero.busy();
        hero.sprite.operate(hero.pos);
        Sample.INSTANCE.play(Assets.SND_BEACON);
        GLog.i(Messages.get(this, "return"));
    } else if (action == AC_RETURN) {
        if (returnDepth == Dungeon.depth) {
            ScrollOfTeleportation.appear(hero, returnPos);
            Dungeon.level.press(returnPos, hero);
            Dungeon.observe();
            GameScene.updateFog();
        } else {
            Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
            if (buff != null)
                buff.detach();
            InterlevelScene.mode = InterlevelScene.Mode.RETURN;
            InterlevelScene.returnDepth = returnDepth;
            InterlevelScene.returnPos = returnPos;
            Game.switchScene(InterlevelScene.class);
        }
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)

Example 34 with Char

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

the class CellSelector method onClick.

@Override
protected void onClick(NoosaInputProcessor.Touch touch) {
    if (dragging) {
        dragging = false;
    } else {
        PointF p = Camera.main.screenToCamera((int) touch.current.x, (int) touch.current.y);
        for (Char mob : Dungeon.level.mobs.toArray(new Mob[0])) {
            if (mob.sprite != null && mob.sprite.overlapsPoint(p.x, p.y)) {
                select(mob.pos);
                return;
            }
        }
        for (Heap heap : Dungeon.level.heaps.values()) {
            if (heap.sprite != null && heap.sprite.overlapsPoint(p.x, p.y)) {
                select(heap.pos);
                return;
            }
        }
        select(((DungeonTilemap) target).screenToTile((int) touch.current.x, (int) touch.current.y, true));
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) PointF(com.watabou.utils.PointF) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 35 with Char

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

the class PitfallTrap method activate.

@Override
public void activate() {
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        for (Item item : heap.items) {
            Dungeon.dropToChasm(item);
        }
        heap.sprite.kill();
        GameScene.discard(heap);
        Dungeon.level.heaps.remove(pos);
    }
    Char ch = Actor.findChar(pos);
    if (ch == Dungeon.hero) {
        Chasm.heroFall(pos);
    } else if (ch != null) {
        Chasm.mobFall((Mob) ch);
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Aggregations

Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)65 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)13 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)13 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)8 Callback (com.watabou.utils.Callback)8 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)7 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)5 ArrayList (java.util.ArrayList)4 Actor (com.shatteredpixel.shatteredpixeldungeon.actors.Actor)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)3 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)3 Burning (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)3 Frost (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost)3 Bleeding (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)2 Chill (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill)2 Paralysis (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis)2 Lightning (com.shatteredpixel.shatteredpixeldungeon.effects.Lightning)2 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)1 CorrosiveGas (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas)1 Regrowth (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth)1