Search in sources :

Example 6 with Drawable

use of objects.Drawable 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)

Example 7 with Drawable

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

the class Utils method fireAt.

private static AttackResult fireAt(Context context, Stage stage, BaseMap combatMap, AttackVector target, boolean avatarAttack, int avatarX, int avatarY) throws PartyDeathException {
    AttackResult res = AttackResult.NONE;
    // check for ship
    Drawable ship = null;
    for (Actor a : stage.getActors()) {
        if (a instanceof Drawable) {
            Drawable d = (Drawable) a;
            if (d.getTile().getName().equals("ship") && d.getCx() == target.x && d.getCy() == target.y) {
                ship = d;
            }
        }
    }
    if (ship != null) {
        ship.damageShip(-1, 10);
        target.impactedDrawable = ship;
        return AttackResult.HIT;
    }
    if (avatarAttack) {
        Creature creature = null;
        for (Creature c : combatMap.getCreatures()) {
            if (c.currentX == target.x && c.currentY == target.y) {
                creature = c;
                break;
            }
        }
        if (creature == null) {
            return res;
        }
        if (rand.nextInt(4) == 0) {
            res = AttackResult.HIT;
            target.impactedCreature = creature;
        } else {
            res = AttackResult.MISS;
        }
    } else if (target.x == avatarX && target.y == avatarY) {
        if (context.getTransportContext() == TransportContext.SHIP) {
            context.damageShip(-1, 10);
        } else {
            context.getParty().damageParty(10, 25);
        }
        res = AttackResult.HIT;
    }
    return res;
}
Also used : Creature(objects.Creature) Actions.removeActor(com.badlogic.gdx.scenes.scene2d.actions.Actions.removeActor) ProjectileActor(objects.ProjectileActor) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Drawable(objects.Drawable)

Example 8 with Drawable

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

the class GameScreen method show.

@Override
public void show() {
    Gdx.input.setInputProcessor(new InputMultiplexer(this, stage));
    gameTimer.active = true;
    // load save game if initializing
    if (context == null) {
        context = new Context();
        SaveGame sg = new SaveGame();
        try {
            sg.read(PARTY_SAV_BASE_FILENAME);
        } catch (Exception e) {
            e.printStackTrace();
        }
        LordBritishConversation.saveGame = sg;
        Party party = new Party(sg);
        context.setParty(party);
        context.loadJournalEntries();
        // party.getMember(0).getPlayer().klass = ClassType.MAGE;
        // party.getMember(0).getPlayer().xp = 899;
        // party.getMember(0).getPlayer().hp = 999;
        // party.getMember(0).getPlayer().hpMax = 999;
        // party.getMember(0).getPlayer().intel = 99;
        // party.getMember(0).getPlayer().mp = 999;
        // sg.reagents = new int[]{90, 93, 94, 90, 90, 90, 90, 90};
        // for (Spell sp : Spell.values()) {
        // party.getSaveGame().mixtures[sp.ordinal()] = 99;
        // }
        // for (Virtue v : Virtue.values()) {
        // sg.karma[v.ordinal()] = 0;
        // }
        // 
        // party.join(NpcDefaults.Geoffrey.name());
        // party.join(NpcDefaults.Shamino.name());
        // party.join(NpcDefaults.Katrina.name());
        // party.join(NpcDefaults.Mariah.name());
        // party.join(NpcDefaults.Dupre.name());
        // party.join(NpcDefaults.Iolo.name());
        // party.join(NpcDefaults.Julia.name());
        // party.join(NpcDefaults.Jaana.name());
        // 
        // sg.food = 30000;
        // sg.gold = 999;
        // sg.keys = 20;
        // sg.gems = 15;
        // sg.moves = 2800;
        // sg.stones = 0xff;
        // sg.runes = 0xff;
        // sg.items = 0xff;
        // sg.sextants = 1;
        // party.getMember(0).getPlayer().status = StatusType.GOOD;
        // party.getMember(0).getPlayer().weapon = WeaponType.MAGICAXE;
        // party.getMember(0).getPlayer().armor = ArmorType.MYSTICROBE;
        // for (int i = 1; i < 16; i++) {
        // party.getSaveGame().weapons[i] = 2;
        // }
        // for (int i = 1; i < 8; i++) {
        // party.getSaveGame().armor[i] = 2;
        // }
        // mainAvatar = shipAnim;
        // sg.transport = 0x10;
        // sg.items |= Constants.Item.IRON_ORE.getLoc();
        // sg.items |= Constants.Item.RUNE_MOLD.getLoc();
        // sg.items |= Constants.Item.BOOK.getLoc();
        // load the surface world first
        loadNextMap(Maps.WORLD, sg.x, sg.y);
        // load the dungeon if save game starts in dungeon
        if (Maps.get(sg.location) != Maps.WORLD) {
            loadNextMap(Maps.get(sg.location), sg.x, sg.y, sg.x, sg.y, sg.dnglevel, Direction.getByValue(sg.orientation + 1), true);
        // loadNextMap(Maps.ABYSS, 0, 0, 5, 5, 0, Direction.SOUTH, true);
        // loadNextMap(Maps.DESTARD, 0, 0, 3, 5, 3, Direction.SOUTH, true);
        // loadNextMap(Maps.DELVE_SORROWS, 0, 0, 3, 19, 1, Direction.EAST, true);
        }
        for (Virtue v : Virtue.values()) {
            v.adjustProgress(sg.karma[v.ordinal()]);
        }
        party.setTransport(Ultima4.baseTileSet.getTileByIndex(sg.transport));
        switch(sg.transport) {
            case 31:
                mainAvatar = avatarAnim;
                break;
            case 16:
            case 17:
            case 18:
            case 19:
                mainAvatar = shipAnim;
                break;
            case 20:
            case 21:
                mainAvatar = horseAnim;
                break;
            case 24:
                mainAvatar = balloonAnim;
                break;
        }
        if (sg.balloonfound == 1 && context.getTransportContext() != TransportContext.BALLOON) {
            addBalloonActor(sg.balloonx, sg.balloony);
        }
        // load objects to surface stage
        for (int i = 0; i < 24; i++) {
            if (sg.objects_save_tileids[i] != 0 && sg.objects_save_x[i] != 0 && sg.objects_save_y[i] != 0) {
                Tile t = Ultima4.baseTileSet.getTileByIndex(sg.objects_save_tileids[i] & 0xff);
                Drawable d = new Drawable(Maps.WORLD.getMap(), sg.objects_save_x[i] & 0xff, sg.objects_save_y[i] & 0xff, t, Ultima4.standardAtlas);
                Vector3 v = getMapPixelCoords(sg.objects_save_x[i] & 0xff, sg.objects_save_y[i] & 0xff);
                d.setX(v.x);
                d.setY(v.y);
                mapObjectsStage.addActor(d);
            }
        }
        // load monsters to surface map
        for (int i = 0; i < 8; i++) {
            if (sg.monster_save_tileids[i] != 0 && sg.monster_save_x[i] != 0 && sg.monster_save_y[i] != 0) {
                Tile t = Ultima4.baseTileSet.getTileByIndex(sg.monster_save_tileids[i] & 0xff);
                Creature cr = Ultima4.creatures.getInstance(CreatureType.get(t.getName()), Ultima4.standardAtlas);
                cr.currentX = sg.monster_save_x[i] & 0xff;
                cr.currentY = sg.monster_save_y[i] & 0xff;
                cr.currentPos = getMapPixelCoords(cr.currentX, cr.currentY);
                Maps.WORLD.getMap().addCreature(cr);
            }
        }
    }
    context.getParty().addObserver(this);
}
Also used : InputMultiplexer(com.badlogic.gdx.InputMultiplexer) Party(objects.Party) Creature(objects.Creature) SaveGame(objects.SaveGame) Drawable(objects.Drawable) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Tile(objects.Tile) Vector3(com.badlogic.gdx.math.Vector3) PartyDeathException(util.PartyDeathException)

