Search in sources :

Example 1 with SequenceAction

use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project skin-composer by raeleus.

the class RootTable method display.

private void display(final String text) {
    SequenceAction sequenceAction = new SequenceAction();
    if (statusLabel.isVisible()) {
        statusLabel.clearActions();
        AlphaAction alphaAction = new AlphaAction();
        alphaAction.setAlpha(0.0f);
        alphaAction.setDuration(.25f);
        sequenceAction.addAction(alphaAction);
        RunnableAction runnableAction = new RunnableAction();
        runnableAction.setRunnable(() -> {
            statusLabel.setText(text);
        });
        sequenceAction.addAction(runnableAction);
        alphaAction = new AlphaAction();
        alphaAction.setAlpha(1.0f);
        alphaAction.setDuration(.25f);
        sequenceAction.addAction(alphaAction);
        DelayAction delayAction = new DelayAction();
        delayAction.setDuration(3.0f);
        sequenceAction.addAction(delayAction);
        alphaAction = new AlphaAction();
        alphaAction.setAlpha(0.0f);
        alphaAction.setDuration(1.5f);
        sequenceAction.addAction(alphaAction);
        VisibleAction visibleAction = new VisibleAction();
        visibleAction.setVisible(false);
        sequenceAction.addAction(visibleAction);
    } else {
        statusLabel.setText(text);
        statusLabel.clearActions();
        statusLabel.setVisible(true);
        AlphaAction alphaAction = new AlphaAction();
        alphaAction.setAlpha(1.0f);
        alphaAction.setDuration(.5f);
        sequenceAction.addAction(alphaAction);
        DelayAction delayAction = new DelayAction();
        delayAction.setDuration(3.0f);
        sequenceAction.addAction(delayAction);
        alphaAction = new AlphaAction();
        alphaAction.setAlpha(0.0f);
        alphaAction.setDuration(1.5f);
        sequenceAction.addAction(alphaAction);
        VisibleAction visibleAction = new VisibleAction();
        visibleAction.setVisible(false);
        sequenceAction.addAction(visibleAction);
    }
    statusLabel.addAction(sequenceAction);
}
Also used : RunnableAction(com.badlogic.gdx.scenes.scene2d.actions.RunnableAction) DelayAction(com.badlogic.gdx.scenes.scene2d.actions.DelayAction) AlphaAction(com.badlogic.gdx.scenes.scene2d.actions.AlphaAction) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction) VisibleAction(com.badlogic.gdx.scenes.scene2d.actions.VisibleAction)

Example 2 with SequenceAction

use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project ultimate-java by pantinor.

the class CombatScreen method holeUp.

