Search in sources :

Example 1 with CustomTiledVisual

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

the class GameScene method create.

@Override
public void create() {
    Music.INSTANCE.play(Assets.TUNE, true);
    SPDSettings.lastClass(Dungeon.hero.heroClass.ordinal());
    super.create();
    Camera.main.zoom(GameMath.gate(minZoom, defaultZoom + SPDSettings.zoom(), maxZoom));
    scene = this;
    terrain = new Group();
    add(terrain);
    water = new SkinnedBlock(Dungeon.level.width() * DungeonTilemap.SIZE, Dungeon.level.height() * DungeonTilemap.SIZE, Dungeon.level.waterTex()) {

        @Override
        protected NoosaScript script() {
            return NoosaScriptNoLighting.get();
        }

        @Override
        public void draw() {
            // water has no alpha component, this improves performance
            Blending.disable();
            super.draw();
            Blending.enable();
        }
    };
    terrain.add(water);
    ripples = new Group();
    terrain.add(ripples);
    DungeonTileSheet.setupVariance(Dungeon.level.map.length, Dungeon.seedCurDepth());
    tiles = new DungeonTerrainTilemap();
    terrain.add(tiles);
    customTiles = new Group();
    terrain.add(customTiles);
    for (CustomTiledVisual visual : Dungeon.level.customTiles) {
        addCustomTile(visual);
    }
    visualGrid = new GridTileMap();
    terrain.add(visualGrid);
    terrainFeatures = new TerrainFeaturesTilemap(Dungeon.level.plants, Dungeon.level.traps);
    terrain.add(terrainFeatures);
    levelVisuals = Dungeon.level.addVisuals();
    add(levelVisuals);
    heaps = new Group();
    add(heaps);
    for (IntMap.Entry<Heap> heap : Dungeon.level.heaps) {
        addHeapSprite(heap.value);
    }
    emitters = new Group();
    effects = new Group();
    healthIndicators = new Group();
    emoicons = new Group();
    mobs = new Group();
    add(mobs);
    for (Mob mob : Dungeon.level.mobs) {
        addMobSprite(mob);
        if (Statistics.amuletObtained) {
            mob.beckon(Dungeon.hero.pos);
        }
    }
    walls = new DungeonWallsTilemap();
    add(walls);
    customWalls = new Group();
    add(customWalls);
    for (CustomTiledVisual visual : Dungeon.level.customWalls) {
        addCustomWall(visual);
    }
    wallBlocking = new WallBlockingTilemap();
    add(wallBlocking);
    add(emitters);
    add(effects);
    gases = new Group();
    add(gases);
    for (Blob blob : Dungeon.level.blobs.values()) {
        blob.emitter = null;
        addBlobSprite(blob);
    }
    fog = new FogOfWar(Dungeon.level.width(), Dungeon.level.height());
    add(fog);
    spells = new Group();
    add(spells);
    statuses = new Group();
    add(statuses);
    add(healthIndicators);
    // always appears ontop of other health indicators
    add(new TargetHealthIndicator());
    add(emoicons);
    hero = new HeroSprite();
    hero.place(Dungeon.hero.pos);
    hero.updateArmor();
    mobs.add(hero);
    add(cellSelector = new CellSelector(tiles));
    pane = new StatusPane();
    pane.camera = uiCamera;
    pane.setSize(uiCamera.width, 0);
    add(pane);
    toolbar = new Toolbar();
    toolbar.camera = uiCamera;
    toolbar.setRect(0, uiCamera.height - toolbar.height(), uiCamera.width, toolbar.height());
    add(toolbar);
    attack = new AttackIndicator();
    attack.camera = uiCamera;
    add(attack);
    loot = new LootIndicator();
    loot.camera = uiCamera;
    add(loot);
    action = new ActionIndicator();
    action.camera = uiCamera;
    add(action);
    resume = new ResumeIndicator();
    resume.camera = uiCamera;
    add(resume);
    log = new GameLog();
    log.camera = uiCamera;
    log.newLine();
    add(log);
    layoutTags();
    busy = new BusyIndicator();
    busy.camera = uiCamera;
    busy.x = 1;
    busy.y = pane.bottom() + 1;
    add(busy);
    switch(InterlevelScene.mode) {
        case RESURRECT:
            ScrollOfTeleportation.appear(Dungeon.hero, Dungeon.level.entrance);
            new Flare(8, 32).color(0xFFFF66, true).show(hero, 2f);
            break;
        case RETURN:
            ScrollOfTeleportation.appear(Dungeon.hero, Dungeon.hero.pos);
            break;
        case FALL:
            Chasm.heroLand();
            break;
        case DESCEND:
            switch(Dungeon.depth) {
                case 1:
                    WndStory.showChapter(WndStory.ID_SEWERS);
                    break;
                case 6:
                    WndStory.showChapter(WndStory.ID_PRISON);
                    break;
                case 11:
                    WndStory.showChapter(WndStory.ID_CAVES);
                    break;
                case 16:
                    WndStory.showChapter(WndStory.ID_CITY);
                    break;
                case 22:
                    WndStory.showChapter(WndStory.ID_HALLS);
                    break;
            }
            if (Dungeon.hero.isAlive() && Dungeon.depth != 22) {
                Badges.validateNoKilling();
            }
            break;
        default:
    }
    ArrayList<Item> dropped = Dungeon.droppedItems.get(Dungeon.depth);
    if (dropped != null) {
        for (Item item : dropped) {
            int pos = Dungeon.level.randomRespawnCell();
            if (item instanceof Potion) {
                ((Potion) item).shatter(pos);
            } else if (item instanceof Plant.Seed) {
                Dungeon.level.plant((Plant.Seed) item, pos);
            } else if (item instanceof Honeypot) {
                Dungeon.level.drop(((Honeypot) item).shatter(null, pos), pos);
            } else {
                Dungeon.level.drop(item, pos);
            }
        }
        Dungeon.droppedItems.remove(Dungeon.depth);
    }
    Dungeon.hero.next();
    Camera.main.target = hero;
    if (InterlevelScene.mode != InterlevelScene.Mode.NONE) {
        if (Dungeon.depth == Statistics.deepestFloor && (InterlevelScene.mode == InterlevelScene.Mode.DESCEND || InterlevelScene.mode == InterlevelScene.Mode.FALL)) {
            GLog.h(Messages.get(this, "descend"), Dungeon.depth);
            Sample.INSTANCE.play(Assets.SND_DESCEND);
        } else if (InterlevelScene.mode == InterlevelScene.Mode.RESET) {
            GLog.h(Messages.get(this, "warp"));
        } else {
            GLog.h(Messages.get(this, "return"), Dungeon.depth);
        }
        switch(Dungeon.level.feeling) {
            case CHASM:
                GLog.w(Messages.get(this, "chasm"));
                break;
            case WATER:
                GLog.w(Messages.get(this, "water"));
                break;
            case GRASS:
                GLog.w(Messages.get(this, "grass"));
                break;
            case DARK:
                GLog.w(Messages.get(this, "dark"));
                break;
            default:
        }
        if (Dungeon.level instanceof RegularLevel && ((RegularLevel) Dungeon.level).secretDoors > Random.IntRange(3, 4)) {
            GLog.w(Messages.get(this, "secrets"));
        }
        InterlevelScene.mode = InterlevelScene.Mode.NONE;
        fadeIn();
    }
    selectCell(defaultCellListener);
}
Also used : Group(com.watabou.noosa.Group) StatusPane(com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane) DungeonTerrainTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTerrainTilemap) NoosaScript(com.watabou.noosa.NoosaScript) GridTileMap(com.shatteredpixel.shatteredpixeldungeon.tiles.GridTileMap) AttackIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) WndTradeItem(com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem) WndInfoItem(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoItem) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) WndInfoPlant(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant) TargetHealthIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.TargetHealthIndicator) IntMap(com.badlogic.gdx.utils.IntMap) BusyIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.BusyIndicator) SkinnedBlock(com.watabou.noosa.SkinnedBlock) GameLog(com.shatteredpixel.shatteredpixeldungeon.ui.GameLog) Toolbar(com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) WndInfoMob(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob) FogOfWar(com.shatteredpixel.shatteredpixeldungeon.tiles.FogOfWar) Blob(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob) Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) ActionIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) ResumeIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.ResumeIndicator) CustomTiledVisual(com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual) TerrainFeaturesTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.TerrainFeaturesTilemap) WallBlockingTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.WallBlockingTilemap) LootIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator) DungeonWallsTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonWallsTilemap) HeroSprite(com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite) Honeypot(com.shatteredpixel.shatteredpixeldungeon.items.Honeypot) RegularLevel(com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel)

