2025-01-12 15:33:05 -08:00
|
|
|
import { globalScene } from "#app/global-scene";
|
|
|
|
import type { Biome } from "#app/enums/biome";
|
2024-09-07 21:37:37 -07:00
|
|
|
import { getBiomeKey } from "#app/field/arena";
|
2024-08-19 03:23:52 +01:00
|
|
|
import { BattlePhase } from "./battle-phase";
|
|
|
|
|
|
|
|
export class SwitchBiomePhase extends BattlePhase {
|
|
|
|
private nextBiome: Biome;
|
|
|
|
|
2025-01-12 15:33:05 -08:00
|
|
|
constructor(nextBiome: Biome) {
|
|
|
|
super();
|
2024-08-19 03:23:52 +01:00
|
|
|
|
|
|
|
this.nextBiome = nextBiome;
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
super.start();
|
|
|
|
|
|
|
|
if (this.nextBiome === undefined) {
|
|
|
|
return this.end();
|
|
|
|
}
|
|
|
|
|
2025-01-12 15:33:05 -08:00
|
|
|
globalScene.tweens.add({
|
|
|
|
targets: [ globalScene.arenaEnemy, globalScene.lastEnemyTrainer ],
|
2024-08-19 03:23:52 +01:00
|
|
|
x: "+=300",
|
|
|
|
duration: 2000,
|
|
|
|
onComplete: () => {
|
2025-01-12 15:33:05 -08:00
|
|
|
globalScene.arenaEnemy.setX(globalScene.arenaEnemy.x - 600);
|
2024-08-19 03:23:52 +01:00
|
|
|
|
2025-01-12 15:33:05 -08:00
|
|
|
globalScene.newArena(this.nextBiome);
|
2024-08-19 03:23:52 +01:00
|
|
|
|
|
|
|
const biomeKey = getBiomeKey(this.nextBiome);
|
|
|
|
const bgTexture = `${biomeKey}_bg`;
|
2025-01-12 15:33:05 -08:00
|
|
|
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);
|
2024-08-19 03:23:52 +01:00
|
|
|
|
2025-01-12 15:33:05 -08:00
|
|
|
globalScene.tweens.add({
|
|
|
|
targets: [ globalScene.arenaPlayer, globalScene.arenaBgTransition, globalScene.arenaPlayerTransition ],
|
2024-08-19 03:23:52 +01:00
|
|
|
duration: 1000,
|
|
|
|
delay: 1000,
|
|
|
|
ease: "Sine.easeInOut",
|
2025-01-12 15:33:05 -08:00
|
|
|
alpha: (target: any) => target === globalScene.arenaPlayer ? 0 : 1,
|
2024-08-19 03:23:52 +01:00
|
|
|
onComplete: () => {
|
2025-01-12 15:33:05 -08:00
|
|
|
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();
|
2024-08-19 03:23:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.end();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|