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;
}
}
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);
}
}
Aggregations