Search in sources :

Example 1 with CustomLayerTilemap

use of com.watabou.pixeldungeon.CustomLayerTilemap in project pixel-dungeon-remix by NYRDS.

the class GameScene method create.

@Override
public void create() {
    playLevelMusic();
    Level level = Dungeon.level;
    PixelDungeon.lastClass(Dungeon.hero.heroClass.ordinal());
    super.create();
    Camera.main.zoom((float) (defaultZoom + PixelDungeon.zoom()));
    scene = this;
    Group terrain = new Group();
    add(terrain);
    water = new SkinnedBlock(level.getWidth() * DungeonTilemap.SIZE, level.getHeight() * DungeonTilemap.SIZE, level.getWaterTex());
    waterSx = DungeonGenerator.getLevelProperty(level.levelId, "waterSx", waterSx);
    waterSy = DungeonGenerator.getLevelProperty(level.levelId, "waterSy", waterSy);
    terrain.add(water);
    ripples = new Group();
    terrain.add(ripples);
    String logicTilesAtlas = level.getProperty("tiles_logic", null);
    if (logicTilesAtlas != null) {
        logicTiles = new ClassicDungeonTilemap(level, logicTilesAtlas);
        terrain.add(logicTiles);
    }
    if (!level.customTiles()) {
        baseTiles = DungeonTilemap.factory(level, level.getTilesetForLayer(Level.LayerId.Base));
    } else {
        CustomLayerTilemap tiles = new CustomLayerTilemap(level, Level.LayerId.Base);
        tiles.addLayer(Level.LayerId.Deco);
        tiles.addLayer(Level.LayerId.Deco2);
        baseTiles = tiles;
        tiles = new CustomLayerTilemap(level, Level.LayerId.Roof_Base);
        tiles.addLayer(Level.LayerId.Roof_Deco);
        tiles.setTransparent(true);
        roofTiles = tiles;
    }
    terrain.add(baseTiles);
    objects = new Group();
    add(objects);
    for (int i = 0; i < level.objects.size(); i++) {
        SparseArray<LevelObject> objectLayer = level.objects.valueAt(i);
        for (int j = 0; j < objectLayer.size(); j++) {
            addLevelObjectSprite(objectLayer.valueAt(j));
        }
    }
    level.addVisuals(this);
    plants = new Group();
    add(plants);
    for (int i = 0; i < level.plants.size(); i++) {
        addPlantSprite(level.plants.valueAt(i));
    }
    heaps = new Group();
    add(heaps);
    for (Heap heap : level.allHeaps()) {
        addHeapSprite(heap);
    }
    emitters = new Group();
    effects = new Group();
    emoicons = new Group();
    mobs = new Group();
    add(mobs);
    // hack to save bugged saves...
    boolean buggedSave = false;
    HashSet<Mob> filteredMobs = new HashSet<>();
    for (Mob mob : level.mobs) {
        if (level.cellValid(mob.getPos())) {
            filteredMobs.add(mob);
        } else {
            buggedSave = true;
        }
    }
    if (buggedSave) {
        EventCollector.logEvent(EventCollector.BUG, "bugged save", "mob.pos==-1");
    }
    level.mobs = filteredMobs;
    for (Mob mob : level.mobs) {
        if (Statistics.amuletObtained) {
            mob.beckon(Dungeon.hero.getPos());
        }
    }
    Dungeon.hero.updateSprite();
    add(emitters);
    add(effects);
    gases = new Group();
    add(gases);
    for (Blob blob : level.blobs.values()) {
        blob.emitter = null;
        addBlobSprite(blob);
    }
    fog = new FogOfWar(level.getWidth(), level.getHeight());
    if (level.noFogOfWar()) {
        level.reveal();
    }
    if (roofTiles != null) {
        add(roofTiles);
    }
    fog.updateVisibility(Dungeon.visible, level.visited, level.mapped);
    add(fog);
    brightness(PixelDungeon.brightness());
    spells = new Group();
    add(spells);
    statuses = new Group();
    add(statuses);
    add(emoicons);
    add(new HealthIndicator());
    add(cellSelector = new CellSelector(baseTiles));
    Dungeon.hero.updateLook();
    sb = new StatusPane(Dungeon.hero, level);
    sb.camera = uiCamera;
    sb.setSize(uiCamera.width, 0);
    add(sb);
    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;
    attack.setPos(uiCamera.width - attack.width(), toolbar.top() - attack.height());
    add(attack);
    resume = new ResumeIndicator();
    resume.camera = uiCamera;
    resume.setPos(uiCamera.width - resume.width(), attack.top() - resume.height());
    add(resume);
    log = new GameLog();
    log.camera = uiCamera;
    log.setRect(0, toolbar.top(), attack.left(), 0);
    add(log);
    if (Dungeon.depth < Statistics.deepestFloor) {
        GLog.i(TXT_WELCOME_BACK, Dungeon.depth);
    } else {
        GLog.i(TXT_WELCOME, Dungeon.depth);
        Sample.INSTANCE.play(Assets.SND_DESCEND);
    }
    switch(level.getFeeling()) {
        case CHASM:
            GLog.w(TXT_CHASM);
            break;
        case WATER:
            GLog.w(TXT_WATER);
            break;
        case GRASS:
            GLog.w(TXT_GRASS);
            break;
        default:
    }
    if (level instanceof RegularLevel && ((RegularLevel) level).secretDoors > Random.IntRange(3, 4)) {
        GLog.w(TXT_SECRETS);
    }
    if (Dungeon.nightMode && !Dungeon.bossLevel()) {
        GLog.w(TXT_NIGHT_MODE);
    }
    busy = new BusyIndicator();
    busy.camera = uiCamera;
    busy.x = 1;
    busy.y = sb.bottom() + 18;
    add(busy);
    sceneCreated = true;
    switch(InterlevelScene.mode) {
        case RESURRECT:
            WandOfBlink.appear(Dungeon.hero, level.entrance);
            new Flare(8, 32).color(0xFFFF66, true).show(Dungeon.hero.getHeroSprite(), 2f);
            break;
        case RETURN:
            WandOfBlink.appear(Dungeon.hero, Dungeon.hero.getPos());
            break;
        case FALL:
            Chasm.heroLand();
            break;
        case DESCEND:
            DungeonGenerator.showStory(level);
            if (Dungeon.hero.isAlive() && !level.isSafe() && Dungeon.depth != 22 && Dungeon.depth != 1) {
                Badges.validateNoKilling();
            }
            break;
        default:
    }
    Camera.main.target = Dungeon.hero.getHeroSprite();
    level.activateScripts();
    fadeIn();
    Dungeon.observe();
}
Also used : Group(com.watabou.noosa.Group) StatusPane(com.watabou.pixeldungeon.ui.StatusPane) LevelObject(com.nyrds.pixeldungeon.levels.objects.LevelObject) AttackIndicator(com.watabou.pixeldungeon.ui.AttackIndicator) BusyIndicator(com.watabou.pixeldungeon.ui.BusyIndicator) SkinnedBlock(com.watabou.noosa.SkinnedBlock) GameLog(com.watabou.pixeldungeon.ui.GameLog) HashSet(java.util.HashSet) Toolbar(com.watabou.pixeldungeon.ui.Toolbar) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) FogOfWar(com.watabou.pixeldungeon.FogOfWar) Blob(com.watabou.pixeldungeon.actors.blobs.Blob) Flare(com.watabou.pixeldungeon.effects.Flare) ClassicDungeonTilemap(com.watabou.pixeldungeon.ClassicDungeonTilemap) Heap(com.watabou.pixeldungeon.items.Heap) ResumeIndicator(com.watabou.pixeldungeon.ui.ResumeIndicator) HealthIndicator(com.watabou.pixeldungeon.ui.HealthIndicator) Level(com.watabou.pixeldungeon.levels.Level) RegularLevel(com.watabou.pixeldungeon.levels.RegularLevel) CustomLayerTilemap(com.watabou.pixeldungeon.CustomLayerTilemap) RegularLevel(com.watabou.pixeldungeon.levels.RegularLevel)

