Add auto mode and various changes
This commit is contained in:
1 parent
2f17903d30
commit
a739a1666f
14 files changed
+806
-502
No files matched your search
@@ -26,41 +26,7 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
|
||||
};
|
||||
if (prompt) {
|
||||
const originalCallback = callback;
|
||||
callback = () => {
|
||||
const wrappedTextLines = this.message.runWordWrap(this.message.text).split(/\n/g);
|
||||
const textLinesCount = wrappedTextLines.length;
|
||||
const lastTextLine = wrappedTextLines[wrappedTextLines.length - 1];
|
||||
const lastLineTest = this.scene.add.text(0, 0, lastTextLine, { font: '96px emerald' });
|
||||
lastLineTest.setScale(this.message.scale);
|
||||
const lastLineWidth = lastLineTest.displayWidth;
|
||||
lastLineTest.destroy();
|
||||
if (prompt) {
|
||||
if (this.prompt) {
|
||||
this.prompt.setPosition(lastLineWidth + 2, (textLinesCount - 1) * 18 + 2);
|
||||
this.prompt.play('prompt');
|
||||
}
|
||||
this.pendingPrompt = false;
|
||||
}
|
||||
this.awaitingActionInput = true;
|
||||
this.onActionInput = () => {
|
||||
if (this.prompt) {
|
||||
this.prompt.anims.stop();
|
||||
this.prompt.setVisible(false);
|
||||
}
|
||||
if (originalCallback) {
|
||||
if (callbackDelay) {
|
||||
this.textCallbackTimer = this.scene.time.delayedCall(callbackDelay, () => {
|
||||
if (this.textCallbackTimer) {
|
||||
this.textCallbackTimer.destroy();
|
||||
this.textCallbackTimer = null;
|
||||
}
|
||||
originalCallback();
|
||||
});
|
||||
} else
|
||||
originalCallback();
|
||||
}
|
||||
};
|
||||
};
|
||||
callback = () => this.showPrompt(originalCallback, callbackDelay);
|
||||
}
|
||||
if (delay) {
|
||||
this.clearText();
|
||||
@@ -94,6 +60,40 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
showPrompt(callback: Function, callbackDelay: integer) {
|
||||
const wrappedTextLines = this.message.runWordWrap(this.message.text).split(/\n/g);
|
||||
const textLinesCount = wrappedTextLines.length;
|
||||
const lastTextLine = wrappedTextLines[wrappedTextLines.length - 1];
|
||||
const lastLineTest = this.scene.add.text(0, 0, lastTextLine, { font: '96px emerald' });
|
||||
lastLineTest.setScale(this.message.scale);
|
||||
const lastLineWidth = lastLineTest.displayWidth;
|
||||
lastLineTest.destroy();
|
||||
if (this.prompt) {
|
||||
this.prompt.setPosition(lastLineWidth + 2, (textLinesCount - 1) * 18 + 2);
|
||||
this.prompt.play('prompt');
|
||||
}
|
||||
this.pendingPrompt = false;
|
||||
this.awaitingActionInput = true;
|
||||
this.onActionInput = () => {
|
||||
if (this.prompt) {
|
||||
this.prompt.anims.stop();
|
||||
this.prompt.setVisible(false);
|
||||
}
|
||||
if (callback) {
|
||||
if (callbackDelay) {
|
||||
this.textCallbackTimer = this.scene.time.delayedCall(callbackDelay, () => {
|
||||
if (this.textCallbackTimer) {
|
||||
this.textCallbackTimer.destroy();
|
||||
this.textCallbackTimer = null;
|
||||
}
|
||||
callback();
|
||||
});
|
||||
} else
|
||||
callback();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
clearText() {
|
||||
this.message.setText('');
|
||||
this.pendingPrompt = false;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Mode } from "./ui";
|
||||
export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
private overlayBg: Phaser.GameObjects.Rectangle;
|
||||
private modifierContainer: Phaser.GameObjects.Container;
|
||||
private options: ModifierOption[];
|
||||
public options: ModifierOption[];
|
||||
|
||||
private cursorObj: Phaser.GameObjects.Image;
|
||||
|
||||
@@ -66,8 +66,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
onUpdate: t => {
|
||||
const value = t.getValue();
|
||||
const index = Math.floor(value * types.length);
|
||||
if (index > i && index <= types.length)
|
||||
this.options[i++].show(Math.floor((1 - value) * 1250) * 0.325);
|
||||
if (index > i && index <= types.length) {
|
||||
const option = this.options[i++];
|
||||
option?.show(Math.floor((1 - value) * 1250) * 0.325);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -225,6 +227,8 @@ class ModifierOption extends Phaser.GameObjects.Container {
|
||||
duration: 1250,
|
||||
ease: 'Bounce.Out',
|
||||
onUpdate: t => {
|
||||
if (!this.scene)
|
||||
return;
|
||||
const value = t.getValue();
|
||||
if (!bounce && value > lastValue) {
|
||||
this.scene.sound.play('pb_bounce_1', { volume: 1 / ++bounceCount });
|
||||
@@ -236,6 +240,9 @@ class ModifierOption extends Phaser.GameObjects.Container {
|
||||
});
|
||||
|
||||
this.scene.time.delayedCall(remainingDuration + 2000, () => {
|
||||
if (!this.scene)
|
||||
return;
|
||||
|
||||
this.pb.setTexture('pb', `${this.getPbAtlasKey()}_open`);
|
||||
this.scene.sound.play('pb_rel');
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
this.partyMessageBox = partyMessageBox;
|
||||
|
||||
const partyMessageText = addTextObject(this.scene, 8, 10, defaultMessage, TextStyle.WINDOW, { maxLines: 2 });
|
||||
partyMessageText.setPositionRelative
|
||||
|
||||
partyMessageText.setOrigin(0, 0);
|
||||
partyMessageBoxContainer.add(partyMessageText);
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ export default abstract class UiHandler {
|
||||
protected scene: BattleScene;
|
||||
protected mode: integer;
|
||||
protected cursor: integer = 0;
|
||||
protected active: boolean = false;
|
||||
public active: boolean = false;
|
||||
|
||||
constructor(scene: BattleScene, mode: Mode) {
|
||||
this.scene = scene;
|
||||
|
||||
Reference in new issue
Block a user