Search in sources :

Example 1 with Plant

use of com.watabou.pixeldungeon.plants.Plant in project pixel-dungeon by watabou.

the class Level method press.

public void press(int cell, Char ch) {
    if (pit[cell] && ch == Dungeon.hero) {
        Chasm.heroFall(cell);
        return;
    }
    boolean trap = false;
    switch(map[cell]) {
        case Terrain.SECRET_TOXIC_TRAP:
            GLog.i(TXT_HIDDEN_PLATE_CLICKS);
        case Terrain.TOXIC_TRAP:
            trap = true;
            ToxicTrap.trigger(cell, ch);
            break;
        case Terrain.SECRET_FIRE_TRAP:
            GLog.i(TXT_HIDDEN_PLATE_CLICKS);
        case Terrain.FIRE_TRAP:
            trap = true;
            FireTrap.trigger(cell, ch);
            break;
        case Terrain.SECRET_PARALYTIC_TRAP:
            GLog.i(TXT_HIDDEN_PLATE_CLICKS);
        case Terrain.PARALYTIC_TRAP:
            trap = true;
            ParalyticTrap.trigger(cell, ch);
            break;
        case Terrain.SECRET_POISON_TRAP:
            GLog.i(TXT_HIDDEN_PLATE_CLICKS);
        case Terrain.POISON_TRAP:
            trap = true;
            PoisonTrap.trigger(cell, ch);
            break;
        case Terrain.SECRET_ALARM_TRAP:
            GLog.i(TXT_HIDDEN_PLATE_CLICKS);
        case Terrain.ALARM_TRAP:
            trap = true;
            AlarmTrap.trigger(cell, ch);
            break;
        case Terrain.SECRET_LIGHTNING_TRAP:
            GLog.i(TXT_HIDDEN_PLATE_CLICKS);
        case Terrain.LIGHTNING_TRAP:
            trap = true;
            LightningTrap.trigger(cell, ch);
            break;
        case Terrain.SECRET_GRIPPING_TRAP:
            GLog.i(TXT_HIDDEN_PLATE_CLICKS);
        case Terrain.GRIPPING_TRAP:
            trap = true;
            GrippingTrap.trigger(cell, ch);
            break;
        case Terrain.SECRET_SUMMONING_TRAP:
            GLog.i(TXT_HIDDEN_PLATE_CLICKS);
        case Terrain.SUMMONING_TRAP:
            trap = true;
            SummoningTrap.trigger(cell, ch);
            break;
        case Terrain.HIGH_GRASS:
            HighGrass.trample(this, cell, ch);
            break;
        case Terrain.WELL:
            WellWater.affectCell(cell);
            break;
        case Terrain.ALCHEMY:
            if (ch == null) {
                Alchemy.transmute(cell);
            }
            break;
        case Terrain.DOOR:
            Door.enter(cell);
            break;
    }
    if (trap) {
        Sample.INSTANCE.play(Assets.SND_TRAP);
        if (ch == Dungeon.hero) {
            Dungeon.hero.interrupt();
        }
        set(cell, Terrain.INACTIVE_TRAP);
        GameScene.updateMap(cell);
    }
    Plant plant = plants.get(cell);
    if (plant != null) {
        plant.activate(ch);
    }
}
Also used : Plant(com.watabou.pixeldungeon.plants.Plant)

Example 2 with Plant

use of com.watabou.pixeldungeon.plants.Plant in project pixel-dungeon by watabou.

the class Level method create.

public void create() {
    resizingNeeded = false;
    map = new int[LENGTH];
    visited = new boolean[LENGTH];
    Arrays.fill(visited, false);
    mapped = new boolean[LENGTH];
    Arrays.fill(mapped, false);
    mobs = new HashSet<Mob>();
    heaps = new SparseArray<Heap>();
    blobs = new HashMap<Class<? extends Blob>, Blob>();
    plants = new SparseArray<Plant>();
    if (!Dungeon.bossLevel()) {
        addItemToSpawn(Generator.random(Generator.Category.FOOD));
        if (Dungeon.posNeeded()) {
            addItemToSpawn(new PotionOfStrength());
            Dungeon.potionOfStrength++;
        }
        if (Dungeon.souNeeded()) {
            addItemToSpawn(new ScrollOfUpgrade());
            Dungeon.scrollsOfUpgrade++;
        }
        if (Dungeon.soeNeeded()) {
            addItemToSpawn(new ScrollOfEnchantment());
            Dungeon.scrollsOfEnchantment++;
        }
        if (Dungeon.depth > 1) {
            switch(Random.Int(10)) {
                case 0:
                    if (!Dungeon.bossLevel(Dungeon.depth + 1)) {
                        feeling = Feeling.CHASM;
                    }
                    break;
                case 1:
                    feeling = Feeling.WATER;
                    break;
                case 2:
                    feeling = Feeling.GRASS;
                    break;
            }
        }
    }
    boolean pitNeeded = Dungeon.depth > 1 && weakFloorCreated;
    do {
        Arrays.fill(map, feeling == Feeling.CHASM ? Terrain.CHASM : Terrain.WALL);
        pitRoomNeeded = pitNeeded;
        weakFloorCreated = false;
    } while (!build());
    decorate();
    buildFlagMaps();
    cleanWalls();
    createMobs();
    createItems();
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Blob(com.watabou.pixeldungeon.actors.blobs.Blob) ScrollOfEnchantment(com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment) PotionOfStrength(com.watabou.pixeldungeon.items.potions.PotionOfStrength) Heap(com.watabou.pixeldungeon.items.Heap) Plant(com.watabou.pixeldungeon.plants.Plant) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass) ScrollOfUpgrade(com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)

