Search in sources :

Example 1 with UltimaTiledMapLoader

use of util.UltimaTiledMapLoader in project ultimate-java by pantinor.

the class TestMain method create.

@Override
public void create() {
    try {
        Ultima4 ult = new Ultima4();
        ult.create();
        Context context = new Context();
        SaveGame sg = new SaveGame();
        try {
            sg.read(Constants.PARTY_SAV_BASE_FILENAME);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Party party = new Party(sg);
        context.setParty(party);
        context.setCurrentMap(Maps.WORLD.getMap());
        sg.players[0].hpMax = 700;
        party.join(NpcDefaults.Geoffrey.name());
        sg.items |= Constants.Item.MASK_MINAX.getLoc();
        sg.items |= Constants.Item.RAGE_GOD.getLoc();
        sg.players[0].weapon = WeaponType.SLING;
        TiledMap tmap = new UltimaTiledMapLoader(Maps.BRUSH_CON, Ultima4.standardAtlas, Maps.BRUSH_CON.getMap().getWidth(), Maps.BRUSH_CON.getMap().getHeight(), 32, 32).load();
        CombatScreen sc = new CombatScreen(null, context, Maps.WORLD, Maps.BRUSH_CON.getMap(), tmap, CreatureType.troll, Ultima4.creatures, Ultima4.standardAtlas);
        setScreen(sc);
        // atlas = a1;
        // tr = Utils.peerGem(Maps.LYCAEUM, a1);
        batch2 = new SpriteBatch();
        TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("sprites-atlas.txt"));
        a1 = new Animation(0.45f, atlas.findRegions("shallows"));
        TextureRegion[] frames = a1.getKeyFrames();
        a2 = new Animation(0.45f, atlas.findRegions("water"));
    // a3 = new Animation(0.45f, atlas.findRegions("sea"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Context(ultima.Context) Ultima4(ultima.Ultima4) SaveGame(objects.SaveGame) UltimaTiledMapLoader(util.UltimaTiledMapLoader) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) CombatScreen(ultima.CombatScreen) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Party(objects.Party) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Animation(com.badlogic.gdx.graphics.g2d.Animation) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap)

Example 2 with UltimaTiledMapLoader

use of util.UltimaTiledMapLoader 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 UltimaTiledMapLoader

use of util.UltimaTiledMapLoader in project ultimate-java by pantinor.

the class DungeonScreen method battleWandering.

public void battleWandering(Creature cr, int x, int y) {
    if (cr == null) {
        return;
    }
    Maps contextMap = Maps.get(dngMap.getId());
    DungeonTile tile = dungeonTiles[currentLevel][x][y];
    TiledMap tmap = new UltimaTiledMapLoader(tile.getCombatMap(), Ultima4.standardAtlas, 11, 11, tilePixelWidth, tilePixelHeight).load();
    context.setCurrentTiledMap(tmap);
    CombatScreen sc = new CombatScreen(this, context, contextMap, tile.getCombatMap().getMap(), tmap, cr.getTile(), Ultima4.creatures, Ultima4.standardAtlas);
    mainGame.setScreen(sc);
    currentEncounter = cr;
}
Also used : UltimaTiledMapLoader(util.UltimaTiledMapLoader) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap)

Example 4 with UltimaTiledMapLoader

use of util.UltimaTiledMapLoader in project ultimate-java by pantinor.

the class StaticGeneratedDungeonScreen method battleWandering.

public void battleWandering(Creature cr, int x, int y) {
    if (cr == null) {
        return;
    }
    Maps contextMap = Maps.get(dngMap.getId());
    DungeonTile tile = dungeonTiles[currentLevel][x][y];
    TiledMap tmap = new UltimaTiledMapLoader(tile.getCombatMap(), Ultima4.standardAtlas, 11, 11, tilePixelWidth, tilePixelHeight).load();
    context.setCurrentTiledMap(tmap);
    CombatScreen sc = new CombatScreen(this, context, contextMap, tile.getCombatMap().getMap(), tmap, cr.getTile(), Ultima4.creatures, Ultima4.standardAtlas);
    mainGame.setScreen(sc);
    currentEncounter = cr;
}
Also used : UltimaTiledMapLoader(util.UltimaTiledMapLoader) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap) CombatScreen(ultima.CombatScreen)

Example 5 with UltimaTiledMapLoader

use of util.UltimaTiledMapLoader in project ultimate-java by pantinor.

the class GameScreen method attackAt.

public void attackAt(Maps combat, Creature cr) {
    Maps contextMap = Maps.get(context.getCurrentMap().getId());
    BaseMap combatMap = combat.getMap();
    TiledMap tmap = new UltimaTiledMapLoader(combat, Ultima4.standardAtlas, combat.getMap().getWidth(), combat.getMap().getHeight(), tilePixelWidth, tilePixelHeight).load();
    CombatScreen sc = new CombatScreen(this, context, contextMap, combatMap, tmap, cr.getTile(), Ultima4.creatures, Ultima4.standardAtlas);
    mainGame.setScreen(sc);
    currentEncounter = cr;
}
Also used : UltimaTiledMapLoader(util.UltimaTiledMapLoader) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap) BaseMap(objects.BaseMap)

Aggregations

UltimaTiledMapLoader (util.UltimaTiledMapLoader)6 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)5 BaseMap (objects.BaseMap)2 CombatScreen (ultima.CombatScreen)2 Animation (com.badlogic.gdx.graphics.g2d.Animation)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 MapProperties (com.badlogic.gdx.maps.MapProperties)1 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)1 StaticGeneratedDungeonScreen (generator.StaticGeneratedDungeonScreen)1 Random (java.util.Random)1 Party (objects.Party)1 PartyMember (objects.Party.PartyMember)1 Person (objects.Person)1 SaveGame (objects.SaveGame)1 Context (ultima.Context)1 Ultima4 (ultima.Ultima4)1 UltimaMapRenderer (util.UltimaMapRenderer)1 XORShiftRandom (util.XORShiftRandom)1