Example 9 with Drawable

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

the class GameScreen method board.

public void board(int x, int y) {
    if (context.getTransportContext() != TransportContext.FOOT) {
        log("Board: Can't!");
        return;
    }
    Tile tile = null;
    // check for ship
    Drawable ship = null;
    for (Actor a : mapObjectsStage.getActors()) {
        if (a instanceof Drawable) {
            Drawable d = (Drawable) a;
            if (d.getTile().getName().equals("ship") && d.getCx() == x && d.getCy() == y) {
                ship = d;
                tile = d.getTile();
            }
        }
    }
    // check for horse
    Creature horse = context.getCurrentMap().getCreatureAt(x, y);
    if (horse != null && (horse.getTile() == CreatureType.horse)) {
        tile = Ultima4.baseTileSet.getTileByName("horse");
    }
    // check for balloon
    Drawable balloon = null;
    for (Actor a : mapObjectsStage.getActors()) {
        if (a instanceof Drawable) {
            Drawable d = (Drawable) a;
            if (d.getTile().getName().equals("balloon") && d.getCx() == x && d.getCy() == y) {
                balloon = d;
                tile = d.getTile();
            }
        }
    }
    if (tile == null) {
        log("Board What?");
        return;
    }
    if (tile.getRule().has(TileAttrib.ship)) {
        log("Board Frigate!");
        if (context.getLastShip() != ship) {
            context.getParty().adjustShipHull(50);
        }
        context.setCurrentShip(ship);
        ship.remove();
        mainAvatar = shipAnim;
    } else if (tile.getRule().has(TileAttrib.horse)) {
        log("Mount Horse!");
        context.getCurrentMap().removeCreature(horse);
        mainAvatar = horseAnim;
    } else if (tile.getRule().has(TileAttrib.balloon)) {
        log("Board Balloon!");
        balloon.remove();
        mainAvatar = balloonAnim;
    } else {
        log("Board What?");
        return;
    }
    context.getParty().setTransport(tile);
}
Also used : Creature(objects.Creature) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Drawable(objects.Drawable) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Tile(objects.Tile)

Example 10 with Drawable

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

the class GameScreen method addBalloonActor.

public void addBalloonActor(int x, int y) {
    if (Ultima4.balloon != null) {
        Ultima4.balloon.remove();
    }
    Tile st = Ultima4.baseTileSet.getTileByName("balloon");
    Ultima4.balloon = new Drawable(Maps.WORLD.getMap(), x, y, st, Ultima4.standardAtlas);
    Vector3 bpos = getMapPixelCoords(x, y);
    Ultima4.balloon.setX(bpos.x);
    Ultima4.balloon.setY(bpos.y);
    mapObjectsStage.addActor(Ultima4.balloon);
}
Also used : Drawable(objects.Drawable) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Tile(objects.Tile) Vector3(com.badlogic.gdx.math.Vector3)

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