2024-05-05 16:30:00 +02:00
|
|
|
import BattleScene from "../battle-scene";
|
2024-02-20 00:24:39 -05:00
|
|
|
import { EggHatchPhase } from "../egg-hatch-phase";
|
2023-12-15 23:07:32 -05:00
|
|
|
import { Mode } from "./ui";
|
2023-12-20 19:19:23 -05:00
|
|
|
import UiHandler from "./ui-handler";
|
2024-06-13 11:30:47 -04:00
|
|
|
import {Button} from "../enums/buttons";
|
2023-12-15 23:07:32 -05:00
|
|
|
|
|
|
|
export default class EggHatchSceneHandler extends UiHandler {
|
2023-12-19 23:51:48 -05:00
|
|
|
public eggHatchContainer: Phaser.GameObjects.Container;
|
|
|
|
|
2024-06-11 09:20:00 +08:00
|
|
|
/**
|
|
|
|
* Allows subscribers to listen for events
|
|
|
|
*
|
|
|
|
* Current Events:
|
|
|
|
* - {@linkcode EggEventType.EGG_COUNT_CHANGED} {@linkcode EggCountChangedEvent}
|
|
|
|
*/
|
|
|
|
public readonly eventTarget: EventTarget = new EventTarget();
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
constructor(scene: BattleScene) {
|
|
|
|
super(scene, Mode.EGG_HATCH_SCENE);
|
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
this.eggHatchContainer = this.scene.add.container(0, -this.scene.game.canvas.height / 6);
|
|
|
|
this.scene.fieldUI.add(this.eggHatchContainer);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
const eggLightraysAnimFrames = this.scene.anims.generateFrameNames("egg_lightrays", { start: 0, end: 3 });
|
2024-05-24 22:57:28 -04:00
|
|
|
if (!(this.scene.anims.exists("egg_lightrays"))) {
|
|
|
|
this.scene.anims.create({
|
|
|
|
key: "egg_lightrays",
|
|
|
|
frames: eggLightraysAnimFrames,
|
|
|
|
frameRate: 32
|
|
|
|
});
|
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
|
|
|
|
2023-12-30 18:41:25 -05:00
|
|
|
show(_args: any[]): boolean {
|
2023-12-19 23:51:48 -05:00
|
|
|
super.show(_args);
|
|
|
|
|
|
|
|
this.getUi().showText(null, 0);
|
2023-12-30 18:41:25 -05:00
|
|
|
|
2024-04-06 21:48:48 -04:00
|
|
|
this.scene.setModifiersVisible(false);
|
|
|
|
|
2023-12-30 18:41:25 -05:00
|
|
|
return true;
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
processInput(button: Button): boolean {
|
2024-02-20 00:24:39 -05:00
|
|
|
if (button === Button.ACTION || button === Button.CANCEL) {
|
2024-02-20 07:12:03 -05:00
|
|
|
const phase = this.scene.getCurrentPhase();
|
2024-05-23 17:03:10 +02:00
|
|
|
if (phase instanceof EggHatchPhase && phase.trySkip()) {
|
2024-02-20 00:24:39 -05:00
|
|
|
return true;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-02-20 00:24:39 -05:00
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
return this.scene.ui.getMessageHandler().processInput(button);
|
|
|
|
}
|
|
|
|
|
|
|
|
setCursor(_cursor: integer): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
clear() {
|
|
|
|
super.clear();
|
|
|
|
this.eggHatchContainer.removeAll(true);
|
2024-04-19 16:21:35 -04:00
|
|
|
this.getUi().hideTooltip();
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|