Search in sources :

Example 1 with Group

use of com.watabou.noosa.Group in project pixel-dungeon by watabou.

the class GameScene method create.

@Override
public void create() {
    Music.INSTANCE.play(Assets.TUNE, true);
    Music.INSTANCE.volume(1f);
    PixelDungeon.lastClass(Dungeon.hero.heroClass.ordinal());
    super.create();
    Camera.main.zoom(defaultZoom + PixelDungeon.zoom());
    scene = this;
    terrain = new Group();
    add(terrain);
    water = new SkinnedBlock(Level.WIDTH * DungeonTilemap.SIZE, Level.HEIGHT * DungeonTilemap.SIZE, Dungeon.level.waterTex());
    terrain.add(water);
    ripples = new Group();
    terrain.add(ripples);
    tiles = new DungeonTilemap();
    terrain.add(tiles);
    Dungeon.level.addVisuals(this);
    plants = new Group();
    add(plants);
    int size = Dungeon.level.plants.size();
    for (int i = 0; i < size; i++) {
        addPlantSprite(Dungeon.level.plants.valueAt(i));
    }
    heaps = new Group();
    add(heaps);
    size = Dungeon.level.heaps.size();
    for (int i = 0; i < size; i++) {
        addHeapSprite(Dungeon.level.heaps.valueAt(i));
    }
    emitters = new Group();
    effects = 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);
        }
    }
    add(emitters);
    add(effects);
    gases = new Group();
    add(gases);
    for (Blob blob : Dungeon.level.blobs.values()) {
        blob.emitter = null;
        addBlobSprite(blob);
    }
    fog = new FogOfWar(Level.WIDTH, Level.HEIGHT);
    fog.updateVisibility(Dungeon.visible, Dungeon.level.visited, Dungeon.level.mapped);
    add(fog);
    brightness(PixelDungeon.brightness());
    spells = new Group();
    add(spells);
    statuses = new Group();
    add(statuses);
    add(emoicons);
    hero = new HeroSprite();
    hero.place(Dungeon.hero.pos);
    hero.updateArmor();
    mobs.add(hero);
    add(new HealthIndicator());
    add(cellSelector = new CellSelector(tiles));
    StatusPane sb = new StatusPane();
    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);
    AttackIndicator attack = new AttackIndicator();
    attack.camera = uiCamera;
    attack.setPos(uiCamera.width - attack.width(), toolbar.top() - attack.height());
    add(attack);
    log = new GameLog();
    log.camera = uiCamera;
    log.setRect(0, toolbar.top(), attack.left(), 0);
    add(log);
    busy = new BusyIndicator();
    busy.camera = uiCamera;
    busy.x = 1;
    busy.y = sb.bottom() + 1;
    add(busy);
    switch(InterlevelScene.mode) {
        case RESURRECT:
            WandOfBlink.appear(Dungeon.hero, Dungeon.level.entrance);
            new Flare(8, 32).color(0xFFFF66, true).show(hero, 2f);
            break;
        case RETURN:
            WandOfBlink.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_METROPOLIS);
                    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 {
                Dungeon.level.drop(item, pos);
            }
        }
        Dungeon.droppedItems.remove(Dungeon.depth);
    }
    Camera.main.target = hero;
    if (InterlevelScene.mode != InterlevelScene.Mode.NONE) {
        if (Dungeon.depth < Statistics.deepestFloor) {
            GLog.h(TXT_WELCOME_BACK, Dungeon.depth);
        } else {
            GLog.h(TXT_WELCOME, Dungeon.depth);
            Sample.INSTANCE.play(Assets.SND_DESCEND);
        }
        switch(Dungeon.level.feeling) {
            case CHASM:
                GLog.w(TXT_CHASM);
                break;
            case WATER:
                GLog.w(TXT_WATER);
                break;
            case GRASS:
                GLog.w(TXT_GRASS);
                break;
            default:
        }
        if (Dungeon.level instanceof RegularLevel && ((RegularLevel) Dungeon.level).secretDoors > Random.IntRange(3, 4)) {
            GLog.w(TXT_SECRETS);
        }
        if (Dungeon.nightMode && !Dungeon.bossLevel()) {
            GLog.w(TXT_NIGHT_MODE);
        }
        InterlevelScene.mode = InterlevelScene.Mode.NONE;
        fadeIn();
    }
}
Also used : Group(com.watabou.noosa.Group) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) FogOfWar(com.watabou.pixeldungeon.FogOfWar) Blob(com.watabou.pixeldungeon.actors.blobs.Blob) StatusPane(com.watabou.pixeldungeon.ui.StatusPane) Flare(com.watabou.pixeldungeon.effects.Flare) Potion(com.watabou.pixeldungeon.items.potions.Potion) AttackIndicator(com.watabou.pixeldungeon.ui.AttackIndicator) DungeonTilemap(com.watabou.pixeldungeon.DungeonTilemap) Item(com.watabou.pixeldungeon.items.Item) Plant(com.watabou.pixeldungeon.plants.Plant) HealthIndicator(com.watabou.pixeldungeon.ui.HealthIndicator) BusyIndicator(com.watabou.pixeldungeon.ui.BusyIndicator) SkinnedBlock(com.watabou.noosa.SkinnedBlock) HeroSprite(com.watabou.pixeldungeon.sprites.HeroSprite) GameLog(com.watabou.pixeldungeon.ui.GameLog) Toolbar(com.watabou.pixeldungeon.ui.Toolbar) RegularLevel(com.watabou.pixeldungeon.levels.RegularLevel)

