2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.UI {
|
2015-01-21 00:00:00 +00:00
|
|
|
// Ship sprite in the arena (BattleView)
|
|
|
|
export class ArenaShip extends Phaser.Group {
|
2017-04-10 17:38:33 +00:00
|
|
|
// Link to the view
|
2017-05-17 21:55:39 +00:00
|
|
|
arena: Arena
|
2017-05-17 18:14:45 +00:00
|
|
|
battleview: BattleView
|
2017-04-10 17:38:33 +00:00
|
|
|
|
2015-01-21 00:00:00 +00:00
|
|
|
// Link to displayed ship
|
2017-05-17 18:14:45 +00:00
|
|
|
ship: Ship
|
2015-01-21 00:00:00 +00:00
|
|
|
|
2017-01-10 00:22:59 +00:00
|
|
|
// Boolean to indicate if it is an enemy ship
|
2017-05-17 18:14:45 +00:00
|
|
|
enemy: boolean
|
2017-01-10 00:22:59 +00:00
|
|
|
|
2015-01-21 00:00:00 +00:00
|
|
|
// Ship sprite
|
2017-09-19 15:09:06 +00:00
|
|
|
sprite: Phaser.Image
|
2015-01-21 00:00:00 +00:00
|
|
|
|
2017-11-30 00:31:54 +00:00
|
|
|
// Stasis effect
|
2017-05-17 18:14:45 +00:00
|
|
|
stasis: Phaser.Image
|
2017-02-15 22:34:27 +00:00
|
|
|
|
2017-05-23 16:42:55 +00:00
|
|
|
// HSP display
|
2017-08-24 22:47:34 +00:00
|
|
|
hsp: Phaser.Image
|
|
|
|
hull_bar: ValueBar
|
|
|
|
hull_text: Phaser.Text
|
|
|
|
shield_bar: ValueBar
|
|
|
|
shield_text: Phaser.Text
|
|
|
|
power_text: Phaser.Text
|
|
|
|
toggle_hsp: Toggle
|
2017-05-23 16:42:55 +00:00
|
|
|
|
|
|
|
// Play order
|
|
|
|
play_order: Phaser.Text
|
|
|
|
toggle_play_order: Toggle
|
2015-01-21 00:00:00 +00:00
|
|
|
|
2017-01-10 00:22:59 +00:00
|
|
|
// Frame to indicate the owner of the ship, and if it is playing
|
2017-05-17 18:14:45 +00:00
|
|
|
frame: Phaser.Image
|
2015-01-23 00:00:00 +00:00
|
|
|
|
2017-02-12 22:18:36 +00:00
|
|
|
// Effects display
|
2017-06-13 22:01:39 +00:00
|
|
|
active_effects_display: Phaser.Group
|
2017-07-19 17:46:04 +00:00
|
|
|
effects_radius: Phaser.Graphics
|
2017-06-13 22:01:39 +00:00
|
|
|
effects_messages: Phaser.Group
|
2017-09-13 20:56:57 +00:00
|
|
|
effects_messages_toggle: Toggle
|
2017-02-12 22:18:36 +00:00
|
|
|
|
2015-01-21 00:00:00 +00:00
|
|
|
// Create a ship sprite usable in the Arena
|
2017-02-12 22:18:36 +00:00
|
|
|
constructor(parent: Arena, ship: Ship) {
|
|
|
|
super(parent.game);
|
2017-05-17 21:55:39 +00:00
|
|
|
this.arena = parent;
|
2017-09-19 15:09:06 +00:00
|
|
|
this.battleview = parent.view;
|
2015-01-21 00:00:00 +00:00
|
|
|
|
2016-10-26 21:15:04 +00:00
|
|
|
this.ship = ship;
|
2018-01-16 00:08:24 +00:00
|
|
|
this.enemy = !this.battleview.player.is(this.ship.fleet.player);
|
2016-10-26 21:15:04 +00:00
|
|
|
|
2017-07-19 17:46:04 +00:00
|
|
|
// Add effects radius
|
|
|
|
this.effects_radius = new Phaser.Graphics(this.game);
|
|
|
|
this.add(this.effects_radius);
|
|
|
|
|
2017-08-24 18:26:07 +00:00
|
|
|
// Add frame indicating which side this ship is on
|
|
|
|
this.frame = this.battleview.newImage(this.enemy ? "battle-hud-ship-enemy" : "battle-hud-ship-own");
|
|
|
|
this.frame.anchor.set(0.5, 0.5);
|
|
|
|
this.add(this.frame);
|
|
|
|
this.setPlaying(false);
|
|
|
|
|
2015-01-21 00:00:00 +00:00
|
|
|
// Add ship sprite
|
2017-11-14 00:07:06 +00:00
|
|
|
this.sprite = this.battleview.newImage(`ship-${ship.model.code}-sprite`);
|
2015-01-21 00:00:00 +00:00
|
|
|
this.sprite.rotation = ship.arena_angle;
|
|
|
|
this.sprite.anchor.set(0.5, 0.5);
|
2017-05-15 18:30:44 +00:00
|
|
|
this.add(this.sprite);
|
2015-01-21 00:00:00 +00:00
|
|
|
|
2017-05-09 18:17:49 +00:00
|
|
|
// Add stasis effect
|
2017-08-21 23:21:34 +00:00
|
|
|
this.stasis = this.battleview.newImage("battle-hud-ship-stasis");
|
2017-02-15 22:34:27 +00:00
|
|
|
this.stasis.anchor.set(0.5, 0.5);
|
2017-12-08 00:18:15 +00:00
|
|
|
this.stasis.alpha = 0.9;
|
|
|
|
this.stasis.visible = !ship.alive;
|
2017-05-15 18:30:44 +00:00
|
|
|
this.add(this.stasis);
|
2017-02-15 22:34:27 +00:00
|
|
|
|
2017-05-23 16:42:55 +00:00
|
|
|
// HSP display
|
2017-09-10 22:29:14 +00:00
|
|
|
this.hsp = this.battleview.newImage("battle-hud-ship-hsp", -50, 28);
|
2017-08-24 22:47:34 +00:00
|
|
|
this.add(this.hsp);
|
2017-09-10 22:29:14 +00:00
|
|
|
this.hull_bar = new ValueBar(this.battleview, "battle-hud-ship-hull", ValueBarOrientation.WEST, 48, 15);
|
2017-08-24 22:47:34 +00:00
|
|
|
this.hull_bar.setValue(this.ship.getValue("hull"), this.ship.getAttribute("hull_capacity"));
|
|
|
|
this.hsp.addChild(this.hull_bar.node);
|
2017-09-10 22:29:14 +00:00
|
|
|
this.shield_bar = new ValueBar(this.battleview, "battle-hud-ship-shield", ValueBarOrientation.EAST, 53, 15);
|
2017-08-24 22:47:34 +00:00
|
|
|
this.shield_bar.setValue(this.ship.getValue("shield"), this.ship.getAttribute("shield_capacity"));
|
|
|
|
this.hsp.addChild(this.shield_bar.node);
|
2017-09-10 22:29:14 +00:00
|
|
|
this.hull_text = new Phaser.Text(this.game, 0, 20, `${this.ship.getValue("hull")}`,
|
|
|
|
{ align: "left", font: "12pt SpaceTac", fill: "#eb4e4a" });
|
2017-08-24 22:47:34 +00:00
|
|
|
this.hull_text.setShadow(1, 1, "#000000");
|
|
|
|
this.hull_text.anchor.set(0, 1);
|
|
|
|
this.hsp.addChild(this.hull_text);
|
2017-09-10 22:29:14 +00:00
|
|
|
this.shield_text = new Phaser.Text(this.game, 104, 20, `${this.ship.getValue("shield")}`,
|
|
|
|
{ align: "right", font: "12pt SpaceTac", fill: "#2ad8dc" });
|
2017-08-24 22:47:34 +00:00
|
|
|
this.shield_text.setShadow(1, 1, "#000000");
|
|
|
|
this.shield_text.anchor.set(1, 1);
|
|
|
|
this.hsp.addChild(this.shield_text);
|
2017-09-10 22:29:14 +00:00
|
|
|
this.power_text = new Phaser.Text(this.game, 51, 10, `${this.ship.getValue("power")}`,
|
|
|
|
{ align: "center", font: "10pt SpaceTac", fill: "#ffdd4b" });
|
2017-08-24 22:47:34 +00:00
|
|
|
this.power_text.setShadow(1, 1, "#000000");
|
|
|
|
this.power_text.anchor.set(0.5, 0.5);
|
|
|
|
this.hsp.addChild(this.power_text);
|
|
|
|
this.toggle_hsp = this.battleview.animations.newVisibilityToggle(this.hsp, 200, false);
|
2017-05-23 16:42:55 +00:00
|
|
|
|
|
|
|
// Play order display
|
2017-09-10 22:29:14 +00:00
|
|
|
let play_order_bg = this.battleview.newImage("battle-hud-ship-play-order", -44, 0);
|
|
|
|
play_order_bg.anchor.set(0.5, 0.5);
|
|
|
|
this.play_order = new Phaser.Text(this.game, -2, 3, "", { font: "bold 12pt SpaceTac", fill: "#d1d1d1" });
|
|
|
|
this.play_order.setShadow(1, 1, "#000000");
|
|
|
|
this.play_order.anchor.set(0.5, 0.5);
|
|
|
|
play_order_bg.addChild(this.play_order);
|
|
|
|
this.toggle_play_order = this.battleview.animations.newVisibilityToggle(play_order_bg, 200, false);
|
|
|
|
this.add(play_order_bg);
|
2015-02-23 00:00:00 +00:00
|
|
|
|
2017-02-12 22:18:36 +00:00
|
|
|
// Effects display
|
2017-06-13 22:01:39 +00:00
|
|
|
this.active_effects_display = new Phaser.Group(this.game);
|
2017-08-24 18:26:07 +00:00
|
|
|
this.active_effects_display.position.set(0, -44);
|
2017-06-13 22:01:39 +00:00
|
|
|
this.add(this.active_effects_display);
|
|
|
|
this.effects_messages = new Phaser.Group(this.game);
|
|
|
|
this.add(this.effects_messages);
|
2017-09-13 20:56:57 +00:00
|
|
|
this.effects_messages_toggle = this.battleview.animations.newVisibilityToggle(this.effects_messages, 500, false);
|
2017-05-23 16:42:55 +00:00
|
|
|
|
2017-11-14 21:22:32 +00:00
|
|
|
this.updatePlayOrder();
|
2017-06-13 22:01:39 +00:00
|
|
|
this.updateActiveEffects();
|
2017-07-19 17:46:04 +00:00
|
|
|
this.updateEffectsRadius();
|
2017-02-12 22:18:36 +00:00
|
|
|
|
2015-01-21 00:00:00 +00:00
|
|
|
// Set location
|
2018-01-16 00:08:24 +00:00
|
|
|
if (this.battleview.battle.cycle == 1 && this.battleview.battle.play_index == 0 && ship.alive && this.battleview.player.is(ship.fleet.player)) {
|
2017-05-30 10:33:07 +00:00
|
|
|
this.position.set(ship.arena_x - 500 * Math.cos(ship.arena_angle), ship.arena_y - 500 * Math.sin(ship.arena_angle));
|
2017-05-22 20:18:17 +00:00
|
|
|
this.moveTo(ship.arena_x, ship.arena_y, ship.arena_angle);
|
|
|
|
} else {
|
|
|
|
this.moveTo(ship.arena_x, ship.arena_y, ship.arena_angle, false);
|
|
|
|
}
|
2017-05-17 18:14:45 +00:00
|
|
|
|
|
|
|
// Log processing
|
2017-12-04 18:12:06 +00:00
|
|
|
this.battleview.log_processor.register(diff => this.processBattleDiff(diff));
|
|
|
|
this.battleview.log_processor.registerForShip(ship, diff => this.processShipDiff(diff));
|
2017-05-17 20:59:25 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 20:56:25 +00:00
|
|
|
jasmineToString(): string {
|
|
|
|
return `ArenaShip ${this.ship.jasmineToString()}`;
|
|
|
|
}
|
|
|
|
|
2017-05-17 20:59:25 +00:00
|
|
|
/**
|
2017-12-04 18:12:06 +00:00
|
|
|
* Process a battle diff
|
2017-05-17 20:59:25 +00:00
|
|
|
*/
|
2017-12-04 18:12:06 +00:00
|
|
|
private processBattleDiff(diff: BaseBattleDiff) {
|
|
|
|
if (diff instanceof ShipChangeDiff) {
|
2017-11-14 21:22:32 +00:00
|
|
|
this.updatePlayOrder();
|
2017-05-22 22:05:52 +00:00
|
|
|
}
|
2017-12-04 18:12:06 +00:00
|
|
|
return {};
|
2017-05-22 22:05:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-12-04 18:12:06 +00:00
|
|
|
* Process a ship diff
|
2017-05-22 22:05:52 +00:00
|
|
|
*/
|
2017-12-04 18:12:06 +00:00
|
|
|
private processShipDiff(diff: BaseBattleShipDiff): LogProcessorDelegate {
|
|
|
|
if (diff instanceof ShipEffectAddedDiff || diff instanceof ShipEffectRemovedDiff) {
|
|
|
|
return {
|
|
|
|
background: async () => this.updateActiveEffects()
|
2017-05-17 18:14:45 +00:00
|
|
|
}
|
2017-12-04 18:12:06 +00:00
|
|
|
} else if (diff instanceof ShipValueDiff) {
|
|
|
|
return {
|
|
|
|
background: async (animate, timer) => {
|
|
|
|
if (animate) {
|
|
|
|
this.toggle_hsp.manipulate("value")(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (diff.code == "hull") {
|
|
|
|
this.hull_bar.setValue(this.ship.getValue("hull"), this.ship.getAttribute("hull_capacity") || 0);
|
|
|
|
this.hull_text.text = `${this.ship.getValue("hull")}`;
|
|
|
|
if (animate) {
|
|
|
|
await this.battleview.animations.blink(this.hull_text);
|
|
|
|
}
|
|
|
|
} else if (diff.code == "shield") {
|
|
|
|
this.shield_bar.setValue(this.ship.getValue("shield"), this.ship.getAttribute("shield_capacity") || 0);
|
|
|
|
this.shield_text.text = `${this.ship.getValue("shield")}`;
|
|
|
|
if (animate) {
|
|
|
|
await this.battleview.animations.blink(this.shield_text);
|
|
|
|
}
|
|
|
|
/*if (this.shield_bar.getValue() == 0) {
|
|
|
|
this.displayEffect("Shield failure", false);
|
|
|
|
}*/
|
|
|
|
} else if (diff.code == "power") {
|
|
|
|
this.power_text.text = `${this.ship.getValue("power")}`;
|
|
|
|
if (animate) {
|
|
|
|
await this.battleview.animations.blink(this.power_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animate) {
|
|
|
|
await timer.sleep(500);
|
|
|
|
this.toggle_hsp.manipulate("value")(false);
|
|
|
|
}
|
2017-07-19 17:46:04 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-04 18:12:06 +00:00
|
|
|
} else if (diff instanceof ShipAttributeDiff) {
|
|
|
|
return {
|
|
|
|
background: async (animate, timer) => {
|
|
|
|
if (animate) {
|
|
|
|
this.displayAttributeChanged(diff)
|
|
|
|
await timer.sleep(1000);
|
|
|
|
}
|
|
|
|
}
|
2017-11-14 00:07:06 +00:00
|
|
|
}
|
2017-12-04 18:12:06 +00:00
|
|
|
} else if (diff instanceof ShipDamageDiff) {
|
|
|
|
return {
|
|
|
|
background: async (animate, timer) => {
|
|
|
|
if (animate) {
|
2017-12-08 00:18:15 +00:00
|
|
|
await this.displayEffect(`${diff.theoretical} damage`, false);
|
2017-12-04 18:12:06 +00:00
|
|
|
await timer.sleep(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (diff instanceof ShipActionToggleDiff) {
|
|
|
|
return {
|
|
|
|
foreground: async (animate, timer) => {
|
|
|
|
let action = this.ship.getAction(diff.action);
|
|
|
|
if (action && action.equipment) {
|
|
|
|
let equname = action.equipment.name;
|
|
|
|
|
|
|
|
if (animate) {
|
|
|
|
if (diff.activated) {
|
|
|
|
await this.displayEffect(`${equname} ON`, true);
|
|
|
|
} else {
|
|
|
|
await this.displayEffect(`${equname} OFF`, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateEffectsRadius();
|
|
|
|
await timer.sleep(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (diff instanceof ShipActionUsedDiff) {
|
|
|
|
let action = this.ship.getAction(diff.action);
|
|
|
|
if (action) {
|
|
|
|
if (!(action instanceof ToggleAction) && action.equipment) {
|
|
|
|
let equipment = action.equipment;
|
|
|
|
return {
|
|
|
|
foreground: async (animate, timer) => {
|
|
|
|
if (animate) {
|
|
|
|
await this.displayEffect(equipment.name, true);
|
|
|
|
await timer.sleep(300);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (action instanceof EndTurnAction) {
|
|
|
|
return {
|
|
|
|
foreground: async (animate, timer) => {
|
|
|
|
if (animate) {
|
|
|
|
await this.displayEffect("End turn", true);
|
|
|
|
await timer.sleep(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
} else if (diff instanceof ShipMoveDiff) {
|
|
|
|
return {
|
|
|
|
background: async (animate: boolean, timer: Timer) => {
|
|
|
|
this.moveTo(diff.start.x, diff.start.y, diff.start.angle, false);
|
|
|
|
let duration = this.moveTo(diff.end.x, diff.end.y, diff.end.angle, animate, !!diff.engine);
|
|
|
|
if (duration && animate) {
|
|
|
|
await timer.sleep(duration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-05-22 18:06:33 +00:00
|
|
|
} else {
|
2017-12-04 18:12:06 +00:00
|
|
|
return {};
|
2017-05-17 20:59:25 +00:00
|
|
|
}
|
2015-01-21 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-05-15 18:30:44 +00:00
|
|
|
/**
|
|
|
|
* Set the hovered state on this ship
|
|
|
|
*
|
|
|
|
* This will show the information HUD accordingly
|
|
|
|
*/
|
2017-05-23 16:42:55 +00:00
|
|
|
setHovered(hovered: boolean, tactical: boolean) {
|
2017-09-13 20:56:57 +00:00
|
|
|
let client = tactical ? "tactical" : "hover";
|
|
|
|
|
2017-05-17 23:24:42 +00:00
|
|
|
if (hovered && this.ship.alive) {
|
2017-09-13 20:56:57 +00:00
|
|
|
this.toggle_hsp.manipulate(client)(true);
|
2017-05-23 16:42:55 +00:00
|
|
|
if (tactical) {
|
2017-09-13 20:56:57 +00:00
|
|
|
this.toggle_play_order.manipulate(client)(true);
|
2017-05-23 16:42:55 +00:00
|
|
|
}
|
2017-05-17 20:59:25 +00:00
|
|
|
} else {
|
2017-09-13 20:56:57 +00:00
|
|
|
this.toggle_hsp.manipulate(client)(false);
|
|
|
|
this.toggle_play_order.manipulate(client)(false);
|
2017-05-17 20:59:25 +00:00
|
|
|
}
|
2015-01-21 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-08-24 18:26:07 +00:00
|
|
|
/**
|
|
|
|
* Set the playing state on this ship
|
|
|
|
*
|
|
|
|
* This will alter the HUD frame to show this state
|
|
|
|
*/
|
2017-12-04 18:12:06 +00:00
|
|
|
async setPlaying(playing: boolean, animate = true): Promise<void> {
|
2017-08-24 23:02:32 +00:00
|
|
|
this.frame.alpha = playing ? 1 : 0.35;
|
|
|
|
this.frame.visible = this.ship.alive;
|
2017-12-04 18:12:06 +00:00
|
|
|
|
|
|
|
if (playing && animate) {
|
|
|
|
this.battleview.audio.playOnce("battle-ship-change");
|
|
|
|
await this.battleview.animations.blink(this.frame);
|
|
|
|
}
|
2015-01-23 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 22:34:27 +00:00
|
|
|
/**
|
|
|
|
* Activate the dead effect (stasis)
|
|
|
|
*/
|
|
|
|
setDead(dead = true) {
|
|
|
|
if (dead) {
|
2017-11-30 00:31:54 +00:00
|
|
|
//this.displayEffect("stasis", false);
|
|
|
|
this.stasis.visible = true;
|
|
|
|
this.stasis.alpha = 0;
|
|
|
|
this.battleview.animations.blink(this.stasis, 0.9, 0.7);
|
|
|
|
} else {
|
|
|
|
this.stasis.visible = false;
|
2017-02-15 22:34:27 +00:00
|
|
|
}
|
2017-08-24 22:47:34 +00:00
|
|
|
this.setPlaying(false);
|
2017-02-15 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 00:30:50 +00:00
|
|
|
/**
|
|
|
|
* Move the sprite to a location
|
|
|
|
*
|
|
|
|
* Return the duration of animation
|
|
|
|
*/
|
2017-08-17 17:51:22 +00:00
|
|
|
moveTo(x: number, y: number, facing_angle: number, animate = true, engine = true): number {
|
2015-01-21 00:00:00 +00:00
|
|
|
if (animate) {
|
2017-08-17 17:51:22 +00:00
|
|
|
let animation = engine ? Animations.moveInSpace : Animations.moveTo;
|
|
|
|
let duration = animation(this, x, y, facing_angle, this.sprite);
|
2017-05-22 18:06:33 +00:00
|
|
|
return duration;
|
2015-01-21 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
2015-01-26 00:00:00 +00:00
|
|
|
this.sprite.rotation = facing_angle;
|
2017-02-14 00:30:50 +00:00
|
|
|
return 0;
|
2015-01-21 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-03 00:00:00 +00:00
|
|
|
|
2017-02-12 22:18:36 +00:00
|
|
|
/**
|
|
|
|
* Briefly show an effect on this ship
|
|
|
|
*/
|
2017-12-04 18:12:06 +00:00
|
|
|
async displayEffect(message: string, beneficial: boolean) {
|
2017-09-13 20:56:57 +00:00
|
|
|
if (!this.effects_messages.visible) {
|
|
|
|
this.effects_messages.removeAll(true);
|
|
|
|
}
|
|
|
|
|
2017-08-15 22:30:19 +00:00
|
|
|
let text = new Phaser.Text(this.game, 0, 20 * this.effects_messages.children.length, message, { font: "14pt SpaceTac", fill: beneficial ? "#afe9c6" : "#e9afaf" });
|
2017-06-13 22:01:39 +00:00
|
|
|
this.effects_messages.addChild(text);
|
2017-02-12 22:18:36 +00:00
|
|
|
|
2017-05-17 17:44:42 +00:00
|
|
|
let arena = this.battleview.arena.getBoundaries();
|
2017-06-13 22:01:39 +00:00
|
|
|
this.effects_messages.position.set(
|
|
|
|
(this.ship.arena_x < 100) ? -35 : ((this.ship.arena_x > arena.width - 100) ? (35 - this.effects_messages.width) : (-this.effects_messages.width * 0.5)),
|
2017-07-19 17:46:04 +00:00
|
|
|
(this.ship.arena_y < arena.height * 0.9) ? 50 : (-50 - this.effects_messages.height)
|
2017-05-17 17:44:42 +00:00
|
|
|
);
|
2017-02-12 22:18:36 +00:00
|
|
|
|
2017-09-13 20:56:57 +00:00
|
|
|
this.effects_messages_toggle.manipulate("added")(1000);
|
2017-12-04 18:12:06 +00:00
|
|
|
await this.battleview.timer.sleep(1000);
|
2015-02-03 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 22:18:36 +00:00
|
|
|
/**
|
2017-11-14 00:07:06 +00:00
|
|
|
* Display interesting changes in ship attributes
|
2017-02-12 22:18:36 +00:00
|
|
|
*/
|
2017-11-14 00:07:06 +00:00
|
|
|
displayAttributeChanged(event: ShipAttributeDiff) {
|
|
|
|
// TODO show final diff, not just cumulative one
|
|
|
|
let diff = (event.added.cumulative || 0) - (event.removed.cumulative || 0);
|
|
|
|
if (diff) {
|
|
|
|
let name = SHIP_VALUES_NAMES[event.code];
|
|
|
|
this.displayEffect(`${name} ${diff < 0 ? "-" : "+"}${Math.abs(diff)}`, diff >= 0);
|
|
|
|
}
|
2015-02-03 00:00:00 +00:00
|
|
|
}
|
2017-05-17 18:14:45 +00:00
|
|
|
|
2017-11-14 21:22:32 +00:00
|
|
|
/**
|
|
|
|
* Update the play order indicator
|
|
|
|
*/
|
|
|
|
updatePlayOrder(): void {
|
|
|
|
let play_order = this.battleview.battle.getPlayOrder(this.ship);
|
|
|
|
if (play_order == 0) {
|
|
|
|
this.play_order.text = "-";
|
|
|
|
} else {
|
|
|
|
this.play_order.text = play_order.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:14:45 +00:00
|
|
|
/**
|
2017-06-13 22:01:39 +00:00
|
|
|
* Update the list of effects active on the ship
|
2017-05-17 18:14:45 +00:00
|
|
|
*/
|
2017-06-13 22:01:39 +00:00
|
|
|
updateActiveEffects() {
|
|
|
|
this.active_effects_display.removeAll();
|
2017-05-17 18:14:45 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
let effects = this.ship.active_effects.list();
|
2017-06-13 22:01:39 +00:00
|
|
|
|
|
|
|
let count = effects.length;
|
2017-05-17 18:14:45 +00:00
|
|
|
if (count) {
|
2017-08-24 18:26:07 +00:00
|
|
|
let positions = UITools.evenlySpace(70, 17, count);
|
2017-06-13 22:01:39 +00:00
|
|
|
|
|
|
|
effects.forEach((effect, index) => {
|
2017-08-21 23:21:34 +00:00
|
|
|
let name = effect.isBeneficial() ? "battle-hud-ship-effect-good" : "battle-hud-ship-effect-bad";
|
2017-08-24 18:26:07 +00:00
|
|
|
let dot = this.battleview.newImage(name, positions[index] - 35, 0);
|
|
|
|
dot.anchor.set(0.5, 0.5);
|
2017-06-13 22:01:39 +00:00
|
|
|
this.active_effects_display.add(dot);
|
2017-05-17 18:14:45 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2017-05-23 16:42:55 +00:00
|
|
|
|
2017-07-19 17:46:04 +00:00
|
|
|
/**
|
|
|
|
* Update the activated effects radius
|
|
|
|
*/
|
|
|
|
updateEffectsRadius(): void {
|
|
|
|
this.effects_radius.clear();
|
|
|
|
this.ship.getAvailableActions().forEach(action => {
|
|
|
|
if (action instanceof ToggleAction && action.activated) {
|
|
|
|
this.effects_radius.lineStyle(2, 0xe9f2f9, 0.3);
|
|
|
|
this.effects_radius.beginFill(0xe9f2f9, 0.0);
|
|
|
|
this.effects_radius.drawCircle(0, 0, action.radius * 2);
|
|
|
|
this.effects_radius.endFill();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-01-21 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|