Search in sources :

Example 11 with Drawable

use of objects.Drawable in project ultimate-java by pantinor.

the class GameScreen method endCombat.

@Override
public void endCombat(boolean isWon, BaseMap combatMap, boolean wounded) {
    mainGame.setScreen(this);
    if (currentEncounter != null) {
        Tile tile = context.getCurrentMap().getTile(currentEncounter.currentX, currentEncounter.currentY);
        if (isWon) {
            log("Victory!");
            if (!currentEncounter.getGood()) {
                context.getParty().adjustKarma(KarmaAction.KILLED_EVIL);
            }
            TileRule r = tile.getRule();
            /* add a chest, if the creature leaves one */
            if (!currentEncounter.getNochest() && (r == null || !r.has(TileAttrib.unwalkable))) {
                Tile ct = Ultima4.baseTileSet.getTileByName("chest");
                Drawable chest = new Drawable(context.getCurrentMap(), currentEncounter.currentX, currentEncounter.currentY, ct, Ultima4.standardAtlas);
                chest.setX(currentEncounter.currentPos.x);
                chest.setY(currentEncounter.currentPos.y);
                mapObjectsStage.addActor(chest);
            } else /* add a ship if you just defeated a pirate ship */
            if (currentEncounter.getTile() == CreatureType.pirate_ship) {
                Tile st = Ultima4.baseTileSet.getTileByName("ship");
                Drawable ship = new Drawable(context.getCurrentMap(), currentEncounter.currentX, currentEncounter.currentY, st, Ultima4.standardAtlas);
                ship.setX(currentEncounter.currentPos.x);
                ship.setY(currentEncounter.currentPos.y);
                mapObjectsStage.addActor(ship);
            }
        } else {
            if (context.getParty().didAnyoneFlee()) {
                log("Battle is lost!");
                /* minus points for fleeing from evil creatures */
                if (!currentEncounter.getGood()) {
                    // lose karma points here
                    if (!wounded) {
                        context.getParty().adjustKarma(KarmaAction.HEALTHY_FLED_EVIL);
                    }
                } else {
                    // get extra karma points
                    context.getParty().adjustKarma(KarmaAction.FLED_GOOD);
                }
            } else if (!context.getParty().isAnyoneAlive()) {
                partyDeath();
            }
        }
        context.getCurrentMap().removeCreature(currentEncounter);
        currentEncounter = null;
    }
}
Also used : Drawable(objects.Drawable) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Tile(objects.Tile)

Example 12 with Drawable

use of objects.Drawable in project ultimate-java by pantinor.

the class SpellUtil method spellTremor.

public static void spellTremor(BaseScreen screen, PartyMember caster) {
    if (screen.scType == ScreenType.COMBAT) {
        final CombatScreen combatScreen = (CombatScreen) screen;
        SequenceAction seq = Actions.action(SequenceAction.class);
        for (Creature cr : combatScreen.combatMap.getCreatures()) {
            /* creatures with over 192 hp are unaffected */
            if (cr.getHP() > 192) {
                seq.addAction(Actions.run(new PlaySoundAction(Sound.EVADE)));
                continue;
            } else {
                if (Utils.rand.nextInt(2) == 0) {
                    /* Deal maximum damage to creature */
                    Utils.dealDamage(caster, cr, 0xFF);
                    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)));
                } 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);
                        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)));
                    }
                } 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)

Aggregations

Drawable (objects.Drawable)12 Tile (objects.Tile)10 Creature (objects.Creature)8 TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)6 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)6 Actor (com.badlogic.gdx.scenes.scene2d.Actor)5 Vector3 (com.badlogic.gdx.math.Vector3)3 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)3 Portal (objects.Portal)3 PartyDeathException (util.PartyDeathException)3 BaseMap (objects.BaseMap)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1 Actions.removeActor (com.badlogic.gdx.scenes.scene2d.actions.Actions.removeActor)1 File (java.io.File)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 Party (objects.Party)1 PartyMember (objects.Party.PartyMember)1 ProjectileActor (objects.ProjectileActor)1