Example 2 with Group

use of com.watabou.noosa.Group in project pixel-dungeon by watabou.

the class StartScene method create.

@Override
public void create() {
    super.create();
    Badges.loadGlobal();
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    float width, height;
    if (PixelDungeon.landscape()) {
        width = WIDTH_L;
        height = HEIGHT_L;
    } else {
        width = WIDTH_P;
        height = HEIGHT_P;
    }
    float left = (w - width) / 2;
    float top = (h - height) / 2;
    float bottom = h - top;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Image title = BannerSprites.get(Type.SELECT_YOUR_HERO);
    title.x = align((w - title.width()) / 2);
    title.y = align(top);
    add(title);
    buttonX = left;
    buttonY = bottom - BUTTON_HEIGHT;
    btnNewGame = new GameButton(TXT_NEW) {

        @Override
        protected void onClick() {
            if (GamesInProgress.check(curClass) != null) {
                StartScene.this.add(new WndOptions(TXT_REALLY, TXT_WARNING, TXT_YES, TXT_NO) {

                    @Override
                    protected void onSelect(int index) {
                        if (index == 0) {
                            startNewGame();
                        }
                    }
                });
            } else {
                startNewGame();
            }
        }
    };
    add(btnNewGame);
    btnLoad = new GameButton(TXT_LOAD) {

        @Override
        protected void onClick() {
            InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
            Game.switchScene(InterlevelScene.class);
        }
    };
    add(btnLoad);
    float centralHeight = buttonY - title.y - title.height();
    HeroClass[] classes = { HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS };
    for (HeroClass cl : classes) {
        ClassShield shield = new ClassShield(cl);
        shields.put(cl, shield);
        add(shield);
    }
    if (PixelDungeon.landscape()) {
        float shieldW = width / 4;
        float shieldH = Math.min(centralHeight, shieldW);
        top = title.y + title.height + (centralHeight - shieldH) / 2;
        for (int i = 0; i < classes.length; i++) {
            ClassShield shield = shields.get(classes[i]);
            shield.setRect(left + i * shieldW, top, shieldW, shieldH);
        }
        ChallengeButton challenge = new ChallengeButton();
        challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
        add(challenge);
    } else {
        float shieldW = width / 2;
        float shieldH = Math.min(centralHeight / 2, shieldW * 1.2f);
        top = title.y + title.height() + centralHeight / 2 - shieldH;
        for (int i = 0; i < classes.length; i++) {
            ClassShield shield = shields.get(classes[i]);
            shield.setRect(left + (i % 2) * shieldW, top + (i / 2) * shieldH, shieldW, shieldH);
        }
        ChallengeButton challenge = new ChallengeButton();
        challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
        add(challenge);
    }
    unlock = new Group();
    add(unlock);
    if (!(huntressUnlocked = Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_3))) {
        BitmapTextMultiline text = PixelScene.createMultiline(TXT_UNLOCK, 9);
        text.maxWidth = (int) width;
        text.measure();
        float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.height()) / 2;
        for (BitmapText line : text.new LineSplitter().split()) {
            line.measure();
            line.hardlight(0xFFFF00);
            line.x = PixelScene.align(w / 2 - line.width() / 2);
            line.y = PixelScene.align(pos);
            unlock.add(line);
            pos += line.height();
        }
    }
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    curClass = null;
    updateClass(HeroClass.values()[PixelDungeon.lastClass()]);
    fadeIn();
    Badges.loadingListener = new Callback() {

        @Override
        public void call() {
            if (Game.scene() == StartScene.this) {
                PixelDungeon.switchNoFade(StartScene.class);
            }
        }
    };
}
Also used : WndOptions(com.watabou.pixeldungeon.windows.WndOptions) Group(com.watabou.noosa.Group) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Image(com.watabou.noosa.Image) BitmapTextMultiline(com.watabou.noosa.BitmapTextMultiline) Callback(com.watabou.utils.Callback) Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass)

