mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-20 12:05:50 +02: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>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { TrainerSlot } from "#enums/trainer-slot";
|
|
import { Phase } from "#app/phase";
|
|
|
|
export abstract class BattlePhase extends Phase {
|
|
showEnemyTrainer(trainerSlot: TrainerSlot = TrainerSlot.NONE): void {
|
|
if (!globalScene.currentBattle.trainer) {
|
|
console.warn("Enemy trainer is missing!");
|
|
return;
|
|
}
|
|
const sprites = globalScene.currentBattle.trainer.getSprites();
|
|
const tintSprites = globalScene.currentBattle.trainer.getTintSprites();
|
|
for (let i = 0; i < sprites.length; i++) {
|
|
const visible = !trainerSlot || !i === (trainerSlot === TrainerSlot.TRAINER) || sprites.length < 2;
|
|
[sprites[i], tintSprites[i]].map(sprite => {
|
|
if (visible) {
|
|
sprite.x = trainerSlot || sprites.length < 2 ? 0 : i ? 16 : -16;
|
|
}
|
|
sprite.setVisible(visible);
|
|
sprite.clearTint();
|
|
});
|
|
sprites[i].setVisible(visible);
|
|
tintSprites[i].setVisible(visible);
|
|
sprites[i].clearTint();
|
|
tintSprites[i].clearTint();
|
|
}
|
|
globalScene.tweens.add({
|
|
targets: globalScene.currentBattle.trainer,
|
|
x: "-=16",
|
|
y: "+=16",
|
|
alpha: 1,
|
|
ease: "Sine.easeInOut",
|
|
duration: 750,
|
|
});
|
|
}
|
|
|
|
hideEnemyTrainer(): void {
|
|
globalScene.tweens.add({
|
|
targets: globalScene.currentBattle.trainer,
|
|
x: "+=16",
|
|
y: "-=16",
|
|
alpha: 0,
|
|
ease: "Sine.easeInOut",
|
|
duration: 750,
|
|
});
|
|
}
|
|
}
|