Search in sources :

Example 1 with Room

use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room in project shattered-pixel-dungeon-gdx by 00-Evan.

the class PrisonBossLevel method progress.

public void progress() {
    switch(state) {
        // moving to the beginning of the fight
        case START:
            seal();
            set(5 + 25 * 32, Terrain.LOCKED_DOOR);
            GameScene.updateMap(5 + 25 * 32);
            for (Mob m : mobs) {
                // bring the first ally with you
                if (m.alignment == Char.Alignment.ALLY) {
                    // they should immediately walk out of the door
                    m.pos = 5 + 25 * 32;
                    m.sprite.place(m.pos);
                    break;
                }
            }
            tengu.state = tengu.HUNTING;
            // in the middle of the fight room
            tengu.pos = 5 + 28 * 32;
            GameScene.add(tengu);
            tengu.notice();
            state = State.FIGHT_START;
            break;
        // halfway through, move to the maze
        case FIGHT_START:
            changeMap(MAP_MAZE);
            // clear the entrance
            clearEntities((Room) new Room().set(0, 5, 8, 32));
            Actor.remove(tengu);
            mobs.remove(tengu);
            TargetHealthIndicator.instance.target(null);
            tengu.sprite.kill();
            Room maze = new MazeRoom();
            maze.set(10, 1, 31, 29);
            maze.connected.put(null, new Room.Door(10, 2));
            maze.connected.put(maze, new Room.Door(20, 29));
            maze.paint(this);
            buildFlagMaps();
            cleanWalls();
            GameScene.resetMap();
            GameScene.flash(0xFFFFFF);
            Sample.INSTANCE.play(Assets.SND_BLAST);
            state = State.MAZE;
            break;
        // maze beaten, moving to the arena
        case MAZE:
            Dungeon.hero.interrupt();
            Dungeon.hero.pos += 9 + 3 * 32;
            Dungeon.hero.sprite.interruptMotion();
            Dungeon.hero.sprite.place(Dungeon.hero.pos);
            changeMap(MAP_ARENA);
            // clear all but the area right around the teleport spot
            clearEntities((Room) new Room().set(0, 0, 10, 4));
            // if any allies are left over, move them along the same way as the hero
            for (Mob m : mobs) {
                if (m.alignment == Char.Alignment.ALLY) {
                    m.pos += 9 + 3 * 32;
                    m.sprite().place(m.pos);
                }
            }
            tengu.state = tengu.HUNTING;
            do {
                tengu.pos = Random.Int(length());
            } while (solid[tengu.pos] || distance(tengu.pos, Dungeon.hero.pos) < 8);
            GameScene.add(tengu);
            tengu.notice();
            GameScene.flash(0xFFFFFF);
            Sample.INSTANCE.play(Assets.SND_BLAST);
            state = State.FIGHT_ARENA;
            break;
        // arena ended, fight over.
        case FIGHT_ARENA:
            unseal();
            CustomTiledVisual vis = new exitVisual();
            vis.pos(11, 8);
            customTiles.add(vis);
            ((GameScene) ShatteredPixelDungeon.scene()).addCustomTile(vis);
            vis = new exitVisualWalls();
            vis.pos(11, 8);
            customWalls.add(vis);
            ((GameScene) ShatteredPixelDungeon.scene()).addCustomWall(vis);
            Dungeon.hero.interrupt();
            Dungeon.hero.pos = 5 + 27 * 32;
            Dungeon.hero.sprite.interruptMotion();
            Dungeon.hero.sprite.place(Dungeon.hero.pos);
            tengu.pos = 5 + 28 * 32;
            tengu.sprite.place(5 + 28 * 32);
            // remove all mobs, but preserve allies
            ArrayList<Mob> allies = new ArrayList<>();
            for (Mob m : mobs.toArray(new Mob[0])) {
                if (m.alignment == Char.Alignment.ALLY) {
                    allies.add(m);
                    mobs.remove(m);
                }
            }
            clearEntities(null);
            changeMap(MAP_END);
            for (Mob m : allies) {
                do {
                    m.pos = Random.IntRange(3, 7) + Random.IntRange(26, 30) * 32;
                } while (findMob(m.pos) != null);
                m.sprite().place(m.pos);
                mobs.add(m);
            }
            tengu.die(Dungeon.hero);
            for (Item item : storedItems) drop(item, randomPrisonCell());
            GameScene.flash(0xFFFFFF);
            Sample.INSTANCE.play(Assets.SND_BLAST);
            state = State.WON;
            break;
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) CustomTiledVisual(com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual) MazeRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MazeRoom) GameScene(com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene) ArrayList(java.util.ArrayList) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) MazeRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MazeRoom)

