Add faster evolution skipping

pull/35/head
Flashfyre 2024-04-04 18:54:50 -04:00
parent 36b3c91276
commit 87e0e06b9e
4 changed files with 83 additions and 59 deletions

View File

@ -30,6 +30,7 @@ export class EggHatchPhase extends Phase {
private pokemon: PlayerPokemon; private pokemon: PlayerPokemon;
private eggMoveIndex: integer; private eggMoveIndex: integer;
private hatched: boolean;
private canSkip: boolean; private canSkip: boolean;
private skipped: boolean; private skipped: boolean;
private evolutionBgm: AnySound; private evolutionBgm: AnySound;
@ -108,9 +109,11 @@ export class EggHatchPhase extends Phase {
this.pokemon = pokemon; this.pokemon = pokemon;
pokemon.loadAssets().then(() => { pokemon.loadAssets().then(() => {
this.canSkip = true;
this.scene.time.delayedCall(1000, () => { this.scene.time.delayedCall(1000, () => {
this.evolutionBgm = this.scene.playSoundWithoutBgm('evolution'); if (!this.skipped)
this.canSkip = true; this.evolutionBgm = this.scene.playSoundWithoutBgm('evolution');
}); });
this.scene.time.delayedCall(2000, () => { this.scene.time.delayedCall(2000, () => {
@ -190,13 +193,18 @@ export class EggHatchPhase extends Phase {
if (!this.canSkip || this.skipped) if (!this.canSkip || this.skipped)
return false; return false;
this.skipped = true; this.skipped = true;
this.doHatch(); if (!this.hatched)
this.doHatch();
else
this.doReveal();
return true; return true;
} }
doHatch(): void { doHatch(): void {
this.canSkip = false; this.canSkip = false;
SoundFade.fadeOut(this.scene, this.evolutionBgm, Utils.fixedInt(100)); this.hatched = true;
if (this.evolutionBgm)
SoundFade.fadeOut(this.scene, this.evolutionBgm, Utils.fixedInt(100));
for (let e = 0; e < 5; e++) for (let e = 0; e < 5; e++)
this.scene.time.delayedCall(Utils.fixedInt(375 * e), () => this.scene.playSound('egg_hatch', { volume: 1 - (e * 0.2) })); this.scene.time.delayedCall(Utils.fixedInt(375 * e), () => this.scene.playSound('egg_hatch', { volume: 1 - (e * 0.2) }));
this.eggLightraysOverlay.setVisible(true); this.eggLightraysOverlay.setVisible(true);
@ -205,51 +213,61 @@ export class EggHatchPhase extends Phase {
duration: Utils.fixedInt(125), duration: Utils.fixedInt(125),
targets: this.eggHatchOverlay, targets: this.eggHatchOverlay,
alpha: 1, alpha: 1,
ease: 'Cubic.easeIn' ease: 'Cubic.easeIn',
onComplete: () => {
this.skipped = false;
this.canSkip = true;
}
}); });
this.scene.time.delayedCall(Utils.fixedInt(1500), () => { this.scene.time.delayedCall(Utils.fixedInt(1500), () => {
const isShiny = this.pokemon.isShiny(); this.canSkip = false;
if (this.pokemon.species.mythical) if (!this.skipped)
this.scene.validateAchv(achvs.HATCH_MYTHICAL); this.doReveal();
if (this.pokemon.species.legendary) });
this.scene.validateAchv(achvs.HATCH_LEGENDARY); }
if (isShiny)
this.scene.validateAchv(achvs.HATCH_SHINY);
this.eggContainer.setVisible(false);
this.pokemonSprite.play(this.pokemon.getSpriteKey(true));
this.pokemonSprite.pipelineData['ignoreTimeTint'] = true;
this.pokemonSprite.setVisible(true);
this.scene.time.delayedCall(Utils.fixedInt(1000), () => {
this.pokemon.cry();
if (isShiny) {
this.scene.time.delayedCall(Utils.fixedInt(1250), () => {
this.pokemonShinySparkle.play('sparkle');
this.scene.playSound('sparkle');
});
}
this.scene.time.delayedCall(Utils.fixedInt(!isShiny ? 1250 : 1750), () => {
this.infoContainer.show(this.pokemon);
this.scene.playSoundWithoutBgm('evolution_fanfare'); doReveal(): void {
const isShiny = this.pokemon.isShiny();
this.scene.ui.showText(`${this.pokemon.name} hatched from the egg!`, null, () => { if (this.pokemon.species.mythical)
this.scene.gameData.updateSpeciesDexIvs(this.pokemon.species.speciesId, this.pokemon.ivs); this.scene.validateAchv(achvs.HATCH_MYTHICAL);
this.scene.gameData.setPokemonCaught(this.pokemon, true, true).then(() => { if (this.pokemon.species.legendary)
this.scene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex).then(() => { this.scene.validateAchv(achvs.HATCH_LEGENDARY);
this.scene.ui.showText(null, 0); if (isShiny)
this.end(); this.scene.validateAchv(achvs.HATCH_SHINY);
}); this.eggContainer.setVisible(false);
}); this.pokemonSprite.play(this.pokemon.getSpriteKey(true));
}, null, true, 3000); this.pokemonSprite.pipelineData['ignoreTimeTint'] = true;
//this.scene.time.delayedCall(Utils.fixedInt(4250), () => this.scene.playBgm()); this.pokemonSprite.setVisible(true);
this.scene.time.delayedCall(Utils.fixedInt(250), () => {
this.pokemon.cry();
if (isShiny) {
this.scene.time.delayedCall(Utils.fixedInt(500), () => {
this.pokemonShinySparkle.play('sparkle');
this.scene.playSound('sparkle');
}); });
}
this.scene.time.delayedCall(Utils.fixedInt(!this.skipped ? !isShiny ? 1250 : 1750 : !isShiny ? 250 : 750), () => {
this.infoContainer.show(this.pokemon, false, this.skipped ? 2 : 1);
this.scene.playSoundWithoutBgm('evolution_fanfare');
this.scene.ui.showText(`${this.pokemon.name} hatched from the egg!`, null, () => {
this.scene.gameData.updateSpeciesDexIvs(this.pokemon.species.speciesId, this.pokemon.ivs);
this.scene.gameData.setPokemonCaught(this.pokemon, true, true).then(() => {
this.scene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex).then(() => {
this.scene.ui.showText(null, 0);
this.end();
});
});
}, null, true, 3000);
//this.scene.time.delayedCall(Utils.fixedInt(4250), () => this.scene.playBgm());
}); });
this.scene.tweens.add({ });
duration: Utils.fixedInt(3000), this.scene.tweens.add({
targets: this.eggHatchOverlay, duration: Utils.fixedInt(this.skipped ? 500 : 3000),
alpha: 0, targets: this.eggHatchOverlay,
ease: 'Cubic.easeOut' alpha: 0,
}); ease: 'Cubic.easeOut'
}); });
} }
@ -288,14 +306,15 @@ export class EggHatchPhase extends Phase {
}); });
const updateParticle = () => { const updateParticle = () => {
yOffset++; const speedMultiplier = this.skipped ? 6 : 1;
yOffset += speedMultiplier;
if (trigIndex < 160) { if (trigIndex < 160) {
particle.setPosition(initialX + (speed * f) / 3, initialY + yOffset); particle.setPosition(initialX + (speed * f) / 3, initialY + yOffset);
particle.y += -this.sin(trigIndex, amp); particle.y += -this.sin(trigIndex, amp);
if (f > 108) if (f > 108)
particle.setScale((1 - (f - 108) / 20)); particle.setScale((1 - (f - 108) / 20));
trigIndex += 2; trigIndex += 2 * speedMultiplier;
f++; f += speedMultiplier;
} else { } else {
particle.destroy(); particle.destroy();
particleTimer.remove(); particleTimer.remove();

View File

@ -973,11 +973,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.fieldUI.moveAbove(this.battleInfo, otherBattleInfo); this.scene.fieldUI.moveAbove(this.battleInfo, otherBattleInfo);
this.battleInfo.setX(this.battleInfo.x + (this.isPlayer() ? 150 : !this.isBoss() ? -150 : -198)); this.battleInfo.setX(this.battleInfo.x + (this.isPlayer() ? 150 : !this.isBoss() ? -150 : -198));
this.battleInfo.setVisible(true); this.battleInfo.setVisible(true);
if (this.isPlayer())
this.battleInfo.expMaskRect.x += 150;
this.scene.tweens.add({ this.scene.tweens.add({
targets: this.battleInfo, targets: [ this.battleInfo, this.battleInfo.expMaskRect ],
x: this.isPlayer() ? '-=150' : `+=${!this.isBoss() ? 150 : 246}`, x: this.isPlayer() ? '-=150' : `+=${!this.isBoss() ? 150 : 246}`,
duration: 1000, duration: 1000,
ease: 'Sine.easeOut' ease: 'Cubic.easeOut'
}); });
} }
} }
@ -986,11 +988,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return new Promise(resolve => { return new Promise(resolve => {
if (this.battleInfo.visible) { if (this.battleInfo.visible) {
this.scene.tweens.add({ this.scene.tweens.add({
targets: this.battleInfo, targets: [ this.battleInfo, this.battleInfo.expMaskRect ],
x: this.isPlayer() ? '+=150' : `-=${!this.isBoss() ? 150 : 246}`, x: this.isPlayer() ? '+=150' : `-=${!this.isBoss() ? 150 : 246}`,
duration: 500, duration: 500,
ease: 'Sine.easeIn', ease: 'Cubic.easeIn',
onComplete: () => { onComplete: () => {
if (this.isPlayer())
this.battleInfo.expMaskRect.x -= 150;
this.battleInfo.setVisible(false); this.battleInfo.setVisible(false);
this.battleInfo.setX(this.battleInfo.x - (this.isPlayer() ? 150 : !this.isBoss() ? -150 : -198)); this.battleInfo.setX(this.battleInfo.x - (this.isPlayer() ? 150 : !this.isBoss() ? -150 : -198));
resolve(); resolve();

View File

@ -40,7 +40,8 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
private type1Icon: Phaser.GameObjects.Sprite; private type1Icon: Phaser.GameObjects.Sprite;
private type2Icon: Phaser.GameObjects.Sprite; private type2Icon: Phaser.GameObjects.Sprite;
private expBar: Phaser.GameObjects.Image; private expBar: Phaser.GameObjects.Image;
private expMaskRect: Phaser.GameObjects.Graphics;
public expMaskRect: Phaser.GameObjects.Graphics;
constructor(scene: Phaser.Scene, x: number, y: number, player: boolean) { constructor(scene: Phaser.Scene, x: number, y: number, player: boolean) {
super(scene, x, y); super(scene, x, y);

View File

@ -109,7 +109,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
this.setVisible(false); this.setVisible(false);
} }
show(pokemon: Pokemon, showMoves: boolean = false): Promise<void> { show(pokemon: Pokemon, showMoves: boolean = false, speedMultiplier: number = 1): Promise<void> {
return new Promise<void>(resolve => { return new Promise<void>(resolve => {
if (pokemon.gender > Gender.GENDERLESS) { if (pokemon.gender > Gender.GENDERLESS) {
this.pokemonGenderText.setText(getGenderSymbol(pokemon.gender)); this.pokemonGenderText.setText(getGenderSymbol(pokemon.gender));
@ -136,7 +136,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
this.scene.tweens.add({ this.scene.tweens.add({
targets: this, targets: this,
duration: Utils.fixedInt(750), duration: Utils.fixedInt(Math.floor(750 / speedMultiplier)),
ease: 'Cubic.easeInOut', ease: 'Cubic.easeInOut',
x: this.initialX - 104, x: this.initialX - 104,
onComplete: () => { onComplete: () => {
@ -146,9 +146,9 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
if (showMoves) { if (showMoves) {
this.scene.tweens.add({ this.scene.tweens.add({
delay: Utils.fixedInt(325), delay: Utils.fixedInt(Math.floor(325 / speedMultiplier)),
targets: this.pokemonMovesContainer, targets: this.pokemonMovesContainer,
duration: Utils.fixedInt(325), duration: Utils.fixedInt(Math.floor(325 / speedMultiplier)),
ease: 'Cubic.easeInOut', ease: 'Cubic.easeInOut',
x: this.movesContainerInitialX - 57, x: this.movesContainerInitialX - 57,
onComplete: () => resolve() onComplete: () => resolve()
@ -167,21 +167,21 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
}); });
} }
hide(): Promise<void> { hide(speedMultiplier: number = 1): Promise<void> {
return new Promise(resolve => { return new Promise(resolve => {
if (!this.shown) if (!this.shown)
return resolve(); return resolve();
this.scene.tweens.add({ this.scene.tweens.add({
targets: this.pokemonMovesContainer, targets: this.pokemonMovesContainer,
duration: Utils.fixedInt(750), duration: Utils.fixedInt(Math.floor(750 / speedMultiplier)),
ease: 'Cubic.easeInOut', ease: 'Cubic.easeInOut',
x: this.movesContainerInitialX x: this.movesContainerInitialX
}); });
this.scene.tweens.add({ this.scene.tweens.add({
targets: this, targets: this,
duration: Utils.fixedInt(750), duration: Utils.fixedInt(Math.floor(750 / speedMultiplier)),
ease: 'Cubic.easeInOut', ease: 'Cubic.easeInOut',
x: this.initialX, x: this.initialX,
onComplete: () => { onComplete: () => {