mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-30 16:05:52 +01:00
* Move phase types out of phase interceptor * Create isXPhase method and add properties to each phase * Replace instanceof phase with isXPhase * Fix missing union types for phaseName * Update doc comment in phase.ts * Fix incomplete comment in encounter-phase * Make phaseName as public and fix more uses * Move phaseName property declaration before constructor in move anim phase Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Rename isXPhase to is --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
86 lines
2.8 KiB
TypeScript
86 lines
2.8 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { EncounterPhase } from "./encounter-phase";
|
|
|
|
/**
|
|
* The phase between defeating an encounter and starting another wild wave.
|
|
* Handles generating, loading and preparing for it.
|
|
*/
|
|
export class NextEncounterPhase extends EncounterPhase {
|
|
public readonly phaseName: "NextEncounterPhase" | "NewBiomeEncounterPhase" = "NextEncounterPhase";
|
|
start() {
|
|
super.start();
|
|
}
|
|
|
|
doEncounter(): void {
|
|
globalScene.playBgm(undefined, true);
|
|
|
|
// Reset all player transient wave data/intel before starting a new wild encounter.
|
|
// We exclusively reset wave data here as wild waves are considered one continuous "battle"
|
|
// for lack of an arena transition.
|
|
for (const pokemon of globalScene.getPlayerParty()) {
|
|
if (pokemon) {
|
|
pokemon.resetWaveData();
|
|
}
|
|
}
|
|
|
|
globalScene.arenaNextEnemy.setBiome(globalScene.arena.biomeType);
|
|
globalScene.arenaNextEnemy.setVisible(true);
|
|
|
|
const enemyField = globalScene.getEnemyField();
|
|
const moveTargets: any[] = [
|
|
globalScene.arenaEnemy,
|
|
globalScene.arenaNextEnemy,
|
|
globalScene.currentBattle.trainer,
|
|
enemyField,
|
|
globalScene.lastEnemyTrainer,
|
|
];
|
|
const lastEncounterVisuals = globalScene.lastMysteryEncounter?.introVisuals;
|
|
if (lastEncounterVisuals) {
|
|
moveTargets.push(lastEncounterVisuals);
|
|
}
|
|
const nextEncounterVisuals = globalScene.currentBattle.mysteryEncounter?.introVisuals;
|
|
if (nextEncounterVisuals) {
|
|
const enterFromRight = nextEncounterVisuals.enterFromRight;
|
|
if (enterFromRight) {
|
|
nextEncounterVisuals.x += 500;
|
|
globalScene.tweens.add({
|
|
targets: nextEncounterVisuals,
|
|
x: "-=200",
|
|
duration: 2000,
|
|
});
|
|
} else {
|
|
moveTargets.push(nextEncounterVisuals);
|
|
}
|
|
}
|
|
|
|
globalScene.tweens.add({
|
|
targets: moveTargets.flat(),
|
|
x: "+=300",
|
|
duration: 2000,
|
|
onComplete: () => {
|
|
globalScene.arenaEnemy.setBiome(globalScene.arena.biomeType);
|
|
globalScene.arenaEnemy.setX(globalScene.arenaNextEnemy.x);
|
|
globalScene.arenaEnemy.setAlpha(1);
|
|
globalScene.arenaNextEnemy.setX(globalScene.arenaNextEnemy.x - 300);
|
|
globalScene.arenaNextEnemy.setVisible(false);
|
|
if (globalScene.lastEnemyTrainer) {
|
|
globalScene.lastEnemyTrainer.destroy();
|
|
}
|
|
if (lastEncounterVisuals) {
|
|
globalScene.field.remove(lastEncounterVisuals, true);
|
|
globalScene.lastMysteryEncounter!.introVisuals = undefined;
|
|
}
|
|
|
|
if (!this.tryOverrideForBattleSpec()) {
|
|
this.doEncounterCommon();
|
|
}
|
|
},
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Do nothing (since this is simply the next wave in the same biome).
|
|
*/
|
|
trySetWeatherIfNewBiome(): void {}
|
|
}
|