public static void holeUp(Maps contextMap, final int x, final int y, final BaseScreen rs, final Context context, CreatureSet cs, final TextureAtlas sa, boolean inn) {
    Ultima4.hud.add("Hole up & Camp!");
    if (!inn && context.getCurrentMap().getCity() != null) {
        Ultima4.hud.add("Only outside or in the dungeon!");
        return;
    }
    if (context.getTransportContext() != TransportContext.FOOT) {
        Ultima4.hud.add("Only on foot!");
        return;
    }
    // make sure everyone's asleep
    for (int i = 0; i < context.getParty().getMembers().size(); i++) {
        context.getParty().getMember(i).putToSleep();
    }
    Ultima4.hud.add("Resting");
    final Maps campMap;
    TiledMap tmap;
    if (contextMap == Maps.WORLD) {
        campMap = Maps.CAMP_CON;
    } else if (inn) {
        campMap = Maps.INN_CON;
    } else {
        campMap = Maps.CAMP_DNG;
    }
    tmap = new UltimaTiledMapLoader(campMap, sa, campMap.getMap().getWidth(), campMap.getMap().getHeight(), tilePixelWidth, tilePixelHeight).load();
    context.setCurrentTiledMap(tmap);
    final CombatScreen sc = new CombatScreen(rs, context, contextMap, campMap.getMap(), tmap, null, cs, sa);
    mainGame.setScreen(sc);
    final int CAMP_HEAL_INTERVAL = 5;
    Random rand = new XORShiftRandom();
    SequenceAction seq = Actions.action(SequenceAction.class);
    for (int i = 0; i < CAMP_HEAL_INTERVAL; i++) {
        seq.addAction(Actions.delay(1f));
        seq.addAction(Actions.run(new Runnable() {

            public void run() {
                Ultima4.hud.append(" .");
            }
        }));
    }
    if (!inn && rand.nextInt(8) == 0) {
        seq.addAction(Actions.run(new Runnable() {

            public void run() {
                Ultima4.hud.add("Ambushed!");
                sc.setAmbushingMonsters(rs, x, y, sa);
            }
        }));
    } else {
        seq.addAction(Actions.run(new Runnable() {

            @Override
            public void run() {
                for (int i = 0; i < context.getParty().getMembers().size(); i++) {
                    context.getParty().getMember(i).wakeUp();
                }
                /* Make sure we've waited long enough for camping to be effective */
                boolean healed = false;
                if (((context.getParty().getSaveGame().moves / CAMP_HEAL_INTERVAL) >= 0x10000) || (((context.getParty().getSaveGame().moves / CAMP_HEAL_INTERVAL) & 0xffff) != context.getParty().getSaveGame().lastcamp)) {
                    for (int i = 0; i < context.getParty().getMembers().size(); i++) {
                        PartyMember m = context.getParty().getMember(i);
                        m.getPlayer().mp = m.getPlayer().getMaxMp();
                        if ((m.getPlayer().hp < m.getPlayer().hpMax) && m.heal(HealType.CAMPHEAL)) {
                            healed = true;
                        }
                    }
                }
                Ultima4.hud.add(healed ? "Party Healed!" : "No effect.");
                context.getParty().getSaveGame().lastcamp = (context.getParty().getSaveGame().moves / 5) & 0xffff;
                sc.end();
            }
        }));
        if (inn && contextMap == Maps.SKARABRAE && rand.nextInt(3) == 0) {
            // show isaac
            for (Person p : context.getCurrentMap().getCity().getPeople()) {
                if (p.getId() == 10) {
                    p.setRemovedFromMap(false);
                    p.setStart_x(27);
                    p.setX(27);
                    p.setStart_y(12);
                    p.setY(12);
                    p.setMovement(ObjectMovementBehavior.WANDER);
                }
            }
        }
    }
    sc.getStage().addAction(seq);
}
Also used : Random(java.util.Random) XORShiftRandom(util.XORShiftRandom) PartyMember(objects.Party.PartyMember) UltimaTiledMapLoader(util.UltimaTiledMapLoader) XORShiftRandom(util.XORShiftRandom) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap) Person(objects.Person) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Example 3 with SequenceAction

use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project ultimate-java by pantinor.

the class SpellUtil method spellUndead.

public static void spellUndead(BaseScreen screen, PartyMember caster) {
    if (screen.scType == ScreenType.COMBAT) {
        SequenceAction seq = Actions.action(SequenceAction.class);
        final CombatScreen combatScreen = (CombatScreen) screen;
        int level = caster.getPlayer().getLevel();
        // from the AD&D dungeon masters guide page 75 :)
        boolean turn = Utils.rand.nextInt(100) >= 50;
        if (level > 1) {
            turn = Utils.rand.nextInt(100) >= 35;
        }
        if (level > 2) {
            turn = Utils.rand.nextInt(100) >= 20;
        }
        if (level > 3) {
            turn = true;
        }
        for (Creature cr : combatScreen.combatMap.getCreatures()) {
            if (cr.getUndead() && turn) {
                Tile tile = Ultima4.baseTileSet.getTileByName("hit_flash");
                Drawable d = new Drawable(combatScreen.combatMap, cr.currentX, cr.currentY, tile, Ultima4.standardAtlas);
                d.setX(cr.currentPos.x);
                d.setY(cr.currentPos.y);
                d.addAction(Actions.sequence(Actions.delay(.4f), Actions.fadeOut(.2f), Actions.removeActor()));
                seq.addAction(Actions.run(new AddActorAction(combatScreen.getStage(), d)));
                seq.addAction(Actions.run(new PlaySoundAction(Sound.NPC_STRUCK)));
                Utils.dealDamage(caster, cr, 23);
            } else {
                seq.addAction(Actions.run(new PlaySoundAction(Sound.EVADE)));
            }
            if (cr.getDamageStatus() == CreatureStatus.DEAD) {
                seq.addAction(Actions.run(combatScreen.new RemoveCreatureAction(cr)));
            }
        }
        seq.addAction(Actions.run(new Runnable() {

            @Override
            public void run() {
                combatScreen.finishPlayerTurn();
            }
        }));
        combatScreen.getStage().addAction(seq);
    }
}
Also used : Creature(objects.Creature) Drawable(objects.Drawable) Tile(objects.Tile) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Example 4 with SequenceAction

use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project ultimate-java by pantinor.

the class SpellUtil method useMaskOfMinax.

public static void useMaskOfMinax(BaseScreen screen, PartyMember caster) {
    if (screen.scType == ScreenType.COMBAT) {
        final CombatScreen combatScreen = (CombatScreen) screen;
        final SequenceAction seq = Actions.action(SequenceAction.class);
        for (Creature cr : combatScreen.combatMap.getCreatures()) {
            if (Utils.rand.nextInt(3) == 0) {
                /* Deal maximum damage to creature */
                Utils.dealDamage(caster, cr, 0xFF);
            } else {
                if (cr.getHP() > 23) {
                    Utils.dealDamage(caster, cr, cr.getHP() * (3 / 4));
                } else {
                    Utils.dealDamage(caster, cr, 15);
                }
            }
            Actor d = new CloudDrawable();
            d.setX(cr.currentPos.x - 16);
            d.setY(cr.currentPos.y - 16);
            d.addAction(Actions.sequence(Actions.delay(2f), Actions.removeActor()));
            seq.addAction(Actions.run(new PlaySoundAction(Sound.SPIRITS)));
            seq.addAction(Actions.run(new AddActorAction(combatScreen.getStage(), d)));
            seq.addAction(Actions.run(new PlaySoundAction(Sound.NPC_STRUCK)));
            if (cr.getDamageStatus() == CreatureStatus.DEAD) {
                seq.addAction(Actions.run(combatScreen.new RemoveCreatureAction(cr)));
            }
        }
        seq.addAction(Actions.run(new Runnable() {

            @Override
            public void run() {
                combatScreen.finishPlayerTurn();
            }
        }));
        combatScreen.getStage().addAction(seq);
    } else {
        Sounds.play(Sound.ERROR);
    }
}
Also used : Creature(objects.Creature) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Example 5 with SequenceAction

use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project ultimate-java by pantinor.

the class SpellUtil method destoryAllCreatures.

/**
 * Used with skull of mondain on world map
 */
public static void destoryAllCreatures(BaseScreen screen, PartyMember caster) {
    if (screen.scType == ScreenType.MAIN) {
        final GameScreen gameScreen = (GameScreen) screen;
        SequenceAction seq = Actions.action(SequenceAction.class);
        for (final Creature cr : screen.context.getCurrentMap().getCreatures()) {
            /* Deal maximum damage to creature */
            Utils.dealDamage(caster, cr, 0xFF);
            Tile tile = Ultima4.baseTileSet.getTileByName("hit_flash");
            Drawable d = new Drawable(screen.context.getCurrentMap(), cr.currentX, cr.currentY, tile, Ultima4.standardAtlas);
            d.setX(cr.currentPos.x);
            d.setY(cr.currentPos.y);
            d.addAction(Actions.sequence(Actions.delay(.4f), Actions.fadeOut(.2f), Actions.removeActor()));
            seq.addAction(Actions.run(new AddActorAction(gameScreen.getStage(), d)));
            seq.addAction(Actions.run(new PlaySoundAction(Sound.NPC_STRUCK)));
            seq.addAction(Actions.run(new Runnable() {

                @Override
                public void run() {
                    screen.context.getCurrentMap().getCreatures().remove(cr);
                }
            }));
        }
        gameScreen.getStage().addAction(seq);
    }
}
Also used : Creature(objects.Creature) Drawable(objects.Drawable) Tile(objects.Tile) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Aggregations

SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)19 Creature (objects.Creature)6 Actor (com.badlogic.gdx.scenes.scene2d.Actor)4 Action (com.badlogic.gdx.scenes.scene2d.Action)3 AlphaAction (com.badlogic.gdx.scenes.scene2d.actions.AlphaAction)3 DelayAction (com.badlogic.gdx.scenes.scene2d.actions.DelayAction)3 RunnableAction (com.badlogic.gdx.scenes.scene2d.actions.RunnableAction)3 Drawable (objects.Drawable)3 Tile (objects.Tile)3 Stage (com.badlogic.gdx.scenes.scene2d.Stage)2 MoveByAction (com.badlogic.gdx.scenes.scene2d.actions.MoveByAction)2 VisibleAction (com.badlogic.gdx.scenes.scene2d.actions.VisibleAction)2 Party (objects.Party)2 PartyMember (objects.Party.PartyMember)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)1 ParallelAction (com.badlogic.gdx.scenes.scene2d.actions.ParallelAction)1 RemoveActorAction (com.badlogic.gdx.scenes.scene2d.actions.RemoveActorAction)1 RotateByAction (com.badlogic.gdx.scenes.scene2d.actions.RotateByAction)1 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)1