Search in sources :

Example 11 with Mob

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

the class AlarmTrap method activate.

@Override
public void activate() {
    for (Mob mob : Dungeon.level.mobs) {
        mob.beckon(pos);
    }
    if (Dungeon.level.heroFOV[pos]) {
        GLog.w(Messages.get(this, "alarm"));
        CellEmitter.center(pos).start(Speck.factory(Speck.SCREAM), 0.3f, 3);
    }
    Sample.INSTANCE.play(Assets.SND_ALERT);
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)

Example 12 with Mob

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

the class WarpingTrap method activate.

@Override
public void activate() {
    CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    Char ch = Actor.findChar(pos);
    if (ch instanceof Hero) {
        ScrollOfTeleportation.teleportHero((Hero) ch);
        BArray.setFalse(Dungeon.level.visited);
        BArray.setFalse(Dungeon.level.mapped);
        GameScene.updateFog();
        Dungeon.observe();
    } else if (ch != null) {
        int count = 10;
        int pos;
        do {
            pos = Dungeon.level.randomRespawnCell();
            if (count-- <= 0) {
                break;
            }
        } while (pos == -1);
        if (pos == -1 || Dungeon.bossLevel()) {
            GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
        } else {
            ch.pos = pos;
            if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            }
            ch.sprite.place(ch.pos);
            ch.sprite.visible = Dungeon.level.heroFOV[pos];
        }
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        int cell = Dungeon.level.randomRespawnCell();
        Item item = heap.pickUp();
        if (cell != -1) {
            Dungeon.level.drop(item, cell);
        }
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 13 with Mob

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

the class Actor method init.

public static void init() {
    add(Dungeon.hero);
    for (Mob mob : Dungeon.level.mobs) {
        add(mob);
    }
    for (Blob blob : Dungeon.level.blobs.values()) {
        add(blob);
    }
    current = null;
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Blob(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)

Example 14 with Mob

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

the class Hero method handle.

public boolean handle(int cell) {
    if (cell == -1) {
        return false;
    }
    Char ch;
    Heap heap;
    if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
        curAction = new HeroAction.Alchemy(cell);
    } else if (fieldOfView[cell] && (ch = Actor.findChar(cell)) instanceof Mob) {
        if (ch instanceof NPC) {
            curAction = new HeroAction.Interact((NPC) ch);
        } else {
            curAction = new HeroAction.Attack(ch);
        }
    } else if ((heap = Dungeon.level.heaps.get(cell)) != null && // moving to an item doesn't auto-pickup when enemies are near...
    (visibleEnemies.size() == 0 || cell == pos || // ...but only for standard heaps, chests and similar open as normal.
    (heap.type != Type.HEAP && heap.type != Type.FOR_SALE))) {
        switch(heap.type) {
            case HEAP:
                curAction = new HeroAction.PickUp(cell);
                break;
            case FOR_SALE:
                curAction = heap.size() == 1 && heap.peek().price() > 0 ? new HeroAction.Buy(cell) : new HeroAction.PickUp(cell);
                break;
            default:
                curAction = new HeroAction.OpenChest(cell);
        }
    } else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
        curAction = new HeroAction.Unlock(cell);
    } else if (cell == Dungeon.level.exit && Dungeon.depth < 26) {
        curAction = new HeroAction.Descend(cell);
    } else if (cell == Dungeon.level.entrance) {
        curAction = new HeroAction.Ascend(cell);
    } else {
        curAction = new HeroAction.Move(cell);
        lastAction = null;
    }
    if (ready)
        return act();
    else
        return false;
}
Also used : NPC(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Example 15 with Mob

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

the class Level method press.

// a 'soft' press ignores hidden traps
// a 'hard' press triggers all things
// generally a 'hard' press should be forced is something is moving forcefully (e.g. thrown)
public void press(int cell, Char ch, boolean hard) {
    if (ch != null && pit[cell] && !ch.flying) {
        if (ch == Dungeon.hero) {
            Chasm.heroFall(cell);
        } else if (ch instanceof Mob) {
            Chasm.mobFall((Mob) ch);
        }
        return;
    }
    Trap trap = null;
    switch(map[cell]) {
        case Terrain.SECRET_TRAP:
            if (hard) {
                trap = traps.get(cell);
                GLog.i(Messages.get(Level.class, "hidden_trap", trap.name));
            }
            break;
        case Terrain.TRAP:
            trap = traps.get(cell);
            break;
        case Terrain.HIGH_GRASS:
            HighGrass.trample(this, cell, ch);
            break;
        case Terrain.WELL:
            WellWater.affectCell(cell);
            break;
        case Terrain.DOOR:
            Door.enter(cell);
            break;
    }
    if (trap != null) {
        TimekeepersHourglass.timeFreeze timeFreeze = ch != null ? ch.buff(TimekeepersHourglass.timeFreeze.class) : null;
        if (timeFreeze == null) {
            if (ch == Dungeon.hero) {
                Dungeon.hero.interrupt();
            }
            trap.trigger();
        } else {
            Sample.INSTANCE.play(Assets.SND_TRAP);
            discover(cell);
            timeFreeze.setDelayedPress(cell);
        }
    }
    Plant plant = plants.get(cell);
    if (plant != null) {
        plant.trigger();
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) TimekeepersHourglass(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass) Trap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)

Aggregations

Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)49 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)13 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)11 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)9 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)7 ArrayList (java.util.ArrayList)6 Plant (com.shatteredpixel.shatteredpixeldungeon.plants.Plant)4 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)3 Mimic (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic)3 Trap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)3 CustomTiledVisual (com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual)3 Point (com.watabou.utils.Point)3 Awareness (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness)2 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)2 Burning (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)2 MindVision (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision)2 Terror (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror)2 King (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King)2 Statue (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue)2 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)2