1
0
Fork 0

Disabled character sheet interaction during battles (except loot screen)

This commit is contained in:
Michaël Lemaire 2017-11-15 00:45:09 +01:00
parent 3310440ff9
commit 87a5e7f49d
6 changed files with 52 additions and 12 deletions

View file

@ -23,7 +23,6 @@ Map/story
Character sheet
---------------
* Disable interaction during battle (except for loot screen)
* Improve eye-catching for shop and loot section
* Highlight allowed destinations during drag-and-drop
* Effective skill is sometimes not updated when upgrading base skill

View file

@ -142,7 +142,9 @@ module TK.SpaceTac.UI {
this.inputs.bindCheat("a", "Use AI to play", () => this.playAI());
// "Battle" animation, then start processing the log
if (this.splash) {
if (this.battle.ended) {
this.endBattle();
} else if (this.splash) {
this.showSplash().then(() => {
this.log_processor.start();
});
@ -282,7 +284,7 @@ module TK.SpaceTac.UI {
if (this.targetting.active) {
this.validationPressed();
} else if (this.ship_hovered && this.ship_hovered.getPlayer().is(this.player) && this.interacting) {
this.character_sheet.show(this.ship_hovered);
this.character_sheet.show(this.ship_hovered, undefined, undefined, false);
this.setShipHovered(null);
}
}
@ -342,14 +344,15 @@ module TK.SpaceTac.UI {
* End the battle and show the outcome dialog
*/
endBattle() {
if (this.battle.outcome) {
let battle = this.actual_battle;
if (battle.outcome) {
this.setInteractionEnabled(false);
this.gameui.session.setBattleEnded();
this.battle.stats.processLog(this.battle.log, this.player.fleet);
battle.stats.processLog(battle.log, this.player.fleet);
new OutcomeDialog(this, this.player, this.battle.outcome, this.battle.stats);
new OutcomeDialog(this, this.player, battle.outcome, battle.stats);
} else {
console.error("Battle not ended !");
}

View file

@ -60,7 +60,7 @@ module TK.SpaceTac.UI {
sheet.destroy(true);
this.refreshContent();
});
sheet.show(this.player.fleet.ships[0], false);
sheet.show(this.player.fleet.ships[0], false, undefined, true);
sheet.setLoot(outcome.loot);
this.view.add.existing(sheet);
});

View file

@ -62,7 +62,9 @@ module TK.SpaceTac.UI {
this.anchor.set(0.5, 0.5);
this.setupDragDrop();
if (sheet.isInteractive()) {
this.setupDragDrop();
}
this.snapToContainer();
sheet.view.tooltip.bind(this, filler => this.fillTooltip(filler));

View file

@ -117,6 +117,29 @@ module TK.SpaceTac.UI.Specs {
draddrop(sprite, <CharacterSlot>sheet.ship_slots.children[0]);
check.equals(equ3.attached_to, null);
});
test.case("controls global interactivity state", check => {
let sheet = new CharacterSheet(testgame.view);
check.equals(sheet.isInteractive(), false, "no ship");
let ship = new Ship();
ship.critical = true;
sheet.show(ship);
check.equals(sheet.isInteractive(), false, "critical ship");
ship.critical = false;
sheet.show(ship);
check.equals(sheet.isInteractive(), true, "normal ship");
sheet.show(ship, undefined, undefined, false);
check.equals(sheet.isInteractive(), false, "interactivity disabled");
sheet.show(ship);
check.equals(sheet.isInteractive(), false, "interactivity stays disabled");
sheet.show(ship, undefined, undefined, true);
check.equals(sheet.isInteractive(), true, "interactivity reenabled");
});
});
test.case("fits slots in area", check => {

View file

@ -8,6 +8,9 @@ module TK.SpaceTac.UI {
* Character sheet, displaying ship characteristics
*/
export class CharacterSheet extends Phaser.Image {
// Globally interactive sheet (equipment can be moved, points upgraded)
interactive = true
// Parent view
view: BaseView
@ -133,6 +136,13 @@ module TK.SpaceTac.UI {
this.addAttribute("skill_time", x2, y + 320);
}
/**
* Check if the sheet should be interactive
*/
isInteractive(): boolean {
return bool(this.ship) && !this.ship.critical && this.interactive;
}
/**
* Add an attribute display
*/
@ -188,8 +198,11 @@ module TK.SpaceTac.UI {
/**
* Show the sheet for a given ship
*/
show(ship: Ship, animate = true, sound = true) {
show(ship: Ship, animate = true, sound = true, interactive?: boolean) {
this.ship = ship;
if (typeof interactive != "undefined") {
this.interactive = interactive;
}
this.layer_equipments.removeAll(true);
this.setActionMessage();
@ -200,7 +213,7 @@ module TK.SpaceTac.UI {
this.ship_level.setText(ship.level.get().toString());
this.ship_experience.setValue(ship.level.getExperience(), ship.level.getNextGoal());
this.ship_upgrade_points.setText(upgrade_points.toString());
this.layer_upgrades.visible = !ship.critical && upgrade_points > 0;
this.layer_upgrades.visible = this.isInteractive() && upgrade_points > 0;
iteritems(<any>ship.attributes, (key, value: ShipAttribute) => {
let text = this.attributes[key];
@ -214,7 +227,7 @@ module TK.SpaceTac.UI {
ship.slots.forEach((slot, idx) => {
let slot_display = new CharacterSlot(this, slotsinfo.positions[idx].x, slotsinfo.positions[idx].y, slot.type);
slot_display.scale.set(slotsinfo.scaling, slotsinfo.scaling);
slot_display.alpha = ship.critical ? 0.5 : 1;
slot_display.alpha = this.isInteractive() ? 1 : 0.5;
this.ship_slots.add(slot_display);
if (slot.attached) {
@ -228,7 +241,7 @@ module TK.SpaceTac.UI {
range(ship.cargo_space).forEach(idx => {
let cargo_slot = new CharacterCargo(this, slotsinfo.positions[idx].x, slotsinfo.positions[idx].y);
cargo_slot.scale.set(slotsinfo.scaling, slotsinfo.scaling);
cargo_slot.alpha = ship.critical ? 0.5 : 1;
cargo_slot.alpha = this.isInteractive() ? 1 : 0.5;
this.ship_cargo.add(cargo_slot);
if (idx < this.ship.cargo.length) {