Example 3 with Group

use of com.watabou.noosa.Group in project pixel-dungeon by watabou.

the class Wound method hit.

public static void hit(int pos, float angle) {
    Group parent = Dungeon.hero.sprite.parent;
    Wound w = (Wound) parent.recycle(Wound.class);
    parent.bringToFront(w);
    w.reset(pos);
    w.angle = angle;
}
Also used : Group(com.watabou.noosa.Group)

Example 4 with Group

use of com.watabou.noosa.Group in project pixel-dungeon by watabou.

the class SurfaceScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.HAPPY, true);
    Music.INSTANCE.volume(1f);
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    Archs archs = new Archs();
    archs.reversed = true;
    archs.setSize(w, h);
    add(archs);
    float vx = align((w - SKY_WIDTH) / 2);
    float vy = align((h - SKY_HEIGHT - BUTTON_HEIGHT) / 2);
    Point s = Camera.main.cameraToScreen(vx, vy);
    viewport = new Camera(s.x, s.y, SKY_WIDTH, SKY_HEIGHT, defaultZoom);
    Camera.add(viewport);
    Group window = new Group();
    window.camera = viewport;
    add(window);
    boolean dayTime = !Dungeon.nightMode;
    Sky sky = new Sky(dayTime);
    sky.scale.set(SKY_WIDTH, SKY_HEIGHT);
    window.add(sky);
    if (!dayTime) {
        for (int i = 0; i < NSTARS; i++) {
            float size = Random.Float();
            ColorBlock star = new ColorBlock(size, size, 0xFFFFFFFF);
            star.x = Random.Float(SKY_WIDTH) - size / 2;
            star.y = Random.Float(SKY_HEIGHT) - size / 2;
            star.am = size * (1 - star.y / SKY_HEIGHT);
            window.add(star);
        }
    }
    float range = SKY_HEIGHT * 2 / 3;
    for (int i = 0; i < NCLOUDS; i++) {
        Cloud cloud = new Cloud((NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float(range / NCLOUDS), dayTime);
        window.add(cloud);
    }
    int nPatches = (int) (sky.width() / GrassPatch.WIDTH + 1);
    for (int i = 0; i < nPatches * 4; i++) {
        GrassPatch patch = new GrassPatch((i - 0.75f) * GrassPatch.WIDTH / 4, SKY_HEIGHT + 1, dayTime);
        patch.brightness(dayTime ? 0.7f : 0.4f);
        window.add(patch);
    }
    Avatar a = new Avatar(Dungeon.hero.heroClass);
    a.x = PixelScene.align((SKY_WIDTH - a.width) / 2);
    a.y = SKY_HEIGHT - a.height;
    window.add(a);
    final Pet pet = new Pet();
    pet.rm = pet.gm = pet.bm = 1.2f;
    pet.x = SKY_WIDTH / 2 + 2;
    pet.y = SKY_HEIGHT - pet.height;
    window.add(pet);
    window.add(new TouchArea(sky) {

        protected void onClick(Touch touch) {
            pet.jump();
        }

        ;
    });
    for (int i = 0; i < nPatches; i++) {
        GrassPatch patch = new GrassPatch((i - 0.5f) * GrassPatch.WIDTH, SKY_HEIGHT, dayTime);
        patch.brightness(dayTime ? 1.0f : 0.8f);
        window.add(patch);
    }
    Image frame = new Image(Assets.SURFACE);
    frame.frame(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
    frame.x = vx - FRAME_MARGIN_X;
    frame.y = vy - FRAME_MARGIN_TOP;
    add(frame);
    if (dayTime) {
        a.brightness(1.2f);
        pet.brightness(1.2f);
    } else {
        frame.hardlight(0xDDEEFF);
    }
    RedButton gameOver = new RedButton("Game Over") {

        protected void onClick() {
            Game.switchScene(TitleScene.class);
        }
    };
    gameOver.setSize(SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT);
    gameOver.setPos(frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4);
    add(gameOver);
    Badges.validateHappyEnd();
    fadeIn();
}
Also used : Group(com.watabou.noosa.Group) Point(com.watabou.utils.Point) Touch(com.watabou.input.Touchscreen.Touch) Image(com.watabou.noosa.Image) Point(com.watabou.utils.Point) Archs(com.watabou.pixeldungeon.ui.Archs) TouchArea(com.watabou.noosa.TouchArea) Camera(com.watabou.noosa.Camera) RedButton(com.watabou.pixeldungeon.ui.RedButton) ColorBlock(com.watabou.noosa.ColorBlock)

Example 5 with Group

use of com.watabou.noosa.Group in project pixel-dungeon by watabou.

the class Fireball method createChildren.

@Override
protected void createChildren() {
    sparks = new Group();
    add(sparks);
    bLight = new Image(Assets.FIREBALL);
    bLight.frame(BLIGHT);
    bLight.origin.set(bLight.width / 2);
    bLight.angularSpeed = -90;
    add(bLight);
    emitter = new Emitter();
    emitter.pour(new Emitter.Factory() {

        @Override
        public void emit(Emitter emitter, int index, float x, float y) {
            Flame p = (Flame) emitter.recycle(Flame.class);
            p.reset();
            p.x = x - p.width / 2;
            p.y = y - p.height / 2;
        }
    }, 0.1f);
    add(emitter);
    fLight = new Image(Assets.FIREBALL);
    fLight.frame(FLIGHT);
    fLight.origin.set(fLight.width / 2);
    fLight.angularSpeed = 360;
    add(fLight);
    bLight.texture.filter(Texture.LINEAR, Texture.LINEAR);
}
Also used : Group(com.watabou.noosa.Group) Emitter(com.watabou.noosa.particles.Emitter) Image(com.watabou.noosa.Image)

Aggregations

Group (com.watabou.noosa.Group)5 Image (com.watabou.noosa.Image)3 Archs (com.watabou.pixeldungeon.ui.Archs)2 Touch (com.watabou.input.Touchscreen.Touch)1 BitmapText (com.watabou.noosa.BitmapText)1 BitmapTextMultiline (com.watabou.noosa.BitmapTextMultiline)1 Camera (com.watabou.noosa.Camera)1 ColorBlock (com.watabou.noosa.ColorBlock)1 SkinnedBlock (com.watabou.noosa.SkinnedBlock)1 TouchArea (com.watabou.noosa.TouchArea)1 Emitter (com.watabou.noosa.particles.Emitter)1 DungeonTilemap (com.watabou.pixeldungeon.DungeonTilemap)1 FogOfWar (com.watabou.pixeldungeon.FogOfWar)1 Blob (com.watabou.pixeldungeon.actors.blobs.Blob)1 HeroClass (com.watabou.pixeldungeon.actors.hero.HeroClass)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Flare (com.watabou.pixeldungeon.effects.Flare)1 Item (com.watabou.pixeldungeon.items.Item)1 Potion (com.watabou.pixeldungeon.items.potions.Potion)1 RegularLevel (com.watabou.pixeldungeon.levels.RegularLevel)1