mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-21 15:52:18 +02:00
Stop ShowAbilityPhase from ending until the bar has popped out
This commit is contained in:
parent
db37dcc204
commit
2ab325c900
@ -17,13 +17,15 @@ export class ShowAbilityPhase extends PokemonPhase {
|
||||
const pokemon = this.getPokemon();
|
||||
|
||||
if (pokemon) {
|
||||
globalScene.abilityBar.showAbility(pokemon, this.passive);
|
||||
globalScene.abilityBar.showAbility(pokemon, this.passive).then(() => {
|
||||
if (pokemon?.battleData) {
|
||||
pokemon.battleData.abilityRevealed = true;
|
||||
}
|
||||
|
||||
if (pokemon?.battleData) {
|
||||
pokemon.battleData.abilityRevealed = true;
|
||||
}
|
||||
this.end();
|
||||
});
|
||||
} else {
|
||||
this.end();
|
||||
}
|
||||
|
||||
this.end();
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,6 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
|
||||
private bg: Phaser.GameObjects.Image;
|
||||
private abilityBarText: Phaser.GameObjects.Text;
|
||||
|
||||
private tween: Phaser.Tweens.Tween | null;
|
||||
private autoHideTimer: NodeJS.Timeout | null;
|
||||
|
||||
public shown: boolean;
|
||||
|
||||
constructor() {
|
||||
@ -36,66 +33,55 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
|
||||
this.shown = false;
|
||||
}
|
||||
|
||||
showAbility(pokemon: Pokemon, passive: boolean = false): void {
|
||||
this.abilityBarText.setText(`${i18next.t("fightUiHandler:abilityFlyInText", { pokemonName: getPokemonNameWithAffix(pokemon), passive: passive ? i18next.t("fightUiHandler:passive") : "", abilityName: !passive ? pokemon.getAbility().name : pokemon.getPassiveAbility().name })}`);
|
||||
override setVisible(shown: boolean): this {
|
||||
this.shown = shown;
|
||||
super.setVisible(shown);
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.shown) {
|
||||
return;
|
||||
startTween(config: any, text?: string): Promise<void> {
|
||||
this.setVisible(true);
|
||||
this.shown = true;
|
||||
if (text) {
|
||||
this.abilityBarText.setText(text);
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
globalScene.tweens.add({
|
||||
...config,
|
||||
onComplete: () => {
|
||||
if (config.onComplete) {
|
||||
config.onComplete();
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
showAbility(pokemon: Pokemon, passive: boolean = false): Promise<void> {
|
||||
const text = (`${i18next.t("fightUiHandler:abilityFlyInText", { pokemonName: getPokemonNameWithAffix(pokemon), passive: passive ? i18next.t("fightUiHandler:passive") : "", abilityName: !passive ? pokemon.getAbility().name : pokemon.getPassiveAbility().name })}`);
|
||||
|
||||
globalScene.fieldUI.bringToTop(this);
|
||||
|
||||
|
||||
this.y = baseY + (globalScene.currentBattle.double ? 14 : 0);
|
||||
this.tween = globalScene.tweens.add({
|
||||
return this.startTween({
|
||||
targets: this,
|
||||
x: shownX,
|
||||
duration: 500,
|
||||
ease: "Sine.easeOut",
|
||||
onComplete: () => {
|
||||
this.tween = null;
|
||||
this.resetAutoHideTimer();
|
||||
}
|
||||
});
|
||||
|
||||
this.setVisible(true);
|
||||
this.shown = true;
|
||||
hold: 1000,
|
||||
}, text);
|
||||
}
|
||||
|
||||
hide(): void {
|
||||
if (!this.shown) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.autoHideTimer) {
|
||||
clearInterval(this.autoHideTimer);
|
||||
}
|
||||
|
||||
if (this.tween) {
|
||||
this.tween.stop();
|
||||
}
|
||||
|
||||
this.tween = globalScene.tweens.add({
|
||||
this.startTween({
|
||||
targets: this,
|
||||
x: -91,
|
||||
duration: 500,
|
||||
ease: "Sine.easeIn",
|
||||
onComplete: () => {
|
||||
this.tween = null;
|
||||
this.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
this.shown = false;
|
||||
}
|
||||
|
||||
resetAutoHideTimer(): void {
|
||||
if (this.autoHideTimer) {
|
||||
clearInterval(this.autoHideTimer);
|
||||
}
|
||||
this.autoHideTimer = setTimeout(() => {
|
||||
this.hide();
|
||||
this.autoHideTimer = null;
|
||||
}, 2500);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user