Search in sources :

Example 16 with SequenceAction

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

the class SpellUtil method spellCast.

public static boolean spellCast(final BaseScreen screen, final Context context, final Spell spell, final PartyMember caster, final PartyMember subject, final Direction dir, final int phase) {
    if (caster == null || spell == null || screen == null) {
        return false;
    }
    switch(spell) {
        case AWAKEN:
        case CURE:
        case HEAL:
        case RESURRECT:
            if (subject == null) {
                Ultima4.hud.add("Thou must indicate a target to cast the spell!");
                return false;
            }
            break;
        case DISPEL:
        case ICEBALL:
        case KILL:
        case SLEEP:
        case MAGICMISSILE:
        case FIREBALL:
        case ENERGY:
        case WINDS:
        case BLINK:
            if (dir == null) {
                Ultima4.hud.add("Thou must indicate a direction to cast the spell!");
                return false;
            }
            break;
        default:
            break;
    }
    if (caster.getPlayer().mp < spell.getMp()) {
        Ultima4.hud.add("Thou dost not have enough magic points!");
        return false;
    }
    Party party = context.getParty();
    if (party.getSaveGame().mixtures[spell.ordinal()] < 1) {
        Ultima4.hud.add("Thou dost not have the mixture prepared!");
        return false;
    }
    // subtract the mixture for even trying to cast the spell
    party.getSaveGame().mixtures[spell.ordinal()]--;
    if (context.getAura().getType() == AuraType.NEGATE) {
        Ultima4.hud.add("Spell is negated!");
        return false;
    }
    caster.adjustMagic(spell.getMp());
    SequenceAction seq = Actions.action(SequenceAction.class);
    seq.addAction(Actions.run(new PlaySoundAction(spell.getSound())));
    seq.addAction(Actions.delay(0.5f));
    seq.addAction(Actions.run(new Runnable() {

        @Override
        public void run() {
            switch(spell) {
                case AWAKEN:
                    spellAwaken(subject);
                    break;
                case CURE:
                    spellCure(subject);
                    break;
                case HEAL:
                    spellHeal(subject);
                    break;
                case RESURRECT:
                    spellRez(subject);
                    break;
                case DISPEL:
                    spellDispel(screen, context, caster, dir);
                    break;
                case ICEBALL:
                    spellIceball(screen, caster, dir);
                    break;
                case KILL:
                    spellKill(screen, caster, dir);
                    break;
                case MAGICMISSILE:
                    spellMMissle(screen, caster, dir);
                    break;
                case FIREBALL:
                    spellFireball(screen, caster, dir);
                    break;
                case ENERGY:
                    spellEnergyField(dir);
                    break;
                case WINDS:
                    spellWinds(screen, dir);
                    break;
                case BLINK:
                    spellBlink(screen, dir);
                    break;
                case GATE:
                    spellGate(screen, phase);
                    break;
                case JINX:
                    spellJinx(context);
                    break;
                case LIGHT:
                    spellLight();
                    break;
                case NEGATE:
                    spellNegate(context);
                    break;
                case OPEN:
                    spellOpen();
                    break;
                case PROTECTION:
                    spellProtect(context);
                    break;
                case QUICKNESS:
                    spellQuick(context);
                    break;
                case SLEEP:
                    spellSleep(screen, caster, dir);
                    break;
                case TREMOR:
                    spellTremor(screen, caster);
                    break;
                case UNDEAD:
                    spellUndead(screen, caster);
                    break;
                case VIEW:
                    spellView(screen, caster);
                    break;
                case XIT:
                    spellXit(screen, caster);
                    break;
                case YUP:
                    spellYup(screen, caster);
                    break;
                case ZDOWN:
                    spellZdown(screen, caster);
                    break;
                default:
                    break;
            }
        }
    }));
    screen.getStage().addAction(seq);
    return true;
}
Also used : Party(objects.Party) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Example 17 with SequenceAction

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

the class SpellUtil method useRageOfGod.

public static void useRageOfGod(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(2) == 0) {
                /* Deal maximum damage to creature */
                Utils.dealDamage(caster, cr, 0xFF);
            } else if (Utils.rand.nextInt(2) == 0) {
                /* Deal enough damage to creature to make it flee */
                if (cr.getHP() > 23) {
                    Utils.dealDamage(caster, cr, cr.getHP() - 23);
                }
            } else {
                // deal damage of half its hit points
                Utils.dealDamage(caster, cr, cr.getHP() / 2);
            }
            Actor d = new ExplosionLargeDrawable();
            d.setX(cr.currentPos.x - 32 * 3 + 16);
            d.setY(cr.currentPos.y - 32 * 3 + 16);
            d.addAction(Actions.sequence(Actions.delay(2f), Actions.removeActor()));
            seq.addAction(Actions.run(new PlaySoundAction(Sound.RAGE)));
            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 18 with SequenceAction

use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project Eidolons by IDemiurge.

the class AnimMultiplicator method createAndAddEmitterActions.

private Action createAndAddEmitterActions(EmitterActor actor, Integer angle, SPELL_ANIMS template) {
    Action action = new SequenceAction();
    actor.addAction(action);
    action.setTarget(actor);
    int range = getActive().getRange();
    // if ()
    range = getActive().getIntParam(G_PARAMS.RADIUS);
    switch(template) {
        case NOVA:
            return addRangeAndAngle(angle, range, actor);
    }
    return action;
}
Also used : Action(com.badlogic.gdx.scenes.scene2d.Action) MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Example 19 with SequenceAction

use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project Eidolons by IDemiurge.

the class AttackAnim method getAction.

/*
delayAction
scale
size - elongate
 */
// TODO back?
@Override
protected Action getAction() {
    // if (sequence != null)  //reset sometimes?
    // return sequence;
    sequence = new SequenceAction();
    int i = 0;
    float totalDuration = 0;
    for (ATK_ANIMS anim : anims) {
        for (float angle : anim.targetAngles) {
            List<Pair<MoveByAction, RotateByAction>> swings = new ArrayList<>();
            float duration = this.duration;
            if (duration <= 0) {
                duration = 1;
            }
            // anim.durations[i];
            totalDuration += duration;
            float x = anim.offsetsX[i];
            float y = anim.offsetsY[i];
            MoveByAction mainMove = null;
            try {
                mainMove = getMoveAction(x, y, duration);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
            if (mainMove == null) {
                return null;
            }
            RotateByAction mainRotate = getRotateAction(angle, duration);
            swings.add(new ImmutablePair<>(mainMove, mainRotate));
            swings.forEach(swing -> {
                sequence.addAction(new ParallelAction(swing.getKey(), swing.getValue()));
            });
            i++;
        }
    }
    setDuration(totalDuration);
    return sequence;
}
Also used : ParallelAction(com.badlogic.gdx.scenes.scene2d.actions.ParallelAction) RotateByAction(com.badlogic.gdx.scenes.scene2d.actions.RotateByAction) ArrayList(java.util.ArrayList) MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

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