Search in sources :

Example 31 with Mob

use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob 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)

Example 32 with Mob

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

the class TeleportationTrap 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);
    } 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 33 with Mob

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

the class SummoningTrap method activate.

@Override
public void activate() {
    if (Dungeon.bossLevel()) {
        return;
    }
    int nMobs = 1;
    if (Random.Int(2) == 0) {
        nMobs++;
        if (Random.Int(2) == 0) {
            nMobs++;
        }
    }
    ArrayList<Integer> candidates = new ArrayList<>();
    for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
        int p = pos + PathFinder.NEIGHBOURS8[i];
        if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
            candidates.add(p);
        }
    }
    ArrayList<Integer> respawnPoints = new ArrayList<>();
    while (nMobs > 0 && candidates.size() > 0) {
        int index = Random.index(candidates);
        respawnPoints.add(candidates.remove(index));
        nMobs--;
    }
    ArrayList<Mob> mobs = new ArrayList<>();
    for (Integer point : respawnPoints) {
        Mob mob = Dungeon.level.createMob();
        if (mob != null) {
            mob.state = mob.WANDERING;
            mob.pos = point;
            GameScene.add(mob, DELAY);
            mobs.add(mob);
        }
    }
    // important to process the visuals and pressing of cells last, so spawned mobs have a chance to occupy cells first
    for (Mob mob : mobs) {
        ScrollOfTeleportation.appear(mob, mob.pos);
        // so hidden traps are triggered as well
        Dungeon.level.press(mob.pos, mob, true);
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) ArrayList(java.util.ArrayList)

Example 34 with Mob

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

the class Fadeleaf method activate.

@Override
public void activate() {
    Char ch = Actor.findChar(pos);
    if (ch instanceof Hero) {
        ScrollOfTeleportation.teleportHero((Hero) ch);
        ((Hero) ch).curAction = null;
    } else if (ch instanceof Mob && !ch.properties().contains(Char.Property.IMMOVABLE)) {
        int count = 10;
        int newPos;
        do {
            newPos = Dungeon.level.randomRespawnCell();
            if (count-- <= 0) {
                break;
            }
        } while (newPos == -1);
        if (newPos != -1 && !Dungeon.bossLevel()) {
            ch.pos = newPos;
            if (((Mob) ch).state == ((Mob) ch).HUNTING)
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            ch.sprite.place(ch.pos);
            ch.sprite.visible = Dungeon.level.heroFOV[ch.pos];
        }
    }
    if (Dungeon.level.heroFOV[pos]) {
        CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 35 with Mob

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

the class Blindweed method activate.

@Override
public void activate() {
    Char ch = Actor.findChar(pos);
    if (ch != null) {
        int len = Random.Int(5, 10);
        Buff.prolong(ch, Blindness.class, len);
        Buff.prolong(ch, Cripple.class, len);
        if (ch instanceof Mob) {
            if (((Mob) ch).state == ((Mob) ch).HUNTING)
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            ((Mob) ch).beckon(Dungeon.level.randomDestination());
        }
    }
    if (Dungeon.level.heroFOV[pos]) {
        CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

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