2023-04-10 17:54:06 +00:00
|
|
|
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
|
2024-02-22 04:57:49 +00:00
|
|
|
import { Phase } from "./phase";
|
2023-04-10 17:54:06 +00:00
|
|
|
import BattleScene from "./battle-scene";
|
2024-02-26 18:50:55 +00:00
|
|
|
import { SpeciesFormEvolution } from "./data/pokemon-evolutions";
|
2023-04-10 17:54:06 +00:00
|
|
|
import EvolutionSceneHandler from "./ui/evolution-scene-handler";
|
|
|
|
import * as Utils from "./utils";
|
|
|
|
import { Mode } from "./ui/ui";
|
2024-02-22 04:57:49 +00:00
|
|
|
import { LearnMovePhase } from "./phases";
|
2024-03-01 01:08:50 +00:00
|
|
|
import { cos, sin } from "./field/anims";
|
|
|
|
import { PlayerPokemon } from "./field/pokemon";
|
2024-02-17 05:40:03 +00:00
|
|
|
import { getTypeRgb } from "./data/type";
|
2024-05-15 17:31:18 +00:00
|
|
|
import i18next from "i18next";
|
2023-04-10 17:54:06 +00:00
|
|
|
|
2024-02-22 04:57:49 +00:00
|
|
|
export class EvolutionPhase extends Phase {
|
2024-01-10 04:34:43 +00:00
|
|
|
protected pokemon: PlayerPokemon;
|
|
|
|
protected lastLevel: integer;
|
2024-05-23 23:45:04 +00:00
|
|
|
|
2024-02-26 18:50:55 +00:00
|
|
|
private evolution: SpeciesFormEvolution;
|
2024-01-10 04:34:43 +00:00
|
|
|
|
|
|
|
protected evolutionContainer: Phaser.GameObjects.Container;
|
|
|
|
protected evolutionBaseBg: Phaser.GameObjects.Image;
|
|
|
|
protected evolutionBg: Phaser.GameObjects.Video;
|
|
|
|
protected evolutionBgOverlay: Phaser.GameObjects.Rectangle;
|
|
|
|
protected evolutionOverlay: Phaser.GameObjects.Rectangle;
|
|
|
|
protected pokemonSprite: Phaser.GameObjects.Sprite;
|
|
|
|
protected pokemonTintSprite: Phaser.GameObjects.Sprite;
|
|
|
|
protected pokemonEvoSprite: Phaser.GameObjects.Sprite;
|
|
|
|
protected pokemonEvoTintSprite: Phaser.GameObjects.Sprite;
|
|
|
|
|
2024-02-26 18:50:55 +00:00
|
|
|
constructor(scene: BattleScene, pokemon: PlayerPokemon, evolution: SpeciesFormEvolution, lastLevel: integer) {
|
2023-04-10 17:54:06 +00:00
|
|
|
super(scene);
|
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
this.pokemon = pokemon;
|
2023-04-10 17:54:06 +00:00
|
|
|
this.evolution = evolution;
|
|
|
|
this.lastLevel = lastLevel;
|
|
|
|
}
|
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
validate(): boolean {
|
|
|
|
return !!this.evolution;
|
|
|
|
}
|
|
|
|
|
|
|
|
setMode(): Promise<void> {
|
|
|
|
return this.scene.ui.setModeForceTransition(Mode.EVOLUTION_SCENE);
|
|
|
|
}
|
|
|
|
|
2023-04-10 17:54:06 +00:00
|
|
|
start() {
|
|
|
|
super.start();
|
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
this.setMode().then(() => {
|
2023-04-10 17:54:06 +00:00
|
|
|
|
2024-05-23 15:03:10 +00:00
|
|
|
if (!this.validate()) {
|
2023-12-07 22:43:56 +00:00
|
|
|
return this.end();
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
|
2023-04-22 02:59:09 +00:00
|
|
|
this.scene.fadeOutBgm(null, false);
|
2023-04-10 17:54:06 +00:00
|
|
|
|
2023-12-14 16:54:56 +00:00
|
|
|
const evolutionHandler = this.scene.ui.getHandler() as EvolutionSceneHandler;
|
|
|
|
|
|
|
|
this.evolutionContainer = evolutionHandler.evolutionContainer;
|
2023-04-10 17:54:06 +00:00
|
|
|
|
2024-05-23 15:03:10 +00:00
|
|
|
this.evolutionBaseBg = this.scene.add.image(0, 0, "default_bg");
|
2023-04-10 17:54:06 +00:00
|
|
|
this.evolutionBaseBg.setOrigin(0, 0);
|
|
|
|
this.evolutionContainer.add(this.evolutionBaseBg);
|
|
|
|
|
2024-05-23 15:03:10 +00:00
|
|
|
this.evolutionBg = this.scene.add.video(0, 0, "evo_bg").stop();
|
2023-04-10 17:54:06 +00:00
|
|
|
this.evolutionBg.setOrigin(0, 0);
|
|
|
|
this.evolutionBg.setScale(0.4359673025);
|
|
|
|
this.evolutionBg.setVisible(false);
|
|
|
|
this.evolutionContainer.add(this.evolutionBg);
|
|
|
|
|
|
|
|
this.evolutionBgOverlay = this.scene.add.rectangle(0, 0, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6, 0x262626);
|
|
|
|
this.evolutionBgOverlay.setOrigin(0, 0);
|
|
|
|
this.evolutionBgOverlay.setAlpha(0);
|
|
|
|
this.evolutionContainer.add(this.evolutionBgOverlay);
|
|
|
|
|
2024-04-21 22:22:33 +00:00
|
|
|
const getPokemonSprite = () => {
|
2024-05-23 15:03:10 +00:00
|
|
|
const ret = this.scene.addPokemonSprite(this.pokemon, this.evolutionBaseBg.displayWidth / 2, this.evolutionBaseBg.displayHeight / 2, "pkmn__sub");
|
2024-04-21 22:22:33 +00:00
|
|
|
ret.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true });
|
|
|
|
return ret;
|
|
|
|
};
|
2023-04-10 17:54:06 +00:00
|
|
|
|
|
|
|
this.evolutionContainer.add((this.pokemonSprite = getPokemonSprite()));
|
|
|
|
this.evolutionContainer.add((this.pokemonTintSprite = getPokemonSprite()));
|
|
|
|
this.evolutionContainer.add((this.pokemonEvoSprite = getPokemonSprite()));
|
|
|
|
this.evolutionContainer.add((this.pokemonEvoTintSprite = getPokemonSprite()));
|
|
|
|
|
|
|
|
this.pokemonTintSprite.setAlpha(0);
|
|
|
|
this.pokemonTintSprite.setTintFill(0xFFFFFF);
|
|
|
|
this.pokemonEvoSprite.setVisible(false);
|
|
|
|
this.pokemonEvoTintSprite.setVisible(false);
|
|
|
|
this.pokemonEvoTintSprite.setTintFill(0xFFFFFF);
|
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
this.evolutionOverlay = this.scene.add.rectangle(0, -this.scene.game.canvas.height / 6, this.scene.game.canvas.width / 6, (this.scene.game.canvas.height / 6) - 48, 0xFFFFFF);
|
2023-04-10 17:54:06 +00:00
|
|
|
this.evolutionOverlay.setOrigin(0, 0);
|
|
|
|
this.evolutionOverlay.setAlpha(0);
|
2024-01-10 04:34:43 +00:00
|
|
|
this.scene.ui.add(this.evolutionOverlay);
|
2023-04-10 17:54:06 +00:00
|
|
|
|
2023-11-24 14:19:18 +00:00
|
|
|
[ this.pokemonSprite, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => {
|
2024-01-10 04:34:43 +00:00
|
|
|
sprite.play(this.pokemon.getSpriteKey(true));
|
2024-02-17 05:40:03 +00:00
|
|
|
sprite.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(this.pokemon.getTeraType()) });
|
2024-05-23 15:03:10 +00:00
|
|
|
sprite.setPipelineData("ignoreTimeTint", true);
|
|
|
|
sprite.setPipelineData("spriteKey", this.pokemon.getSpriteKey());
|
|
|
|
sprite.setPipelineData("shiny", this.pokemon.shiny);
|
|
|
|
sprite.setPipelineData("variant", this.pokemon.variant);
|
|
|
|
[ "spriteColors", "fusionSpriteColors" ].map(k => {
|
|
|
|
if (this.pokemon.summonData?.speciesForm) {
|
|
|
|
k += "Base";
|
|
|
|
}
|
2024-01-10 04:34:43 +00:00
|
|
|
sprite.pipelineData[k] = this.pokemon.getSprite().pipelineData[k];
|
2023-11-24 20:12:26 +00:00
|
|
|
});
|
2023-11-24 14:19:18 +00:00
|
|
|
});
|
2023-04-10 17:54:06 +00:00
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
this.doEvolution();
|
|
|
|
});
|
|
|
|
}
|
2023-12-14 17:55:11 +00:00
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
doEvolution(): void {
|
|
|
|
const evolutionHandler = this.scene.ui.getHandler() as EvolutionSceneHandler;
|
|
|
|
const preName = this.pokemon.name;
|
2024-05-23 23:45:04 +00:00
|
|
|
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.ui.showText(i18next.t("menu:evolving", { pokemonName: preName }), null, () => {
|
2024-01-10 04:34:43 +00:00
|
|
|
this.pokemon.cry();
|
|
|
|
|
|
|
|
this.pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => {
|
|
|
|
|
|
|
|
[ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => {
|
|
|
|
sprite.play(evolvedPokemon.getSpriteKey(true));
|
2024-05-23 15:03:10 +00:00
|
|
|
sprite.setPipelineData("ignoreTimeTint", true);
|
|
|
|
sprite.setPipelineData("spriteKey", evolvedPokemon.getSpriteKey());
|
|
|
|
sprite.setPipelineData("shiny", evolvedPokemon.shiny);
|
|
|
|
sprite.setPipelineData("variant", evolvedPokemon.variant);
|
|
|
|
[ "spriteColors", "fusionSpriteColors" ].map(k => {
|
|
|
|
if (evolvedPokemon.summonData?.speciesForm) {
|
|
|
|
k += "Base";
|
|
|
|
}
|
2024-01-10 04:34:43 +00:00
|
|
|
sprite.pipelineData[k] = evolvedPokemon.getSprite().pipelineData[k];
|
2023-11-24 14:19:18 +00:00
|
|
|
});
|
2024-01-10 04:34:43 +00:00
|
|
|
});
|
2023-04-10 17:54:06 +00:00
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
this.scene.time.delayedCall(1000, () => {
|
2024-05-23 15:03:10 +00:00
|
|
|
const evolutionBgm = this.scene.playSoundWithoutBgm("evolution");
|
2024-01-10 04:34:43 +00:00
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: this.evolutionBgOverlay,
|
|
|
|
alpha: 1,
|
|
|
|
delay: 500,
|
|
|
|
duration: 1500,
|
2024-05-23 15:03:10 +00:00
|
|
|
ease: "Sine.easeOut",
|
2024-01-10 04:34:43 +00:00
|
|
|
onComplete: () => {
|
|
|
|
this.scene.time.delayedCall(1000, () => {
|
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: this.evolutionBgOverlay,
|
|
|
|
alpha: 0,
|
|
|
|
duration: 250
|
2023-04-10 17:54:06 +00:00
|
|
|
});
|
2024-01-10 04:34:43 +00:00
|
|
|
this.evolutionBg.setVisible(true);
|
|
|
|
this.evolutionBg.play();
|
|
|
|
});
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.playSound("charge");
|
2024-01-10 04:34:43 +00:00
|
|
|
this.doSpiralUpward();
|
|
|
|
this.scene.tweens.addCounter({
|
|
|
|
from: 0,
|
|
|
|
to: 1,
|
|
|
|
duration: 2000,
|
|
|
|
onUpdate: t => {
|
|
|
|
this.pokemonTintSprite.setAlpha(t.getValue());
|
|
|
|
},
|
|
|
|
onComplete: () => {
|
|
|
|
this.pokemonSprite.setVisible(false);
|
|
|
|
this.scene.time.delayedCall(1100, () => {
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.playSound("beam");
|
2024-01-10 04:34:43 +00:00
|
|
|
this.doArcDownward();
|
|
|
|
this.scene.time.delayedCall(1500, () => {
|
|
|
|
this.pokemonEvoTintSprite.setScale(0.25);
|
|
|
|
this.pokemonEvoTintSprite.setVisible(true);
|
|
|
|
evolutionHandler.canCancel = true;
|
|
|
|
this.doCycle(1).then(success => {
|
|
|
|
if (!success) {
|
|
|
|
|
|
|
|
this.pokemonSprite.setVisible(true);
|
|
|
|
this.pokemonTintSprite.setScale(1);
|
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ],
|
|
|
|
alpha: 0,
|
|
|
|
duration: 250,
|
|
|
|
onComplete: () => {
|
|
|
|
this.evolutionBg.setVisible(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
SoundFade.fadeOut(this.scene, evolutionBgm, 100);
|
|
|
|
|
|
|
|
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
|
|
|
|
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.ui.showText(i18next.t("menu:stoppedEvolving", { pokemonName: preName }), null, () => {
|
|
|
|
this.scene.ui.showText(i18next.t("menu:pauseEvolutionsQuestion", { pokemonName: preName }), null, () => {
|
2024-01-10 04:34:43 +00:00
|
|
|
const end = () => {
|
|
|
|
this.scene.ui.showText(null, 0);
|
|
|
|
this.scene.playBgm();
|
|
|
|
evolvedPokemon.destroy();
|
|
|
|
this.end();
|
|
|
|
};
|
|
|
|
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
|
|
|
|
this.scene.ui.revertMode();
|
|
|
|
this.pokemon.pauseEvolutions = true;
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.ui.showText(i18next.t("menu:evolutionsPaused", { pokemonName: preName }), null, end, 3000);
|
2024-01-10 04:34:43 +00:00
|
|
|
}, () => {
|
|
|
|
this.scene.ui.revertMode();
|
|
|
|
this.scene.time.delayedCall(3000, end);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, null, true);
|
|
|
|
return;
|
|
|
|
}
|
2024-05-23 23:45:04 +00:00
|
|
|
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.playSound("sparkle");
|
2024-01-10 04:34:43 +00:00
|
|
|
this.pokemonEvoSprite.setVisible(true);
|
|
|
|
this.doCircleInward();
|
|
|
|
this.scene.time.delayedCall(900, () => {
|
|
|
|
evolutionHandler.canCancel = false;
|
|
|
|
|
|
|
|
this.pokemon.evolve(this.evolution).then(() => {
|
|
|
|
const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true);
|
2024-05-23 15:03:10 +00:00
|
|
|
for (const lm of levelMoves) {
|
|
|
|
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.scene.getParty().indexOf(this.pokemon), lm[1]));
|
2024-05-23 23:45:04 +00:00
|
|
|
}
|
2024-01-10 04:34:43 +00:00
|
|
|
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
|
|
|
|
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.playSound("shine");
|
2024-01-10 04:34:43 +00:00
|
|
|
this.doSpray();
|
2023-12-14 16:54:56 +00:00
|
|
|
this.scene.tweens.add({
|
2024-01-10 04:34:43 +00:00
|
|
|
targets: this.evolutionOverlay,
|
|
|
|
alpha: 1,
|
2023-12-14 16:54:56 +00:00
|
|
|
duration: 250,
|
2024-05-23 15:03:10 +00:00
|
|
|
easing: "Sine.easeIn",
|
2023-12-14 16:54:56 +00:00
|
|
|
onComplete: () => {
|
2024-01-10 04:34:43 +00:00
|
|
|
this.evolutionBgOverlay.setAlpha(1);
|
2023-12-14 16:54:56 +00:00
|
|
|
this.evolutionBg.setVisible(false);
|
2024-01-10 04:34:43 +00:00
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ],
|
|
|
|
alpha: 0,
|
|
|
|
duration: 2000,
|
|
|
|
delay: 150,
|
2024-05-23 15:03:10 +00:00
|
|
|
easing: "Sine.easeIn",
|
2024-01-10 04:34:43 +00:00
|
|
|
onComplete: () => {
|
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: this.evolutionBgOverlay,
|
|
|
|
alpha: 0,
|
|
|
|
duration: 250,
|
|
|
|
onComplete: () => {
|
|
|
|
SoundFade.fadeOut(this.scene, evolutionBgm, 100);
|
|
|
|
this.scene.time.delayedCall(250, () => {
|
|
|
|
this.pokemon.cry();
|
|
|
|
this.scene.time.delayedCall(1250, () => {
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.playSoundWithoutBgm("evolution_fanfare");
|
2024-05-23 23:45:04 +00:00
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
evolvedPokemon.destroy();
|
2024-05-23 15:03:10 +00:00
|
|
|
this.scene.ui.showText(i18next.t("menu:evolutionDone", { pokemonName: preName, evolvedPokemonName: this.pokemon.name }), null, () => this.end(), null, true, Utils.fixedInt(4000));
|
2024-01-10 04:34:43 +00:00
|
|
|
this.scene.time.delayedCall(Utils.fixedInt(4250), () => this.scene.playBgm());
|
2023-12-14 17:55:11 +00:00
|
|
|
});
|
2024-01-10 04:34:43 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-12-14 17:55:11 +00:00
|
|
|
});
|
2023-12-14 16:54:56 +00:00
|
|
|
});
|
2023-04-10 17:54:06 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2024-01-10 04:34:43 +00:00
|
|
|
});
|
|
|
|
}
|
2024-05-23 15:03:10 +00:00
|
|
|
});
|
2024-01-10 04:34:43 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
});
|
|
|
|
});
|
2024-01-10 04:34:43 +00:00
|
|
|
});
|
|
|
|
}, 1000);
|
2023-04-10 17:54:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doSpiralUpward() {
|
|
|
|
let f = 0;
|
2024-05-23 23:45:04 +00:00
|
|
|
|
2023-04-10 17:54:06 +00:00
|
|
|
this.scene.tweens.addCounter({
|
|
|
|
repeat: 64,
|
2023-06-05 01:47:43 +00:00
|
|
|
duration: Utils.getFrameMs(1),
|
2023-04-10 17:54:06 +00:00
|
|
|
onRepeat: () => {
|
|
|
|
if (f < 64) {
|
|
|
|
if (!(f & 7)) {
|
2024-05-23 15:03:10 +00:00
|
|
|
for (let i = 0; i < 4; i++) {
|
2023-04-10 17:54:06 +00:00
|
|
|
this.doSpiralUpwardParticle((f & 120) * 2 + i * 64);
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
}
|
|
|
|
f++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
doArcDownward() {
|
|
|
|
let f = 0;
|
2024-05-23 23:45:04 +00:00
|
|
|
|
2023-04-10 17:54:06 +00:00
|
|
|
this.scene.tweens.addCounter({
|
|
|
|
repeat: 96,
|
2023-06-05 01:47:43 +00:00
|
|
|
duration: Utils.getFrameMs(1),
|
2023-04-10 17:54:06 +00:00
|
|
|
onRepeat: () => {
|
|
|
|
if (f < 96) {
|
|
|
|
if (f < 6) {
|
2024-05-23 15:03:10 +00:00
|
|
|
for (let i = 0; i < 9; i++) {
|
2023-04-10 17:54:06 +00:00
|
|
|
this.doArcDownParticle(i * 16);
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
}
|
|
|
|
f++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-01-10 04:34:43 +00:00
|
|
|
doCycle(l: number, lastCycle: integer = 15): Promise<boolean> {
|
2023-04-10 17:54:06 +00:00
|
|
|
return new Promise(resolve => {
|
2023-12-14 16:54:56 +00:00
|
|
|
const evolutionHandler = this.scene.ui.getHandler() as EvolutionSceneHandler;
|
2024-01-10 04:34:43 +00:00
|
|
|
const isLastCycle = l === lastCycle;
|
2023-04-10 17:54:06 +00:00
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: this.pokemonTintSprite,
|
|
|
|
scale: 0.25,
|
2024-05-23 15:03:10 +00:00
|
|
|
ease: "Cubic.easeInOut",
|
2023-04-10 17:54:06 +00:00
|
|
|
duration: 500 / l,
|
|
|
|
yoyo: !isLastCycle
|
|
|
|
});
|
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: this.pokemonEvoTintSprite,
|
|
|
|
scale: 1,
|
2024-05-23 15:03:10 +00:00
|
|
|
ease: "Cubic.easeInOut",
|
2023-04-10 17:54:06 +00:00
|
|
|
duration: 500 / l,
|
|
|
|
yoyo: !isLastCycle,
|
|
|
|
onComplete: () => {
|
2024-05-23 15:03:10 +00:00
|
|
|
if (evolutionHandler.cancelled) {
|
2023-12-14 16:54:56 +00:00
|
|
|
return resolve(false);
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
|
|
|
if (l < lastCycle) {
|
2024-01-10 04:34:43 +00:00
|
|
|
this.doCycle(l + 0.5, lastCycle).then(success => resolve(success));
|
2024-05-23 15:03:10 +00:00
|
|
|
} else {
|
2023-04-10 17:54:06 +00:00
|
|
|
this.pokemonTintSprite.setVisible(false);
|
2023-12-14 16:54:56 +00:00
|
|
|
resolve(true);
|
2023-04-10 17:54:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
doCircleInward() {
|
|
|
|
let f = 0;
|
2024-05-23 23:45:04 +00:00
|
|
|
|
2023-04-10 17:54:06 +00:00
|
|
|
this.scene.tweens.addCounter({
|
|
|
|
repeat: 48,
|
2023-06-05 01:47:43 +00:00
|
|
|
duration: Utils.getFrameMs(1),
|
2023-04-10 17:54:06 +00:00
|
|
|
onRepeat: () => {
|
|
|
|
if (!f) {
|
2024-05-23 15:03:10 +00:00
|
|
|
for (let i = 0; i < 16; i++) {
|
2023-04-10 17:54:06 +00:00
|
|
|
this.doCircleInwardParticle(i * 16, 4);
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
} else if (f === 32) {
|
2024-05-23 15:03:10 +00:00
|
|
|
for (let i = 0; i < 16; i++) {
|
2023-04-10 17:54:06 +00:00
|
|
|
this.doCircleInwardParticle(i * 16, 8);
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
}
|
|
|
|
f++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
doSpray() {
|
|
|
|
let f = 0;
|
2024-05-23 23:45:04 +00:00
|
|
|
|
2023-04-10 17:54:06 +00:00
|
|
|
this.scene.tweens.addCounter({
|
|
|
|
repeat: 48,
|
2023-06-05 01:47:43 +00:00
|
|
|
duration: Utils.getFrameMs(1),
|
2023-04-10 17:54:06 +00:00
|
|
|
onRepeat: () => {
|
|
|
|
if (!f) {
|
2024-05-23 15:03:10 +00:00
|
|
|
for (let i = 0; i < 8; i++) {
|
2023-04-10 17:54:06 +00:00
|
|
|
this.doSprayParticle(i);
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
|
|
|
} else if (f < 50) {
|
2023-04-10 17:54:06 +00:00
|
|
|
this.doSprayParticle(Utils.randInt(8));
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
f++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
doSpiralUpwardParticle(trigIndex: integer) {
|
|
|
|
const initialX = this.evolutionBaseBg.displayWidth / 2;
|
2024-05-23 15:03:10 +00:00
|
|
|
const particle = this.scene.add.image(initialX, 0, "evo_sparkle");
|
2023-04-10 17:54:06 +00:00
|
|
|
this.evolutionContainer.add(particle);
|
|
|
|
|
|
|
|
let f = 0;
|
|
|
|
let amp = 48;
|
|
|
|
|
|
|
|
const particleTimer = this.scene.tweens.addCounter({
|
|
|
|
repeat: -1,
|
2023-06-05 01:47:43 +00:00
|
|
|
duration: Utils.getFrameMs(1),
|
2023-04-10 17:54:06 +00:00
|
|
|
onRepeat: () => {
|
|
|
|
updateParticle();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const updateParticle = () => {
|
|
|
|
if (!f || particle.y > 8) {
|
|
|
|
particle.setPosition(initialX, 88 - (f * f) / 80);
|
2024-01-05 04:57:21 +00:00
|
|
|
particle.y += sin(trigIndex, amp) / 4;
|
|
|
|
particle.x += cos(trigIndex, amp);
|
2023-04-10 17:54:06 +00:00
|
|
|
particle.setScale(1 - (f / 80));
|
|
|
|
trigIndex += 4;
|
2024-05-23 15:03:10 +00:00
|
|
|
if (f & 1) {
|
2023-04-10 17:54:06 +00:00
|
|
|
amp--;
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
f++;
|
|
|
|
} else {
|
|
|
|
particle.destroy();
|
|
|
|
particleTimer.remove();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
updateParticle();
|
|
|
|
}
|
|
|
|
|
|
|
|
doArcDownParticle(trigIndex: integer) {
|
|
|
|
const initialX = this.evolutionBaseBg.displayWidth / 2;
|
2024-05-23 15:03:10 +00:00
|
|
|
const particle = this.scene.add.image(initialX, 0, "evo_sparkle");
|
2023-04-10 17:54:06 +00:00
|
|
|
particle.setScale(0.5);
|
|
|
|
this.evolutionContainer.add(particle);
|
|
|
|
|
|
|
|
let f = 0;
|
|
|
|
let amp = 8;
|
|
|
|
|
|
|
|
const particleTimer = this.scene.tweens.addCounter({
|
|
|
|
repeat: -1,
|
2023-06-05 01:47:43 +00:00
|
|
|
duration: Utils.getFrameMs(1),
|
2023-04-10 17:54:06 +00:00
|
|
|
onRepeat: () => {
|
|
|
|
updateParticle();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const updateParticle = () => {
|
|
|
|
if (!f || particle.y < 88) {
|
|
|
|
particle.setPosition(initialX, 8 + (f * f) / 5);
|
2024-01-05 04:57:21 +00:00
|
|
|
particle.y += sin(trigIndex, amp) / 4;
|
|
|
|
particle.x += cos(trigIndex, amp);
|
|
|
|
amp = 8 + sin(f * 4, 40);
|
2023-04-10 17:54:06 +00:00
|
|
|
f++;
|
|
|
|
} else {
|
|
|
|
particle.destroy();
|
|
|
|
particleTimer.remove();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
updateParticle();
|
|
|
|
}
|
|
|
|
|
|
|
|
doCircleInwardParticle(trigIndex: integer, speed: integer) {
|
|
|
|
const initialX = this.evolutionBaseBg.displayWidth / 2;
|
|
|
|
const initialY = this.evolutionBaseBg.displayHeight / 2;
|
2024-05-23 15:03:10 +00:00
|
|
|
const particle = this.scene.add.image(initialX, initialY, "evo_sparkle");
|
2023-04-10 17:54:06 +00:00
|
|
|
this.evolutionContainer.add(particle);
|
|
|
|
|
|
|
|
let amp = 120;
|
|
|
|
|
|
|
|
const particleTimer = this.scene.tweens.addCounter({
|
|
|
|
repeat: -1,
|
2023-06-05 01:47:43 +00:00
|
|
|
duration: Utils.getFrameMs(1),
|
2023-04-10 17:54:06 +00:00
|
|
|
onRepeat: () => {
|
|
|
|
updateParticle();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const updateParticle = () => {
|
|
|
|
if (amp > 8) {
|
|
|
|
particle.setPosition(initialX, initialY);
|
2024-01-05 04:57:21 +00:00
|
|
|
particle.y += sin(trigIndex, amp);
|
|
|
|
particle.x += cos(trigIndex, amp);
|
2023-04-10 17:54:06 +00:00
|
|
|
amp -= speed;
|
|
|
|
trigIndex += 4;
|
|
|
|
} else {
|
|
|
|
particle.destroy();
|
|
|
|
particleTimer.remove();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
updateParticle();
|
|
|
|
}
|
|
|
|
|
|
|
|
doSprayParticle(trigIndex: integer) {
|
|
|
|
const initialX = this.evolutionBaseBg.displayWidth / 2;
|
|
|
|
const initialY = this.evolutionBaseBg.displayHeight / 2;
|
2024-05-23 15:03:10 +00:00
|
|
|
const particle = this.scene.add.image(initialX, initialY, "evo_sparkle");
|
2023-04-10 17:54:06 +00:00
|
|
|
this.evolutionContainer.add(particle);
|
|
|
|
|
|
|
|
let f = 0;
|
|
|
|
let yOffset = 0;
|
2024-05-23 15:03:10 +00:00
|
|
|
const speed = 3 - Utils.randInt(8);
|
|
|
|
const amp = 48 + Utils.randInt(64);
|
2023-04-10 17:54:06 +00:00
|
|
|
|
|
|
|
const particleTimer = this.scene.tweens.addCounter({
|
|
|
|
repeat: -1,
|
2023-06-05 01:47:43 +00:00
|
|
|
duration: Utils.getFrameMs(1),
|
2023-04-10 17:54:06 +00:00
|
|
|
onRepeat: () => {
|
|
|
|
updateParticle();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const updateParticle = () => {
|
2024-05-23 15:03:10 +00:00
|
|
|
if (!(f & 3)) {
|
2023-04-10 17:54:06 +00:00
|
|
|
yOffset++;
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
if (trigIndex < 128) {
|
|
|
|
particle.setPosition(initialX + (speed * f) / 3, initialY + yOffset);
|
2024-01-05 04:57:21 +00:00
|
|
|
particle.y += -sin(trigIndex, amp);
|
2024-05-23 15:03:10 +00:00
|
|
|
if (f > 108) {
|
2023-04-10 17:54:06 +00:00
|
|
|
particle.setScale((1 - (f - 108) / 20));
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|
2023-04-10 17:54:06 +00:00
|
|
|
trigIndex++;
|
|
|
|
f++;
|
|
|
|
} else {
|
|
|
|
particle.destroy();
|
|
|
|
particleTimer.remove();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
updateParticle();
|
|
|
|
}
|
2023-05-18 15:11:06 +00:00
|
|
|
}
|
|
|
|
|
2024-02-22 04:57:49 +00:00
|
|
|
export class EndEvolutionPhase extends Phase {
|
2024-06-08 05:07:23 +00:00
|
|
|
|
|
|
|
constructor(scene: BattleScene) {
|
|
|
|
super(scene);
|
|
|
|
}
|
|
|
|
|
2023-05-18 15:11:06 +00:00
|
|
|
start() {
|
|
|
|
super.start();
|
|
|
|
|
|
|
|
this.scene.ui.setModeForceTransition(Mode.MESSAGE).then(() => this.end());
|
|
|
|
}
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|