use of objects.ProjectileActor in project ultimate-java by pantinor.
the class CombatScreen method rangedAttackAt.
private boolean rangedAttackAt(AttackVector target, Creature attacker) throws PartyDeathException {
PartyMember defender = null;
for (PartyMember p : party.getMembers()) {
if (p.combatCr.currentX == target.x && p.combatCr.currentY == target.y) {
defender = p;
break;
}
}
if (defender == null) {
return false;
}
AttackResult res = Utils.attackHit(attacker, defender);
TileEffect effect = TileEffect.NONE;
Color col = Color.WHITE;
if (attacker.rangedAttackIs("poison_field")) {
effect = TileEffect.POISON;
col = Color.GREEN;
} else if (attacker.rangedAttackIs("magic_flash")) {
col = Color.CYAN;
} else if (attacker.rangedAttackIs("fire_field")) {
effect = TileEffect.FIRE;
col = Color.RED;
} else if (attacker.rangedAttackIs("sleep_field")) {
effect = TileEffect.SLEEP;
col = Color.PURPLE;
} else if (attacker.rangedAttackIs("energy_field")) {
effect = TileEffect.ELECTRICITY;
col = Color.BLUE;
} else if (attacker.rangedAttackIs("rocks")) {
col = Color.BROWN;
}
final ProjectileActor p = new ProjectileActor(this, col, attacker.currentX, attacker.currentY, res);
Vector3 v = getMapPixelCoords(defender.combatCr.currentX, defender.combatCr.currentY);
p.addAction(sequence(moveTo(v.x, v.y, .3f), new Action() {
public boolean act(float delta) {
switch(p.res) {
case HIT:
p.resultTexture = Ultima4.hitTile;
Sounds.play(Sound.NPC_MAGIC_STRUCK);
wounded = true;
break;
case MISS:
p.resultTexture = Ultima4.missTile;
Sounds.play(Sound.EVADE);
break;
}
return true;
}
}, fadeOut(.2f), removeActor(p)));
stage.addActor(p);
switch(effect) {
case ELECTRICITY:
Sounds.play(Sound.LIGHTNING);
log("Electrified!");
Utils.dealDamage(attacker, defender);
break;
case FIRE:
case LAVA:
Sounds.play(Sound.FIREBALL);
log("Fiery Hit!");
Utils.dealDamage(attacker, defender);
break;
case NONE:
break;
case POISON:
case POISONFIELD:
if (rand.nextInt(2) == 0 && defender.getPlayer().status != StatusType.POISONED) {
Sounds.play(Sound.POISON_EFFECT);
log("Poisoned!");
defender.getPlayer().status = StatusType.POISONED;
}
break;
case SLEEP:
if (context.getAura().getType() == AuraType.NEGATE) {
log("Sleep attack negated.");
} else {
log("Sleep!");
Sounds.play(Sound.SLEEP);
if (rand.nextInt(2) == 0 && !defender.isDisabled()) {
defender.putToSleep();
}
}
break;
default:
break;
}
if (res == AttackResult.HIT) {
Utils.dealDamage(attacker, defender);
}
return res == AttackResult.HIT;
}
use of objects.ProjectileActor in project ultimate-java by pantinor.
the class Utils method animateMagicAttack.
public static void animateMagicAttack(Stage stage, final CombatScreen scr, PartyMember attacker, Direction dir, int x, int y, Spell spell, int minDamage, int maxDamage) {
final AttackVector av = Utils.castSpellAttack(scr.combatMap, attacker, dir, x, y, minDamage, maxDamage, spell);
Color color = Color.WHITE;
switch(spell) {
case FIREBALL:
color = Color.RED;
break;
case ICEBALL:
color = Color.CYAN;
break;
case KILL:
color = Color.VIOLET;
break;
case MAGICMISSILE:
color = Color.BLUE;
break;
case SLEEP:
color = Color.PURPLE;
break;
}
final ProjectileActor p = new ProjectileActor(scr, color, x, y, av.result);
Vector3 v = scr.getMapPixelCoords(av.x, av.y);
p.addAction(sequence(moveTo(v.x, v.y, av.distance * .1f), new Action() {
public boolean act(float delta) {
switch(p.res) {
case HIT:
p.resultTexture = Ultima4.magicHitTile;
break;
case MISS:
p.resultTexture = Ultima4.missTile;
break;
}
scr.replaceTile(av.leaveTileName, av.x, av.y);
scr.finishPlayerTurn();
return true;
}
}, fadeOut(.2f), removeActor(p)));
stage.addActor(p);
}
use of objects.ProjectileActor in project ultimate-java by pantinor.
the class Utils method animateCannonFire.
public static void animateCannonFire(final BaseScreen screen, final Stage stage, final BaseMap map, final AttackVector av, final int sx, final int sy, final boolean avatarAttack) {
Sounds.play(Sound.CANNON);
final ProjectileActor p = new ProjectileActor(screen, Color.WHITE, sx, sy, av.result);
Vector3 d = screen.getMapPixelCoords(av.x, av.y);
p.addAction(sequence(moveTo(d.x, d.y, av.distance * .1f), Actions.run(new Runnable() {
public void run() {
switch(p.res) {
case HIT:
p.resultTexture = Ultima4.hitTile;
map.removeCreature(av.impactedCreature);
if (av.impactedDrawable != null && av.impactedDrawable.getShipHull() <= 0) {
av.impactedDrawable.remove();
}
break;
case MISS:
p.resultTexture = Ultima4.missTile;
break;
}
if (avatarAttack) {
Vector3 v = screen.getCurrentMapCoords();
screen.finishTurn((int) v.x, (int) v.y);
}
}
}), Actions.fadeOut(.3f), removeActor(p)));
stage.addActor(p);
}
use of objects.ProjectileActor in project ultimate-java by pantinor.
the class Utils method animateAttack.
public static void animateAttack(Stage stage, final CombatScreen scr, PartyMember attacker, Direction dir, int x, int y, int range) {
final AttackVector av = Utils.attack(scr.combatMap, attacker, dir, x, y, range);
boolean magicHit = attacker.getPlayer().weapon.getWeapon().getHittile().equals("magic_flash");
final ProjectileActor p = new ProjectileActor(scr, magicHit ? Color.CYAN : Color.RED, x, y, av.result);
Vector3 v = scr.getMapPixelCoords(av.x, av.y);
final TextureRegion hitTile = (magicHit ? Ultima4.magicHitTile : Ultima4.hitTile);
p.addAction(sequence(moveTo(v.x, v.y, av.distance * .1f), new Action() {
@Override
public boolean act(float delta) {
switch(p.res) {
case HIT:
p.resultTexture = hitTile;
break;
case MISS:
p.resultTexture = Ultima4.missTile;
break;
}
scr.replaceTile(av.leaveTileName, av.x, av.y);
scr.finishPlayerTurn();
return true;
}
}, fadeOut(.2f), removeActor(p)));
stage.addActor(p);
}
Aggregations