Example 2 with CustomTiledVisual

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

the class Level method restoreFromBundle.

@Override
public void restoreFromBundle(Bundle bundle) {
    version = bundle.getInt(VERSION);
    // saves from before 0.5.0b are not supported
    if (version < ShatteredPixelDungeon.v0_5_0b) {
        throw new RuntimeException("old save");
    }
    setSize(bundle.getInt(WIDTH), bundle.getInt(HEIGHT));
    mobs = new HashSet<>();
    heaps = new SparseArray<>();
    blobs = new HashMap<>();
    plants = new SparseArray<>();
    traps = new SparseArray<>();
    customTiles = new HashSet<>();
    customWalls = new HashSet<>();
    map = bundle.getIntArray(MAP);
    visited = bundle.getBooleanArray(VISITED);
    mapped = bundle.getBooleanArray(MAPPED);
    entrance = bundle.getInt(ENTRANCE);
    exit = bundle.getInt(EXIT);
    locked = bundle.getBoolean(LOCKED);
    // pre-0.6.1 saves
    if (version <= ShatteredPixelDungeon.v0_6_0b) {
        map = Terrain.convertTilesFrom0_6_0b(map);
    }
    Collection<Bundlable> collection = bundle.getCollection(HEAPS);
    for (Bundlable h : collection) {
        Heap heap = (Heap) h;
        if (!heap.isEmpty())
            heaps.put(heap.pos, heap);
    }
    collection = bundle.getCollection(PLANTS);
    for (Bundlable p : collection) {
        Plant plant = (Plant) p;
        plants.put(plant.pos, plant);
    }
    collection = bundle.getCollection(TRAPS);
    for (Bundlable p : collection) {
        Trap trap = (Trap) p;
        traps.put(trap.pos, trap);
    }
    collection = bundle.getCollection(CUSTOM_TILES);
    for (Bundlable p : collection) {
        CustomTiledVisual vis = (CustomTiledVisual) p;
        customTiles.add(vis);
    }
    collection = bundle.getCollection(CUSTOM_WALLS);
    for (Bundlable p : collection) {
        CustomTiledVisual vis = (CustomTiledVisual) p;
        customWalls.add(vis);
    }
    collection = bundle.getCollection(MOBS);
    for (Bundlable m : collection) {
        Mob mob = (Mob) m;
        if (mob != null) {
            mobs.add(mob);
        }
    }
    collection = bundle.getCollection(BLOBS);
    for (Bundlable b : collection) {
        Blob blob = (Blob) b;
        blobs.put(blob.getClass(), blob);
    }
    feeling = bundle.getEnum(FEELING, Feeling.class);
    if (feeling == Feeling.DARK)
        viewDistance = Math.round(viewDistance / 2f);
    buildFlagMaps();
    cleanWalls();
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Bundlable(com.watabou.utils.Bundlable) Blob(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob) Trap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) CustomTiledVisual(com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual)

