use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project ultimate-java by pantinor.
the class CodexScreen method codexEject.
private void codexEject(String text) {
logs.add(text);
SequenceAction seq = Actions.action(SequenceAction.class);
seq.addAction(Actions.run(new Runnable() {
public void run() {
Sounds.play(Sound.NEGATIVE_EFFECT);
}
}));
seq.addAction(Actions.delay(3f));
seq.addAction(Actions.run(new Runnable() {
public void run() {
mainGame.setScreen(returnScreen);
}
}));
stage.addAction(seq);
}
use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project ultimate-java by pantinor.
the class CombatScreen method finishTurn.
@Override
public void finishTurn(int currentX, int currentY) {
try {
party.endTurn(combatMap.getType());
context.getAura().passTurn();
if (combatMap.getCreatures().isEmpty() && combatMap.getType() == MapType.combat) {
end();
return;
}
boolean quick = context.getAura().getType() == AuraType.QUICKNESS && (rand.nextInt(2) == 0);
if (!quick) {
SequenceAction seq = Actions.action(SequenceAction.class);
for (Creature cr : combatMap.getCreatures()) {
seq.addAction(Actions.run(new CreatureActionsAction(cr)));
seq.addAction(Actions.delay(.04f));
}
seq.addAction(Actions.run(new FinishCreatureAction()));
stage.addAction(seq);
}
} catch (PartyDeathException e) {
this.returnScreen.partyDeath();
}
}
use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction 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);
}
}
}
use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction in project ultimate-java by pantinor.
the class ConversationDialog method initialize.
private void initialize() {
screen.gameTimer.active = false;
setModal(true);
defaults().space(10);
add(internalTable = new Table(Ultima4.skin)).expand().fill();
row();
internalTable.defaults().pad(1);
scrollPane = new LogScrollPane(Ultima4.skin, width);
scrollPane.setHeight(height);
input = new TextField("", Ultima4.skin);
input.setTextFieldListener(new TextFieldListener() {
@Override
public void keyTyped(TextField tf, char key) {
if (key == '\r') {
if (tf.getText().length() == 0) {
if (!cancelHide) {
hide();
}
cancelHide = false;
}
Conversation conversation = person.getConversation();
if (conversation != null) {
if (conversation instanceof CustomInputConversation) {
((CustomInputConversation) conversation).setParty(screen.context.getParty());
}
String query = tf.getText();
Topic t = conversation.matchTopic(query);
if (t != null) {
if (t.getQuery() != null && t.getQuery().equals("join")) {
String name = conversation.getName();
Virtue virtue = screen.context.getParty().getVirtueForJoinable(name);
if (virtue != null) {
CannotJoinError join = screen.context.getParty().join(name);
if (join == CannotJoinError.JOIN_SUCCEEDED) {
scrollPane.add("I am honored to join thee!");
screen.context.getCurrentMap().removeJoinedPartyMemberFromPeopleList(screen.context.getParty());
} else {
scrollPane.add("Thou art not " + (join == CannotJoinError.JOIN_NOT_VIRTUOUS ? virtue.getDescription() : "experienced") + " enough for me to join thee.");
}
} else {
scrollPane.add("I cannot join thee.");
}
} else {
if (!conversation.isStandardQuery(query)) {
screen.context.addEntry(conversation.getName(), conversation.getMap(), t.getPhrase());
}
scrollPane.add(t.getPhrase());
if (t.getQuestion() != null) {
scrollPane.add(t.getQuestion());
}
}
previousTopic = t;
} else {
if (previousTopic != null && previousTopic.getQuestion() != null) {
if (query.toLowerCase().contains("y")) {
screen.context.addEntry(conversation.getName(), conversation.getMap(), previousTopic.getYesResponse());
scrollPane.add(previousTopic.getYesResponse());
if (conversation.getRespAffectsHumility() > 0) {
screen.context.getParty().adjustKarma(KarmaAction.BRAGGED);
}
} else {
screen.context.addEntry(conversation.getName(), conversation.getMap(), previousTopic.getNoResponse());
scrollPane.add(previousTopic.getNoResponse());
if (previousTopic.isLbHeal()) {
for (PartyMember pm : screen.context.getParty().getMembers()) {
pm.heal(HealType.CURE);
pm.heal(HealType.FULLHEAL);
}
Sounds.play(Sound.HEALING);
}
if (conversation.getRespAffectsHumility() > 0) {
screen.context.getParty().adjustKarma(KarmaAction.HUMBLE);
}
}
} else {
scrollPane.add("That I cannot help thee with.");
}
previousTopic = null;
}
} else if (person.getRole() != null && vendor != null) {
String input = tf.getText();
vendor.setResponse(input);
vendor.nextDialog();
}
tf.setText("");
}
}
});
defaults().pad(5);
internalTable.add(scrollPane).maxWidth(width).width(width);
internalTable.row();
internalTable.add(input).maxWidth(width).width(width);
focusListener = new FocusListener() {
@Override
public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) {
if (!focused) {
focusChanged(event);
}
}
@Override
public void scrollFocusChanged(FocusEvent event, Actor actor, boolean focused) {
if (!focused) {
focusChanged(event);
}
}
private void focusChanged(FocusEvent event) {
Stage stage = getStage();
if (isModal() && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == ConversationDialog.this) {
Actor newFocusedActor = event.getRelatedActor();
if (newFocusedActor != null && !newFocusedActor.isDescendantOf(ConversationDialog.this) && !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus))) {
event.cancel();
}
}
}
};
person.setTalking(true);
if (person.getConversation() != null) {
if (person.getRole() != null && person.getRole().getRole().equals("lordbritish")) {
LordBritishConversation conv = (LordBritishConversation) person.getConversation();
scrollPane.add(conv.intro(screen.context));
SequenceAction seq = Actions.action(SequenceAction.class);
Party party = screen.context.getParty();
if (party.getMember(0).getPlayer().status == StatusType.DEAD) {
party.getMember(0).heal(HealType.RESURRECT);
party.getMember(0).heal(HealType.FULLHEAL);
seq.addAction(Actions.run(new LBAction(Sound.HEALING, "I resurrect thee.")));
seq.addAction(Actions.delay(3f));
}
for (int i = 0; i < party.getMembers().size(); i++) {
PartyMember pm = party.getMember(i);
if (pm.getPlayer().advanceLevel()) {
seq.addAction(Actions.run(new LBAction(Sound.MAGIC, pm.getPlayer().name + " thou art now level " + pm.getPlayer().getLevel())));
seq.addAction(Actions.delay(3f));
}
}
stage.addAction(seq);
} else if (person.getRole() != null && person.getRole().getRole().equals("hawkwind")) {
HawkwindConversation conv = (HawkwindConversation) person.getConversation();
conv.setParty(screen.context.getParty());
scrollPane.add(conv.intro());
} else {
scrollPane.add("You meet " + person.getConversation().getDescription().toLowerCase() + ".");
}
} else if (person.getRole() != null && person.getRole().getInventoryType() != null) {
vendor = Ultima4.vendorClassSet.getVendorImpl(person.getRole().getInventoryType(), Maps.get(screen.context.getCurrentMap().getId()), screen.context);
vendor.setScreen(screen);
vendor.setScrollPane(scrollPane);
vendor.nextDialog();
}
}
use of com.badlogic.gdx.scenes.scene2d.actions.SequenceAction 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);
}
}
Aggregations