Search in sources :

Example 1 with InnService

use of vendor.InnService in project ultimate-java by pantinor.

the class VendorTest method testInnVendor.

// @Test
public void testInnVendor() throws Exception {
    File file = new File("assets/xml/vendor.xml");
    JAXBContext jaxbContext = JAXBContext.newInstance(VendorClassSet.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
    VendorClassSet vcs = (VendorClassSet) jaxbUnmarshaller.unmarshal(file);
    vcs.init();
    SaveGame sg = new SaveGame();
    SaveGame.SaveGamePlayerRecord rec = sg.new SaveGamePlayerRecord();
    rec.name = "avatar";
    rec.hp = 200;
    Party party = new Party(sg);
    Context context = new Context();
    context.setParty(party);
    party.addMember(rec);
    sg.gold = 500;
    BaseVendor v = new InnService(vcs.getVendor(InventoryType.INN, Maps.TRINSIC), context);
    while (true) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        if (!v.nextDialog()) {
            break;
        }
        String input = br.readLine();
        if (input != null && input.equals("bye")) {
            break;
        }
        v.setResponse(input);
    }
    System.err.println("sg gold = " + sg.gold);
}
Also used : Context(ultima.Context) JAXBContext(javax.xml.bind.JAXBContext) BaseVendor(vendor.BaseVendor) InputStreamReader(java.io.InputStreamReader) SaveGame(objects.SaveGame) JAXBContext(javax.xml.bind.JAXBContext) Party(objects.Party) BufferedReader(java.io.BufferedReader) InnService(vendor.InnService) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File) VendorClassSet(vendor.VendorClassSet)

Example 2 with InnService

use of vendor.InnService in project ultimate-java by pantinor.

the class ConversationDialog method hide.

public void hide(Action action) {
    Stage stage = getStage();
    if (stage != null) {
        removeListener(focusListener);
        if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null) {
            previousKeyboardFocus = null;
        }
        Actor actor = stage.getKeyboardFocus();
        if (actor == null || actor.isDescendantOf(this)) {
            stage.setKeyboardFocus(previousKeyboardFocus);
        }
        if (previousScrollFocus != null && previousScrollFocus.getStage() == null) {
            previousScrollFocus = null;
        }
        actor = stage.getScrollFocus();
        if (actor == null || actor.isDescendantOf(this)) {
            stage.setScrollFocus(previousScrollFocus);
        }
    }
    if (action != null) {
        addCaptureListener(ignoreTouchDown);
        addAction(sequence(action, Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
    } else {
        remove();
    }
    Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
    screen.gameTimer.active = true;
    if (screen.context.getCurrentMap().getCity() != null) {
        screen.context.getCurrentMap().getCity().resetTalkingFlags();
    }
    if (vendor != null && vendor instanceof InnService) {
        InnService inn = (InnService) vendor;
        if (inn.rentedRoom) {
            SequenceAction seq = Actions.action(SequenceAction.class);
            seq.addAction(Actions.delay(1f));
            seq.addAction(Actions.run(new Runnable() {

                public void run() {
                    CombatScreen.holeUp(Maps.get(screen.context.getCurrentMap().getId()), 0, 0, screen, screen.context, Ultima4.creatures, Ultima4.standardAtlas, true);
                }
            }));
            screen.getStage().addAction(seq);
        }
    }
}
Also used : InputMultiplexer(com.badlogic.gdx.InputMultiplexer) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) InnService(vendor.InnService) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Aggregations

InnService (vendor.InnService)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Party (objects.Party)1 SaveGame (objects.SaveGame)1 Context (ultima.Context)1 BaseVendor (vendor.BaseVendor)1 VendorClassSet (vendor.VendorClassSet)1