1
0
Fork 0
spacetac/src/ui/battle/OutcomeDialog.ts

46 lines
2.1 KiB
TypeScript
Raw Normal View History

2017-05-25 23:09:29 +00:00
/// <reference path="../common/UIComponent.ts" />
2017-03-12 23:32:41 +00:00
module TS.SpaceTac.UI {
/**
* Dialog to display battle outcome
*/
2017-05-25 23:09:29 +00:00
export class OutcomeDialog extends UIComponent {
constructor(parent: BattleView, player: Player, outcome: BattleOutcome, stats: BattleStats) {
super(parent, 1428, 1032, "battle-outcome-dialog");
2017-03-12 23:32:41 +00:00
let victory = outcome.winner && (outcome.winner.player == player);
2017-05-25 23:09:29 +00:00
this.addImage(714, 164, victory ? "battle-outcome-title-victory" : "battle-outcome-title-defeat");
2017-03-12 23:32:41 +00:00
if (victory) {
2017-05-25 23:09:29 +00:00
this.addButton(502, 871, () => {
parent.character_sheet.show(nn(outcome.winner).ships[0]);
parent.character_sheet.setLoot(outcome.loot);
2017-06-05 22:05:34 +00:00
}, "battle-outcome-button-loot", 0, 0, "Open character sheet to loot equipment from defeated fleet");
2017-03-15 21:40:19 +00:00
2017-05-25 23:09:29 +00:00
this.addButton(924, 871, () => {
2017-03-12 23:32:41 +00:00
parent.exitBattle();
2017-06-05 22:05:34 +00:00
}, "battle-outcome-button-map", 0, 0, "Exit the battle and go back to the map");
2017-03-12 23:32:41 +00:00
} else {
2017-05-25 23:09:29 +00:00
this.addButton(502, 871, () => {
2017-03-14 22:28:07 +00:00
parent.revertBattle();
2017-06-05 22:05:34 +00:00
}, "battle-outcome-button-revert", 0, 0, "Go back to where the fleet was before the battle happened");
2017-03-15 21:40:19 +00:00
2017-05-25 23:09:29 +00:00
this.addButton(924, 871, () => {
2017-03-12 23:32:41 +00:00
// Quit the game, and go back to menu
parent.gameui.quitGame();
2017-06-05 22:05:34 +00:00
}, "battle-outcome-button-menu", 0, 0, "Quit the game, and go back to main menu");
2017-03-12 23:32:41 +00:00
}
2017-05-25 23:09:29 +00:00
this.addText(780, 270, "You", "#ffffff", 20);
this.addText(980, 270, "Enemy", "#ffffff", 20);
stats.getImportant(10).forEach((stat, index) => {
this.addText(500, 314 + 40 * index, stat.name, "#ffffff", 20);
this.addText(780, 314 + 40 * index, stat.attacker.toString(), "#8ba883", 20, true);
this.addText(980, 314 + 40 * index, stat.defender.toString(), "#cd6767", 20, true);
});
this.setPositionInsideParent(0.5, 0.5);
2017-03-12 23:32:41 +00:00
}
}
}