Example 3 with Plant

use of com.watabou.pixeldungeon.plants.Plant in project pixel-dungeon by watabou.

the class Level method restoreFromBundle.

@Override
public void restoreFromBundle(Bundle bundle) {
    mobs = new HashSet<Mob>();
    heaps = new SparseArray<Heap>();
    blobs = new HashMap<Class<? extends Blob>, Blob>();
    plants = new SparseArray<Plant>();
    map = bundle.getIntArray(MAP);
    visited = bundle.getBooleanArray(VISITED);
    mapped = bundle.getBooleanArray(MAPPED);
    entrance = bundle.getInt(ENTRANCE);
    exit = bundle.getInt(EXIT);
    weakFloorCreated = false;
    adjustMapSize();
    Collection<Bundlable> collection = bundle.getCollection(HEAPS);
    for (Bundlable h : collection) {
        Heap heap = (Heap) h;
        if (resizingNeeded) {
            heap.pos = adjustPos(heap.pos);
        }
        heaps.put(heap.pos, heap);
    }
    collection = bundle.getCollection(PLANTS);
    for (Bundlable p : collection) {
        Plant plant = (Plant) p;
        if (resizingNeeded) {
            plant.pos = adjustPos(plant.pos);
        }
        plants.put(plant.pos, plant);
    }
    collection = bundle.getCollection(MOBS);
    for (Bundlable m : collection) {
        Mob mob = (Mob) m;
        if (mob != null) {
            if (resizingNeeded) {
                mob.pos = adjustPos(mob.pos);
            }
            mobs.add(mob);
        }
    }
    collection = bundle.getCollection(BLOBS);
    for (Bundlable b : collection) {
        Blob blob = (Blob) b;
        blobs.put(blob.getClass(), blob);
    }
    buildFlagMaps();
    cleanWalls();
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Blob(com.watabou.pixeldungeon.actors.blobs.Blob) Plant(com.watabou.pixeldungeon.plants.Plant) Bundlable(com.watabou.utils.Bundlable) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass) Heap(com.watabou.pixeldungeon.items.Heap)

Example 4 with Plant

use of com.watabou.pixeldungeon.plants.Plant in project pixel-dungeon by watabou.

the class Level method mobPress.

public void mobPress(Mob mob) {
    int cell = mob.pos;
    if (pit[cell] && !mob.flying) {
        Chasm.mobFall(mob);
        return;
    }
    boolean trap = true;
    switch(map[cell]) {
        case Terrain.TOXIC_TRAP:
            ToxicTrap.trigger(cell, mob);
            break;
        case Terrain.FIRE_TRAP:
            FireTrap.trigger(cell, mob);
            break;
        case Terrain.PARALYTIC_TRAP:
            ParalyticTrap.trigger(cell, mob);
            break;
        case Terrain.POISON_TRAP:
            PoisonTrap.trigger(cell, mob);
            break;
        case Terrain.ALARM_TRAP:
            AlarmTrap.trigger(cell, mob);
            break;
        case Terrain.LIGHTNING_TRAP:
            LightningTrap.trigger(cell, mob);
            break;
        case Terrain.GRIPPING_TRAP:
            GrippingTrap.trigger(cell, mob);
            break;
        case Terrain.SUMMONING_TRAP:
            SummoningTrap.trigger(cell, mob);
            break;
        case Terrain.DOOR:
            Door.enter(cell);
        default:
            trap = false;
    }
    if (trap) {
        if (Dungeon.visible[cell]) {
            Sample.INSTANCE.play(Assets.SND_TRAP);
        }
        set(cell, Terrain.INACTIVE_TRAP);
        GameScene.updateMap(cell);
    }
    Plant plant = plants.get(cell);
    if (plant != null) {
        plant.activate(mob);
    }
}
Also used : Plant(com.watabou.pixeldungeon.plants.Plant)

Example 5 with Plant

use of com.watabou.pixeldungeon.plants.Plant in project pixel-dungeon by watabou.

the class Level method plant.

public Plant plant(Plant.Seed seed, int pos) {
    Plant plant = plants.get(pos);
    if (plant != null) {
        plant.wither();
    }
    plant = seed.couch(pos);
    plants.put(pos, plant);
    GameScene.add(plant);
    return plant;
}
Also used : Plant(com.watabou.pixeldungeon.plants.Plant)

Aggregations

Plant (com.watabou.pixeldungeon.plants.Plant)5 Blob (com.watabou.pixeldungeon.actors.blobs.Blob)2 HeroClass (com.watabou.pixeldungeon.actors.hero.HeroClass)2 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)2 Heap (com.watabou.pixeldungeon.items.Heap)2 PotionOfStrength (com.watabou.pixeldungeon.items.potions.PotionOfStrength)1 ScrollOfEnchantment (com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment)1 ScrollOfUpgrade (com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)1 Bundlable (com.watabou.utils.Bundlable)1