Added fast forward option to speed up animations when clicking
This commit is contained in:
parent
7879457035
commit
ade6b8068d
2
TODO.md
2
TODO.md
|
@ -8,6 +8,7 @@ Phaser 3 migration
|
||||||
* Fit the game in window size
|
* Fit the game in window size
|
||||||
* Fix top-right messages positions
|
* Fix top-right messages positions
|
||||||
* Fix valuebar requiring to be in root display list
|
* Fix valuebar requiring to be in root display list
|
||||||
|
* Fix tactical mode button not working
|
||||||
* Restore unit tests about boundaries (in UITools)
|
* Restore unit tests about boundaries (in UITools)
|
||||||
|
|
||||||
Menu/settings/saves
|
Menu/settings/saves
|
||||||
|
@ -50,7 +51,6 @@ Battle
|
||||||
* Show a cooldown indicator on move action icon, if the simulation would cause the engine to overheat
|
* Show a cooldown indicator on move action icon, if the simulation would cause the engine to overheat
|
||||||
* Add an hexagonal grid (optional, may be enforced only on mobile) and work in units of this grid
|
* Add an hexagonal grid (optional, may be enforced only on mobile) and work in units of this grid
|
||||||
* Add engine trail effect, and sound
|
* Add engine trail effect, and sound
|
||||||
* Allow to skip animations, and allow no animation mode
|
|
||||||
* Find incentives to move from starting position (permanent drones or anomalies?)
|
* Find incentives to move from starting position (permanent drones or anomalies?)
|
||||||
* Mark targetting in error when target is refused by the action (there is already an arrow for this)
|
* Mark targetting in error when target is refused by the action (there is already an arrow for this)
|
||||||
* Allow to undo last moves
|
* Allow to undo last moves
|
||||||
|
|
|
@ -135,8 +135,14 @@ module TK.SpaceTac.UI {
|
||||||
this.inputs.bind("Escape", "Cancel action", () => this.action_bar.actionEnded());
|
this.inputs.bind("Escape", "Cancel action", () => this.action_bar.actionEnded());
|
||||||
range(10).forEach(i => this.inputs.bind(`Numpad${i % 10}`, `Action/target ${i}`, () => this.numberPressed(i)));
|
range(10).forEach(i => this.inputs.bind(`Numpad${i % 10}`, `Action/target ${i}`, () => this.numberPressed(i)));
|
||||||
range(10).forEach(i => this.inputs.bind(`Digit${i % 10}`, `Action/target ${i}`, () => this.numberPressed(i)));
|
range(10).forEach(i => this.inputs.bind(`Digit${i % 10}`, `Action/target ${i}`, () => this.numberPressed(i)));
|
||||||
this.inputs.bindCheat("w", "Win current battle", () => nn(this.player.getCheats()).win());
|
this.inputs.bindCheat("w", "Win current battle", () => {
|
||||||
this.inputs.bindCheat("x", "Lose current battle", () => nn(this.player.getCheats()).lose());
|
nn(this.player.getCheats()).win();
|
||||||
|
this.log_processor.fastForward();
|
||||||
|
});
|
||||||
|
this.inputs.bindCheat("x", "Lose current battle", () => {
|
||||||
|
nn(this.player.getCheats()).lose();
|
||||||
|
this.log_processor.fastForward();
|
||||||
|
});
|
||||||
this.inputs.bindCheat("a", "Use AI to play", () => this.playAI());
|
this.inputs.bindCheat("a", "Use AI to play", () => this.playAI());
|
||||||
|
|
||||||
// "Battle" animation, then start processing the log
|
// "Battle" animation, then start processing the log
|
||||||
|
@ -287,6 +293,8 @@ module TK.SpaceTac.UI {
|
||||||
} else if (this.ship_hovered && this.player.is(this.ship_hovered.fleet.player) && this.interacting) {
|
} else if (this.ship_hovered && this.player.is(this.ship_hovered.fleet.player) && this.interacting) {
|
||||||
this.character_sheet.show(this.ship_hovered);
|
this.character_sheet.show(this.ship_hovered);
|
||||||
this.setShipHovered(null);
|
this.setShipHovered(null);
|
||||||
|
} else {
|
||||||
|
this.log_processor.fastForward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@ module TK.SpaceTac.UI {
|
||||||
// Background delegates promises
|
// Background delegates promises
|
||||||
private background_promises: Promise<void>[] = []
|
private background_promises: Promise<void>[] = []
|
||||||
|
|
||||||
|
// Speed control
|
||||||
|
private speed = 1
|
||||||
|
private temp_speed?: number
|
||||||
|
|
||||||
// Debug indicators
|
// Debug indicators
|
||||||
private debug = false
|
private debug = false
|
||||||
private ai_disabled = false
|
private ai_disabled = false
|
||||||
|
@ -57,6 +61,10 @@ module TK.SpaceTac.UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.processBattleDiff(diff);
|
await this.processBattleDiff(diff);
|
||||||
|
|
||||||
|
if (this.log.atEnd()) {
|
||||||
|
this.temp_speed = undefined;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.transferControl();
|
this.transferControl();
|
||||||
|
@ -77,6 +85,15 @@ module TK.SpaceTac.UI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fast forward to the end of log, then resume normal speed
|
||||||
|
*/
|
||||||
|
fastForward(speed = 3): void {
|
||||||
|
if (!this.log.atEnd()) {
|
||||||
|
this.temp_speed = speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the processor
|
* Destroy the processor
|
||||||
*
|
*
|
||||||
|
@ -175,7 +192,7 @@ module TK.SpaceTac.UI {
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
console.log("Battle diff", diff);
|
console.log("Battle diff", diff);
|
||||||
}
|
}
|
||||||
let speed = timed ? 1 : 0;
|
let speed = timed ? (typeof this.temp_speed == "undefined" ? this.speed : this.temp_speed) : 0;
|
||||||
|
|
||||||
// TODO add priority to sort the delegates
|
// TODO add priority to sort the delegates
|
||||||
let delegates = this.subscriber.map(subscriber => subscriber(diff));
|
let delegates = this.subscriber.map(subscriber => subscriber(diff));
|
||||||
|
|
|
@ -115,7 +115,7 @@ module TK.SpaceTac.UI {
|
||||||
* Update the locations of all items
|
* Update the locations of all items
|
||||||
*/
|
*/
|
||||||
refresh(speed = 1): void {
|
refresh(speed = 1): void {
|
||||||
let duration = speed ? 1000 / speed : 0;
|
let duration = speed ? (1000 / speed) : 0;
|
||||||
this.items.forEach(item => {
|
this.items.forEach(item => {
|
||||||
if (item.ship.alive) {
|
if (item.ship.alive) {
|
||||||
let position = this.battle.getPlayOrder(item.ship);
|
let position = this.battle.getPlayOrder(item.ship);
|
||||||
|
|
|
@ -72,8 +72,8 @@ module TK.SpaceTac.UI {
|
||||||
|
|
||||||
builder.text(ship.model.getDescription(), 0, iy + 4, { size: 14, color: "#999999", width: 540 });
|
builder.text(ship.model.getDescription(), 0, iy + 4, { size: 14, color: "#999999", width: 540 });
|
||||||
} else {
|
} else {
|
||||||
builder.text("Emergency Stasis Protocol\nship disabled", 140, 36,
|
builder.text("Emergency Stasis Protocol\nship disabled", 230, 36,
|
||||||
{ color: "#a899db", size: 20, center: true, vcenter: true });
|
{ color: "#a899db", size: 20, center: false, vcenter: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue