mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-02-19 10:47:41 +00:00
* Replace various `scene` pass-arounds with global scene variable * Modify tests * Add scene back to `fade[in|out]()` calls Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Fix Bug Superfan ME test Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Re-enable fixed test Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Rename `gScene` to `globalScene` * Move `globalScene` to its own file to fix import/async issues * Fix `SelectModifierPhase` tests * Fix ME tests by removing `scene` from `expect()`s * Resolve merge issues * Remove tsdocs referencing `scene` params Remove missed instances of `.scene` * Remove unnecessary `globalScene` usage in `loading-scene.ts` * Fix merge conflicts * Attempt to fix circular import issue * Found the source of the import issue * Fix merge issues --------- Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com>
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import type { Biome } from "#app/enums/biome";
|
|
import { getBiomeKey } from "#app/field/arena";
|
|
import { BattlePhase } from "./battle-phase";
|
|
|
|
export class SwitchBiomePhase extends BattlePhase {
|
|
private nextBiome: Biome;
|
|
|
|
constructor(nextBiome: Biome) {
|
|
super();
|
|
|
|
this.nextBiome = nextBiome;
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
if (this.nextBiome === undefined) {
|
|
return this.end();
|
|
}
|
|
|
|
globalScene.tweens.add({
|
|
targets: [ globalScene.arenaEnemy, globalScene.lastEnemyTrainer ],
|
|
x: "+=300",
|
|
duration: 2000,
|
|
onComplete: () => {
|
|
globalScene.arenaEnemy.setX(globalScene.arenaEnemy.x - 600);
|
|
|
|
globalScene.newArena(this.nextBiome);
|
|
|
|
const biomeKey = getBiomeKey(this.nextBiome);
|
|
const bgTexture = `${biomeKey}_bg`;
|
|
globalScene.arenaBgTransition.setTexture(bgTexture);
|
|
globalScene.arenaBgTransition.setAlpha(0);
|
|
globalScene.arenaBgTransition.setVisible(true);
|
|
globalScene.arenaPlayerTransition.setBiome(this.nextBiome);
|
|
globalScene.arenaPlayerTransition.setAlpha(0);
|
|
globalScene.arenaPlayerTransition.setVisible(true);
|
|
|
|
globalScene.tweens.add({
|
|
targets: [ globalScene.arenaPlayer, globalScene.arenaBgTransition, globalScene.arenaPlayerTransition ],
|
|
duration: 1000,
|
|
delay: 1000,
|
|
ease: "Sine.easeInOut",
|
|
alpha: (target: any) => target === globalScene.arenaPlayer ? 0 : 1,
|
|
onComplete: () => {
|
|
globalScene.arenaBg.setTexture(bgTexture);
|
|
globalScene.arenaPlayer.setBiome(this.nextBiome);
|
|
globalScene.arenaPlayer.setAlpha(1);
|
|
globalScene.arenaEnemy.setBiome(this.nextBiome);
|
|
globalScene.arenaEnemy.setAlpha(1);
|
|
globalScene.arenaNextEnemy.setBiome(this.nextBiome);
|
|
globalScene.arenaBgTransition.setVisible(false);
|
|
globalScene.arenaPlayerTransition.setVisible(false);
|
|
if (globalScene.lastEnemyTrainer) {
|
|
globalScene.lastEnemyTrainer.destroy();
|
|
}
|
|
|
|
this.end();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|