Add endless mode
Add endless mode; prevent stat booster items from being transferred or stolen
This commit is contained in:
1 parent
ac9814e665
commit
9faa489f19
16 files changed
+241
-112
No files matched your search
@@ -1,17 +1,9 @@
|
||||
import BattleScene, { Button } from "../battle-scene";
|
||||
import OptionSelectUiHandler from "./option-select-ui-handler";
|
||||
import { addTextObject, TextStyle } from "./text";
|
||||
import { Mode } from "./ui";
|
||||
import UiHandler from "./uiHandler";
|
||||
|
||||
export default class ConfirmUiHandler extends UiHandler {
|
||||
private yesHandler: Function;
|
||||
private noHander: Function;
|
||||
|
||||
private confirmContainer: Phaser.GameObjects.Container;
|
||||
private confirmBg: Phaser.GameObjects.Image;
|
||||
|
||||
private cursorObj: Phaser.GameObjects.Image;
|
||||
|
||||
export default class ConfirmUiHandler extends OptionSelectUiHandler {
|
||||
private switchCheck: boolean;
|
||||
private switchCheckCursor: integer;
|
||||
|
||||
@@ -19,94 +11,34 @@ export default class ConfirmUiHandler extends UiHandler {
|
||||
super(scene, Mode.CONFIRM);
|
||||
}
|
||||
|
||||
setup() {
|
||||
const ui = this.getUi();
|
||||
|
||||
this.confirmContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 49, -49);
|
||||
this.confirmContainer.setVisible(false);
|
||||
ui.add(this.confirmContainer);
|
||||
getWindowName(): string {
|
||||
return 'boolean_window';
|
||||
}
|
||||
|
||||
this.confirmBg = this.scene.add.image(0, 0, 'boolean_window');
|
||||
this.confirmBg.setOrigin(0, 1);
|
||||
this.confirmContainer.add(this.confirmBg);
|
||||
getWindowWidth(): integer {
|
||||
return 48;
|
||||
}
|
||||
|
||||
const confirmText = addTextObject(this.scene, 0, 0, 'Yes\nNo', TextStyle.WINDOW, { maxLines: 2 });
|
||||
confirmText.setPositionRelative(this.confirmBg, 16, 9);
|
||||
confirmText.setLineSpacing(12);
|
||||
this.confirmContainer.add(confirmText);
|
||||
|
||||
this.setCursor(0);
|
||||
getOptions(): string[] {
|
||||
return [ 'Yes', 'No' ];
|
||||
}
|
||||
|
||||
show(args: any[]) {
|
||||
if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) {
|
||||
super.show(args);
|
||||
|
||||
this.yesHandler = args[0] as Function;
|
||||
this.noHander = args[1] as Function;
|
||||
this.switchCheck = args.length >= 3 && args[2] as boolean;
|
||||
|
||||
this.confirmContainer.setVisible(true);
|
||||
this.setCursor(this.switchCheck ? this.switchCheckCursor : 0);
|
||||
}
|
||||
}
|
||||
|
||||
processInput(button: Button) {
|
||||
const ui = this.getUi();
|
||||
|
||||
let success = false;
|
||||
|
||||
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||
success = true;
|
||||
if (button === Button.CANCEL)
|
||||
this.setCursor(1);
|
||||
const handler = this.cursor ? this.noHander : this.yesHandler;
|
||||
handler();
|
||||
this.clear();
|
||||
} else {
|
||||
switch (button) {
|
||||
case Button.UP:
|
||||
if (this.cursor)
|
||||
success = this.setCursor(0);
|
||||
break;
|
||||
case Button.DOWN:
|
||||
if (!this.cursor)
|
||||
success = this.setCursor(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
ui.playSelect();
|
||||
}
|
||||
|
||||
setCursor(cursor: integer): boolean {
|
||||
const ret = super.setCursor(cursor);
|
||||
|
||||
if (ret && this.switchCheck)
|
||||
this.switchCheckCursor = this.cursor;
|
||||
|
||||
if (!this.cursorObj) {
|
||||
this.cursorObj = this.scene.add.image(0, 0, 'cursor');
|
||||
this.confirmContainer.add(this.cursorObj);
|
||||
}
|
||||
|
||||
this.cursorObj.setPositionRelative(this.confirmBg, 12, this.cursor ? 33 : 17);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
clear() {
|
||||
super.clear();
|
||||
this.yesHandler = null;
|
||||
this.noHander = null;
|
||||
this.confirmContainer.setVisible(false);
|
||||
this.eraseCursor();
|
||||
}
|
||||
|
||||
eraseCursor() {
|
||||
if (this.cursorObj)
|
||||
this.cursorObj.destroy();
|
||||
this.cursorObj = null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user