mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-20 20:15: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>
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { UiMode } from "#enums/ui-mode";
|
|
import UiHandler from "./ui-handler";
|
|
import { Button } from "#enums/buttons";
|
|
import { globalScene } from "#app/global-scene";
|
|
|
|
export default class EggHatchSceneHandler extends UiHandler {
|
|
public eggHatchContainer: Phaser.GameObjects.Container;
|
|
|
|
/**
|
|
* Allows subscribers to listen for events
|
|
*
|
|
* Current Events:
|
|
* - {@linkcode EggEventType.EGG_COUNT_CHANGED} {@linkcode EggCountChangedEvent}
|
|
*/
|
|
public readonly eventTarget: EventTarget = new EventTarget();
|
|
|
|
constructor() {
|
|
super(UiMode.EGG_HATCH_SCENE);
|
|
}
|
|
|
|
setup() {
|
|
this.eggHatchContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6);
|
|
globalScene.fieldUI.add(this.eggHatchContainer);
|
|
|
|
const eggLightraysAnimFrames = globalScene.anims.generateFrameNames("egg_lightrays", { start: 0, end: 3 });
|
|
if (!globalScene.anims.exists("egg_lightrays")) {
|
|
globalScene.anims.create({
|
|
key: "egg_lightrays",
|
|
frames: eggLightraysAnimFrames,
|
|
frameRate: 32,
|
|
});
|
|
}
|
|
}
|
|
|
|
show(_args: any[]): boolean {
|
|
super.show(_args);
|
|
|
|
this.getUi().showText("", 0);
|
|
|
|
globalScene.setModifiersVisible(false);
|
|
|
|
return true;
|
|
}
|
|
|
|
processInput(button: Button): boolean {
|
|
if (button === Button.ACTION || button === Button.CANCEL) {
|
|
const phase = globalScene.getCurrentPhase();
|
|
if (phase?.is("EggHatchPhase") && phase.trySkip()) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return globalScene.ui.getMessageHandler().processInput(button);
|
|
}
|
|
|
|
setCursor(_cursor: number): boolean {
|
|
return false;
|
|
}
|
|
|
|
clear() {
|
|
super.clear();
|
|
this.eggHatchContainer.removeAll(true);
|
|
this.getUi().hideTooltip();
|
|
}
|
|
}
|