Example 2 with Room

use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RegularLevel method initRooms.

protected ArrayList<Room> initRooms() {
    ArrayList<Room> initRooms = new ArrayList<>();
    initRooms.add(roomEntrance = new EntranceRoom());
    initRooms.add(roomExit = new ExitRoom());
    int standards = standardRooms();
    for (int i = 0; i < standards; i++) {
        StandardRoom s;
        do {
            s = StandardRoom.createRoom();
        } while (!s.setSizeCat(standards - i));
        i += s.sizeCat.roomValue - 1;
        initRooms.add(s);
    }
    if (Dungeon.shopOnLevel())
        initRooms.add(new ShopRoom());
    int specials = specialRooms();
    SpecialRoom.initForFloor();
    for (int i = 0; i < specials; i++) initRooms.add(SpecialRoom.createRoom());
    int secrets = SecretRoom.secretsForFloor(Dungeon.depth);
    for (int i = 0; i < secrets; i++) initRooms.add(SecretRoom.createRoom());
    return initRooms;
}
Also used : ShopRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom) ArrayList(java.util.ArrayList) ExitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) PitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom) ShopRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom) SpecialRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom) EntranceRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom) ExitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom) StandardRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom) SecretRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom) EntranceRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom) StandardRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom)

Example 3 with Room

use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RegularLevel method randomRespawnCell.

@Override
public int randomRespawnCell() {
    int count = 0;
    int cell = -1;
    while (true) {
        if (++count > 30) {
            return -1;
        }
        Room room = randomRoom(StandardRoom.class);
        if (room == null || room == roomEntrance) {
            continue;
        }
        cell = pointToCell(room.random(1));
        if (!heroFOV[cell] && Actor.findChar(cell) == null && passable[cell] && cell != exit) {
            return cell;
        }
    }
}
Also used : Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) PitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom) ShopRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom) SpecialRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom) EntranceRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom) ExitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom) StandardRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom) SecretRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom)

Example 4 with Room

use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RegularLevel method randomDestination.

@Override
public int randomDestination() {
    int cell = -1;
    while (true) {
        Room room = Random.element(rooms);
        if (room == null) {
            continue;
        }
        cell = pointToCell(room.random());
        if (passable[cell]) {
            return cell;
        }
    }
}
Also used : Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) PitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom) ShopRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom) SpecialRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom) EntranceRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom) ExitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom) StandardRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom) SecretRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom)

Example 5 with Room

use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RegularBuilder method setupRooms.

protected void setupRooms(ArrayList<Room> rooms) {
    for (Room r : rooms) {
        r.setEmpty();
    }
    entrance = exit = shop = null;
    singleConnections.clear();
    multiConnections.clear();
    for (Room r : rooms) {
        if (r instanceof EntranceRoom) {
            entrance = r;
        } else if (r instanceof ExitRoom) {
            exit = r;
        } else if (r instanceof ShopRoom && r.maxConnections(Room.ALL) == 1) {
            shop = r;
        } else if (r.maxConnections(Room.ALL) > 1) {
            multiConnections.add(r);
        } else if (r.maxConnections(Room.ALL) == 1) {
            singleConnections.add(r);
        }
    }
    // this weights larger rooms to be much more likely to appear in the main loop, by placing them earlier in the multiconnections list
    weightRooms(multiConnections);
    Random.shuffle(multiConnections);
    multiConnections = new ArrayList<>(new LinkedHashSet<>(multiConnections));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ShopRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom) ExitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom) MazeConnectionRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.MazeConnectionRoom) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) ShopRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom) ConnectionRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom) SecretRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom) EntranceRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom) ExitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom) StandardRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom) EntranceRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom)

Aggregations

Room (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)28 ArrayList (java.util.ArrayList)15 StandardRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom)11 EntranceRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom)10 ExitRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom)9 SecretRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom)8 ShopRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom)8 EmptyRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom)8 Point (com.watabou.utils.Point)7 PitRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom)6 SpecialRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom)6 Rect (com.watabou.utils.Rect)6 ConnectionRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom)5 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)2 RegularLevel (com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel)2 MazeConnectionRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.MazeConnectionRoom)2 RatKingRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.RatKingRoom)2 SewerBossEntranceRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.SewerBossEntranceRoom)2 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)1 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)1