Aggregations

LevelObject (com.nyrds.pixeldungeon.levels.objects.LevelObject)1 Group (com.watabou.noosa.Group)1 SkinnedBlock (com.watabou.noosa.SkinnedBlock)1 ClassicDungeonTilemap (com.watabou.pixeldungeon.ClassicDungeonTilemap)1 CustomLayerTilemap (com.watabou.pixeldungeon.CustomLayerTilemap)1 FogOfWar (com.watabou.pixeldungeon.FogOfWar)1 Blob (com.watabou.pixeldungeon.actors.blobs.Blob)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Flare (com.watabou.pixeldungeon.effects.Flare)1 Heap (com.watabou.pixeldungeon.items.Heap)1 Level (com.watabou.pixeldungeon.levels.Level)1 RegularLevel (com.watabou.pixeldungeon.levels.RegularLevel)1 AttackIndicator (com.watabou.pixeldungeon.ui.AttackIndicator)1 BusyIndicator (com.watabou.pixeldungeon.ui.BusyIndicator)1 GameLog (com.watabou.pixeldungeon.ui.GameLog)1 HealthIndicator (com.watabou.pixeldungeon.ui.HealthIndicator)1 ResumeIndicator (com.watabou.pixeldungeon.ui.ResumeIndicator)1 StatusPane (com.watabou.pixeldungeon.ui.StatusPane)1 Toolbar (com.watabou.pixeldungeon.ui.Toolbar)1 HashSet (java.util.HashSet)1