Example 3 with CustomTiledVisual

use of com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual 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 4 with CustomTiledVisual

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

the class WeakFloorRoom method paint.

public void paint(Level level) {
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.CHASM);
    Door door = entrance();
    door.set(Door.Type.REGULAR);
    Point well = null;
    if (door.x == left) {
        for (int i = top + 1; i < bottom; i++) {
            Painter.drawInside(level, this, new Point(left, i), Random.IntRange(1, width() - 4), Terrain.EMPTY_SP);
        }
        well = new Point(right - 1, Random.Int(2) == 0 ? top + 2 : bottom - 1);
    } else if (door.x == right) {
        for (int i = top + 1; i < bottom; i++) {
            Painter.drawInside(level, this, new Point(right, i), Random.IntRange(1, width() - 4), Terrain.EMPTY_SP);
        }
        well = new Point(left + 1, Random.Int(2) == 0 ? top + 2 : bottom - 1);
    } else if (door.y == top) {
        for (int i = left + 1; i < right; i++) {
            Painter.drawInside(level, this, new Point(i, top), Random.IntRange(1, height() - 4), Terrain.EMPTY_SP);
        }
        well = new Point(Random.Int(2) == 0 ? left + 1 : right - 1, bottom - 1);
    } else if (door.y == bottom) {
        for (int i = left + 1; i < right; i++) {
            Painter.drawInside(level, this, new Point(i, bottom), Random.IntRange(1, height() - 4), Terrain.EMPTY_SP);
        }
        well = new Point(Random.Int(2) == 0 ? left + 1 : right - 1, top + 2);
    }
    Painter.set(level, well, Terrain.CHASM);
    CustomTiledVisual vis = new HiddenWell();
    vis.pos(well.x, well.y);
    level.customTiles.add(vis);
}
Also used : CustomTiledVisual(com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Aggregations

CustomTiledVisual (com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual)4 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)3 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)2 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)2 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)2 Plant (com.shatteredpixel.shatteredpixeldungeon.plants.Plant)2 IntMap (com.badlogic.gdx.utils.IntMap)1 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)1 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)1 Potion (com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion)1 RegularLevel (com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel)1 MazeRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MazeRoom)1 Room (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)1 Trap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)1 GameScene (com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene)1 HeroSprite (com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite)1 DungeonTerrainTilemap (com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTerrainTilemap)1 DungeonWallsTilemap (com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonWallsTilemap)1 FogOfWar (com.shatteredpixel.shatteredpixeldungeon.tiles.FogOfWar)1 GridTileMap (com.shatteredpixel.shatteredpixeldungeon.tiles.GridTileMap)1