Refactor controls and add random starter function
parent
15c3318bd5
commit
8e6e1fd233
|
@ -1,5 +1,5 @@
|
||||||
import { SelectModifierPhase } from "./battle-phases";
|
import { SelectModifierPhase } from "./battle-phases";
|
||||||
import BattleScene from "./battle-scene";
|
import BattleScene, { Button } from "./battle-scene";
|
||||||
import { ModifierTier, ModifierType, PokemonBaseStatBoosterModifierType, PokemonHpRestoreModifierType, PokemonReviveModifierType } from "./modifier";
|
import { ModifierTier, ModifierType, PokemonBaseStatBoosterModifierType, PokemonHpRestoreModifierType, PokemonReviveModifierType } from "./modifier";
|
||||||
import Pokemon, { AiType, EnemyPokemon, PlayerPokemon, PokemonMove } from "./pokemon";
|
import Pokemon, { AiType, EnemyPokemon, PlayerPokemon, PokemonMove } from "./pokemon";
|
||||||
import { Species } from "./species";
|
import { Species } from "./species";
|
||||||
|
@ -53,8 +53,6 @@ export function initAutoPlay() {
|
||||||
return originalAddCounter.apply(this, [ config ]);
|
return originalAddCounter.apply(this, [ config ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
|
|
||||||
PlayerPokemon.prototype.getNextMove = EnemyPokemon.prototype.getNextMove;
|
PlayerPokemon.prototype.getNextMove = EnemyPokemon.prototype.getNextMove;
|
||||||
|
|
||||||
const playerPokemon = this.getParty()[0] as PlayerPokemon;
|
const playerPokemon = this.getParty()[0] as PlayerPokemon;
|
||||||
|
@ -132,14 +130,14 @@ export function initAutoPlay() {
|
||||||
callbackDelay = 0;
|
callbackDelay = 0;
|
||||||
originalMessageUiHandlerShowPrompt.apply(this, [ callback, callbackDelay ]);
|
originalMessageUiHandlerShowPrompt.apply(this, [ callback, callbackDelay ]);
|
||||||
if (thisArg.auto)
|
if (thisArg.auto)
|
||||||
thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
|
thisArg.time.delayedCall(20, () => this.processInput(Button.ACTION));
|
||||||
};
|
};
|
||||||
|
|
||||||
const originalMessageUiHandlerPromptLevelUpStats = messageUiHandler.promptLevelUpStats;
|
const originalMessageUiHandlerPromptLevelUpStats = messageUiHandler.promptLevelUpStats;
|
||||||
messageUiHandler.promptLevelUpStats = function (prevStats: integer[], showTotals: boolean, callback?: Function) {
|
messageUiHandler.promptLevelUpStats = function (prevStats: integer[], showTotals: boolean, callback?: Function) {
|
||||||
originalMessageUiHandlerPromptLevelUpStats.apply(this, [ prevStats, showTotals, callback ]);
|
originalMessageUiHandlerPromptLevelUpStats.apply(this, [ prevStats, showTotals, callback ]);
|
||||||
if (thisArg.auto)
|
if (thisArg.auto)
|
||||||
thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
|
thisArg.time.delayedCall(20, () => this.processInput(Button.ACTION));
|
||||||
};
|
};
|
||||||
|
|
||||||
const originalCommandUiHandlerShow = commandUiHandler.show;
|
const originalCommandUiHandlerShow = commandUiHandler.show;
|
||||||
|
@ -153,10 +151,10 @@ export function initAutoPlay() {
|
||||||
console.log('Switching to ', Species[thisArg.getParty()[bestPartyMemberIndex].species.speciesId]);
|
console.log('Switching to ', Species[thisArg.getParty()[bestPartyMemberIndex].species.speciesId]);
|
||||||
nextPartyMemberIndex = bestPartyMemberIndex;
|
nextPartyMemberIndex = bestPartyMemberIndex;
|
||||||
commandUiHandler.setCursor(2);
|
commandUiHandler.setCursor(2);
|
||||||
thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
|
thisArg.time.delayedCall(20, () => this.processInput(Button.ACTION));
|
||||||
} else {
|
} else {
|
||||||
commandUiHandler.setCursor(0);
|
commandUiHandler.setCursor(0);
|
||||||
thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
|
thisArg.time.delayedCall(20, () => this.processInput(Button.ACTION));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -171,7 +169,7 @@ export function initAutoPlay() {
|
||||||
thisArg.time.delayedCall(20, () => {
|
thisArg.time.delayedCall(20, () => {
|
||||||
const nextMove = playerPokemon.getNextMove() as PokemonMove;
|
const nextMove = playerPokemon.getNextMove() as PokemonMove;
|
||||||
fightUiHandler.setCursor(playerPokemon.moveset.indexOf(nextMove));
|
fightUiHandler.setCursor(playerPokemon.moveset.indexOf(nextMove));
|
||||||
thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
|
thisArg.time.delayedCall(20, () => this.processInput(Button.ACTION));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -186,10 +184,10 @@ export function initAutoPlay() {
|
||||||
partyUiHandler.setCursor(nextPartyMemberIndex);
|
partyUiHandler.setCursor(nextPartyMemberIndex);
|
||||||
nextPartyMemberIndex = -1;
|
nextPartyMemberIndex = -1;
|
||||||
if (partyUiHandler.partyUiMode === PartyUiMode.MODIFIER || partyUiHandler.getCursor()) {
|
if (partyUiHandler.partyUiMode === PartyUiMode.MODIFIER || partyUiHandler.getCursor()) {
|
||||||
this.processInput(keyCodes.Z);
|
this.processInput(Button.ACTION);
|
||||||
thisArg.time.delayedCall(250, () => this.processInput(keyCodes.Z));
|
thisArg.time.delayedCall(250, () => this.processInput(Button.ACTION));
|
||||||
} else
|
} else
|
||||||
this.processInput(keyCodes.X);
|
this.processInput(Button.CANCEL);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -203,7 +201,7 @@ export function initAutoPlay() {
|
||||||
if (bestPartyMemberIndex)
|
if (bestPartyMemberIndex)
|
||||||
nextPartyMemberIndex = bestPartyMemberIndex;
|
nextPartyMemberIndex = bestPartyMemberIndex;
|
||||||
switchCheckUiHandler.setCursor(bestPartyMemberIndex ? 1 : 0);
|
switchCheckUiHandler.setCursor(bestPartyMemberIndex ? 1 : 0);
|
||||||
thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
|
thisArg.time.delayedCall(20, () => this.processInput(Button.ACTION));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,7 +283,7 @@ export function initAutoPlay() {
|
||||||
const trySelectModifier = () => {
|
const trySelectModifier = () => {
|
||||||
modifierSelectUiHandler.setCursor(optionIndex);
|
modifierSelectUiHandler.setCursor(optionIndex);
|
||||||
thisArg.time.delayedCall(20, () => {
|
thisArg.time.delayedCall(20, () => {
|
||||||
modifierSelectUiHandler.processInput(keyCodes.Z);
|
modifierSelectUiHandler.processInput(Button.ACTION);
|
||||||
thisArg.time.delayedCall(250, () => {
|
thisArg.time.delayedCall(250, () => {
|
||||||
console.log(modifierTypes[optionIndex]?.name);
|
console.log(modifierTypes[optionIndex]?.name);
|
||||||
if (thisArg.getCurrentPhase() instanceof SelectModifierPhase) {
|
if (thisArg.getCurrentPhase() instanceof SelectModifierPhase) {
|
||||||
|
@ -293,7 +291,7 @@ export function initAutoPlay() {
|
||||||
optionIndex++;
|
optionIndex++;
|
||||||
thisArg.time.delayedCall(250, () => trySelectModifier());
|
thisArg.time.delayedCall(250, () => trySelectModifier());
|
||||||
} else
|
} else
|
||||||
modifierSelectUiHandler.processInput(keyCodes.X);
|
modifierSelectUiHandler.processInput(Button.CANCEL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,19 @@ import { BattlePhase } from './battle-phase';
|
||||||
|
|
||||||
const enableAuto = true;
|
const enableAuto = true;
|
||||||
|
|
||||||
|
export enum Button {
|
||||||
|
UP,
|
||||||
|
DOWN,
|
||||||
|
LEFT,
|
||||||
|
RIGHT,
|
||||||
|
ACTION,
|
||||||
|
CANCEL,
|
||||||
|
RANDOM,
|
||||||
|
AUTO,
|
||||||
|
SPEED_UP,
|
||||||
|
SLOW_DOWN
|
||||||
|
}
|
||||||
|
|
||||||
export default class BattleScene extends Phaser.Scene {
|
export default class BattleScene extends Phaser.Scene {
|
||||||
public auto: boolean;
|
public auto: boolean;
|
||||||
public autoSpeed: integer = 1;
|
public autoSpeed: integer = 1;
|
||||||
|
@ -45,15 +58,7 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
|
|
||||||
private bgm: Phaser.Sound.BaseSound;
|
private bgm: Phaser.Sound.BaseSound;
|
||||||
|
|
||||||
private upKey: Phaser.Input.Keyboard.Key;
|
private buttonKeys: Phaser.Input.Keyboard.Key[][];
|
||||||
private downKey: Phaser.Input.Keyboard.Key;
|
|
||||||
private leftKey: Phaser.Input.Keyboard.Key;
|
|
||||||
private rightKey: Phaser.Input.Keyboard.Key;
|
|
||||||
private actionKey: Phaser.Input.Keyboard.Key;
|
|
||||||
private cancelKey: Phaser.Input.Keyboard.Key;
|
|
||||||
private f2Key: Phaser.Input.Keyboard.Key;
|
|
||||||
private plusKey: Phaser.Input.Keyboard.Key;
|
|
||||||
private minusKey: Phaser.Input.Keyboard.Key;
|
|
||||||
|
|
||||||
private blockInput: boolean;
|
private blockInput: boolean;
|
||||||
|
|
||||||
|
@ -214,10 +219,20 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
|
this.setupControls();
|
||||||
|
|
||||||
this.load.setBaseURL();
|
this.load.setBaseURL();
|
||||||
|
|
||||||
//this.spritePipeline = (this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.get('Sprite') as SpritePipeline;
|
//this.spritePipeline = (this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.get('Sprite') as SpritePipeline;
|
||||||
|
|
||||||
|
this.time.delayedCall(20, () => this.launchBattle());
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.checkInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
launchBattle() {
|
||||||
const field = this.add.container(0, 0);
|
const field = this.add.container(0, 0);
|
||||||
field.setScale(6);
|
field.setScale(6);
|
||||||
|
|
||||||
|
@ -264,8 +279,10 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
|
|
||||||
let loadPokemonAssets = [];
|
let loadPokemonAssets = [];
|
||||||
|
|
||||||
|
const isRandom = this.isButtonPressed(Button.RANDOM); // For testing purposes
|
||||||
|
|
||||||
for (let s = 0; s < 3; s++) {
|
for (let s = 0; s < 3; s++) {
|
||||||
const playerSpecies = getPokemonSpecies(s === 0 ? Species.TORCHIC : s === 1 ? Species.TREECKO : Species.MUDKIP); //this.randomSpecies();
|
const playerSpecies = !isRandom ? getPokemonSpecies(s === 0 ? Species.TORCHIC : s === 1 ? Species.TREECKO : Species.MUDKIP) : this.randomSpecies(5);
|
||||||
const playerPokemon = new PlayerPokemon(this, playerSpecies, 5);
|
const playerPokemon = new PlayerPokemon(this, playerSpecies, 5);
|
||||||
playerPokemon.setVisible(false);
|
playerPokemon.setVisible(false);
|
||||||
loadPokemonAssets.push(playerPokemon.loadAssets());
|
loadPokemonAssets.push(playerPokemon.loadAssets());
|
||||||
|
@ -304,16 +321,6 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
|
|
||||||
ui.setup();
|
ui.setup();
|
||||||
|
|
||||||
this.upKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP);
|
|
||||||
this.downKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN);
|
|
||||||
this.leftKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT);
|
|
||||||
this.rightKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT);
|
|
||||||
this.actionKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Z);
|
|
||||||
this.cancelKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.X);
|
|
||||||
this.f2Key = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F2);
|
|
||||||
this.plusKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.PLUS);
|
|
||||||
this.minusKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.MINUS);
|
|
||||||
|
|
||||||
Promise.all(loadPokemonAssets).then(() => {
|
Promise.all(loadPokemonAssets).then(() => {
|
||||||
if (enableAuto)
|
if (enableAuto)
|
||||||
initAutoPlay.apply(this);
|
initAutoPlay.apply(this);
|
||||||
|
@ -326,8 +333,29 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
setupControls() {
|
||||||
this.checkInput();
|
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
||||||
|
const keyConfig = {
|
||||||
|
[Button.UP]: [keyCodes.UP, keyCodes.W],
|
||||||
|
[Button.DOWN]: [keyCodes.DOWN, keyCodes.S],
|
||||||
|
[Button.LEFT]: [keyCodes.LEFT, keyCodes.A],
|
||||||
|
[Button.RIGHT]: [keyCodes.RIGHT, keyCodes.D],
|
||||||
|
[Button.ACTION]: [keyCodes.ENTER, keyCodes.SPACE, keyCodes.Z],
|
||||||
|
[Button.CANCEL]: [keyCodes.BACKSPACE, keyCodes.ESC, keyCodes.X],
|
||||||
|
[Button.RANDOM]: [keyCodes.R],
|
||||||
|
[Button.AUTO]: [keyCodes.F2],
|
||||||
|
[Button.SPEED_UP]: [keyCodes.PLUS],
|
||||||
|
[Button.SLOW_DOWN]: [keyCodes.MINUS]
|
||||||
|
};
|
||||||
|
this.buttonKeys = [];
|
||||||
|
for (let b of Utils.getEnumValues(Button)) {
|
||||||
|
const keys: Phaser.Input.Keyboard.Key[] = [];
|
||||||
|
if (keyConfig.hasOwnProperty(b)) {
|
||||||
|
for (let k of keyConfig[b])
|
||||||
|
keys.push(this.input.keyboard.addKey(k));
|
||||||
|
}
|
||||||
|
this.buttonKeys[b] = keys;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getParty(): PlayerPokemon[] {
|
getParty(): PlayerPokemon[] {
|
||||||
|
@ -372,31 +400,31 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
randomSpecies(level: integer, fromArenaPool?: boolean): PokemonSpecies {
|
randomSpecies(level: integer, fromArenaPool?: boolean): PokemonSpecies {
|
||||||
return fromArenaPool
|
return fromArenaPool
|
||||||
? this.arena.randomSpecies(1, level)
|
? this.arena.randomSpecies(1, level)
|
||||||
: allSpecies[(Utils.randInt(allSpecies.length)) - 1];
|
: getPokemonSpecies(allSpecies[(Utils.randInt(allSpecies.length)) - 1].getSpeciesForLevel(level));
|
||||||
}
|
}
|
||||||
|
|
||||||
checkInput(): boolean {
|
checkInput(): boolean {
|
||||||
if (this.blockInput)
|
if (this.blockInput)
|
||||||
return;
|
return;
|
||||||
if (this.upKey.isDown)
|
if (this.isButtonPressed(Button.UP))
|
||||||
this.ui.processInput(this.upKey.keyCode);
|
this.ui.processInput(Button.UP);
|
||||||
else if (this.downKey.isDown)
|
else if (this.isButtonPressed(Button.DOWN))
|
||||||
this.ui.processInput(this.downKey.keyCode);
|
this.ui.processInput(Button.DOWN);
|
||||||
else if (this.leftKey.isDown)
|
else if (this.isButtonPressed(Button.LEFT))
|
||||||
this.ui.processInput(this.leftKey.keyCode);
|
this.ui.processInput(Button.LEFT);
|
||||||
else if (this.rightKey.isDown)
|
else if (this.isButtonPressed(Button.RIGHT))
|
||||||
this.ui.processInput(this.rightKey.keyCode);
|
this.ui.processInput(Button.RIGHT);
|
||||||
else if (this.actionKey.isDown)
|
else if (this.isButtonPressed(Button.ACTION))
|
||||||
this.ui.processInput(this.actionKey.keyCode);
|
this.ui.processInput(Button.ACTION);
|
||||||
else if (this.cancelKey.isDown)
|
else if (this.isButtonPressed(Button.CANCEL))
|
||||||
this.ui.processInput(this.cancelKey.keyCode);
|
this.ui.processInput(Button.CANCEL);
|
||||||
else if (enableAuto) {
|
else if (enableAuto) {
|
||||||
if (this.f2Key.isDown)
|
if (this.isButtonPressed(Button.AUTO))
|
||||||
this.auto = !this.auto;
|
this.auto = !this.auto;
|
||||||
else if (this.plusKey.isDown) {
|
else if (this.isButtonPressed(Button.SPEED_UP)) {
|
||||||
if (this.autoSpeed < 20)
|
if (this.autoSpeed < 20)
|
||||||
this.autoSpeed++;
|
this.autoSpeed++;
|
||||||
} else if (this.minusKey.isDown) {
|
} else if (this.isButtonPressed(Button.SLOW_DOWN)) {
|
||||||
if (this.autoSpeed > 1)
|
if (this.autoSpeed > 1)
|
||||||
this.autoSpeed--;
|
this.autoSpeed--;
|
||||||
}
|
}
|
||||||
|
@ -409,6 +437,10 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isButtonPressed(button: Button): boolean {
|
||||||
|
return this.buttonKeys[button].filter(k => k.isDown).length >= 1;
|
||||||
|
}
|
||||||
|
|
||||||
playBgm(bgmName?: string): void {
|
playBgm(bgmName?: string): void {
|
||||||
if (!bgmName && this.bgm) {
|
if (!bgmName && this.bgm) {
|
||||||
this.bgm.play({
|
this.bgm.play({
|
||||||
|
@ -419,7 +451,7 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
if (this.bgm && this.bgm.isPlaying)
|
if (this.bgm && this.bgm.isPlaying)
|
||||||
this.bgm.stop();
|
this.bgm.stop();
|
||||||
this.bgm = this.sound.add(bgmName, { loop: true });
|
this.bgm = this.sound.add(bgmName, { loop: true });
|
||||||
//this.bgm.play();
|
this.bgm.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
pauseBgm(): void {
|
pauseBgm(): void {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { CommandPhase } from "../battle-phase";
|
import { CommandPhase } from "../battle-phases";
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { getPokeballName, PokeballType } from "../pokeball";
|
import { getPokeballName, PokeballType } from "../pokeball";
|
||||||
import { addTextObject, TextStyle } from "../text";
|
import { addTextObject, TextStyle } from "../text";
|
||||||
import { Command } from "./command-ui-handler";
|
import { Command } from "./command-ui-handler";
|
||||||
|
@ -55,17 +55,16 @@ export default class BallUiHandler extends UiHandler {
|
||||||
this.setCursor(this.cursor);
|
this.setCursor(this.cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
const pokeballTypeCount = Object.keys(this.scene.pokeballCounts).length;
|
const pokeballTypeCount = Object.keys(this.scene.pokeballCounts).length;
|
||||||
|
|
||||||
if (keyCode === keyCodes.Z || keyCode === keyCodes.X) {
|
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||||
success = true;
|
success = true;
|
||||||
if (keyCode === keyCodes.Z && this.cursor < pokeballTypeCount) {
|
if (button === Button.ACTION && this.cursor < pokeballTypeCount) {
|
||||||
if (this.scene.pokeballCounts[this.cursor]) {
|
if (this.scene.pokeballCounts[this.cursor]) {
|
||||||
(this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.BALL, this.cursor);
|
(this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.BALL, this.cursor);
|
||||||
this.scene.ui.setMode(Mode.COMMAND);
|
this.scene.ui.setMode(Mode.COMMAND);
|
||||||
|
@ -78,11 +77,11 @@ export default class BallUiHandler extends UiHandler {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.UP:
|
case Button.UP:
|
||||||
success = this.setCursor(this.cursor ? this.cursor - 1 : pokeballTypeCount);
|
success = this.setCursor(this.cursor ? this.cursor - 1 : pokeballTypeCount);
|
||||||
break;
|
break;
|
||||||
case keyCodes.DOWN:
|
case Button.DOWN:
|
||||||
success = this.setCursor(this.cursor < pokeballTypeCount ? this.cursor + 1 : 0);
|
success = this.setCursor(this.cursor < pokeballTypeCount ? this.cursor + 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { addTextObject, TextStyle } from "../text";
|
import { addTextObject, TextStyle } from "../text";
|
||||||
import UI, { Mode } from "./ui";
|
import UI, { Mode } from "./ui";
|
||||||
import * as Utils from "../utils";
|
import * as Utils from "../utils";
|
||||||
|
@ -87,11 +87,10 @@ export default class BattleMessageUiHandler extends MessageUiHandler {
|
||||||
this.message.setWordWrapWidth(1780);
|
this.message.setWordWrapWidth(1780);
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
if (this.awaitingActionInput) {
|
if (this.awaitingActionInput) {
|
||||||
if (keyCode === keyCodes.X || keyCode === keyCodes.Z) {
|
if (button === Button.CANCEL || button === Button.ACTION) {
|
||||||
if (this.onActionInput) {
|
if (this.onActionInput) {
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
const originalOnActionInput = this.onActionInput;
|
const originalOnActionInput = this.onActionInput;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { addTextObject, TextStyle } from "../text";
|
import { addTextObject, TextStyle } from "../text";
|
||||||
import { toPokemonUpperCase } from "../utils";
|
import { toPokemonUpperCase } from "../utils";
|
||||||
import { PartyUiMode } from "./party-ui-handler";
|
import { PartyUiMode } from "./party-ui-handler";
|
||||||
|
@ -46,15 +46,14 @@ export default class CommandUiHandler extends UiHandler {
|
||||||
this.setCursor(this.cursor);
|
this.setCursor(this.cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
if (keyCode === keyCodes.X || keyCode === keyCodes.Z) {
|
if (button === Button.CANCEL || button === Button.ACTION) {
|
||||||
|
|
||||||
if (keyCode === keyCodes.Z) {
|
if (button === Button.ACTION) {
|
||||||
switch (this.cursor) {
|
switch (this.cursor) {
|
||||||
case 0:
|
case 0:
|
||||||
ui.setMode(Mode.FIGHT);
|
ui.setMode(Mode.FIGHT);
|
||||||
|
@ -71,20 +70,20 @@ export default class CommandUiHandler extends UiHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.UP:
|
case Button.UP:
|
||||||
if (this.cursor >= 2)
|
if (this.cursor >= 2)
|
||||||
success = this.setCursor(this.cursor - 2);
|
success = this.setCursor(this.cursor - 2);
|
||||||
break;
|
break;
|
||||||
case keyCodes.DOWN:
|
case Button.DOWN:
|
||||||
if (this.cursor < 2)
|
if (this.cursor < 2)
|
||||||
success = this.setCursor(this.cursor + 2);
|
success = this.setCursor(this.cursor + 2);
|
||||||
break;
|
break;
|
||||||
case keyCodes.LEFT:
|
case Button.LEFT:
|
||||||
if (this.cursor % 2 === 1)
|
if (this.cursor % 2 === 1)
|
||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(this.cursor - 1);
|
||||||
break;
|
break;
|
||||||
case keyCodes.RIGHT:
|
case Button.RIGHT:
|
||||||
if (this.cursor % 2 === 0)
|
if (this.cursor % 2 === 0)
|
||||||
success = this.setCursor(this.cursor + 1);
|
success = this.setCursor(this.cursor + 1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { addTextObject, TextStyle } from "../text";
|
import { addTextObject, TextStyle } from "../text";
|
||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
import UiHandler from "./uiHandler";
|
import UiHandler from "./uiHandler";
|
||||||
|
@ -51,27 +51,26 @@ export default class ConfirmUiHandler extends UiHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
if (keyCode === keyCodes.Z || keyCode === keyCodes.X) {
|
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||||
success = true;
|
success = true;
|
||||||
if (keyCode === keyCodes.X)
|
if (button === Button.CANCEL)
|
||||||
this.setCursor(1);
|
this.setCursor(1);
|
||||||
const handler = this.cursor ? this.noHander : this.yesHandler;
|
const handler = this.cursor ? this.noHander : this.yesHandler;
|
||||||
handler();
|
handler();
|
||||||
console.log(this.cursor ? this.noHander : this.yesHandler);
|
console.log(this.cursor ? this.noHander : this.yesHandler);
|
||||||
this.clear();
|
this.clear();
|
||||||
} else {
|
} else {
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.UP:
|
case Button.UP:
|
||||||
if (this.cursor)
|
if (this.cursor)
|
||||||
success = this.setCursor(0);
|
success = this.setCursor(0);
|
||||||
break;
|
break;
|
||||||
case keyCodes.DOWN:
|
case Button.DOWN:
|
||||||
if (!this.cursor)
|
if (!this.cursor)
|
||||||
success = this.setCursor(1);
|
success = this.setCursor(1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
import UiHandler from "./uiHandler";
|
import UiHandler from "./uiHandler";
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ export default class EvolutionSceneHandler extends UiHandler {
|
||||||
this.scene.fieldUI.add(this.evolutionContainer);
|
this.scene.fieldUI.add(this.evolutionContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
this.scene.ui.getMessageHandler().processInput(keyCode);
|
this.scene.ui.getMessageHandler().processInput(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
setCursor(_cursor: integer): boolean {
|
setCursor(_cursor: integer): boolean {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { addTextObject, TextStyle } from "../text";
|
import { addTextObject, TextStyle } from "../text";
|
||||||
import { Type } from "../type";
|
import { Type } from "../type";
|
||||||
import { Command } from "./command-ui-handler";
|
import { Command } from "./command-ui-handler";
|
||||||
|
@ -42,14 +42,13 @@ export default class FightUiHandler extends UiHandler {
|
||||||
this.displayMoves();
|
this.displayMoves();
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
if (keyCode === keyCodes.X || keyCode === keyCodes.Z) {
|
if (button === Button.CANCEL || button === Button.ACTION) {
|
||||||
if (keyCode === keyCodes.Z) {
|
if (button === Button.ACTION) {
|
||||||
if (((this.scene as BattleScene).getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, this.cursor))
|
if (((this.scene as BattleScene).getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, this.cursor))
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,20 +56,20 @@ export default class FightUiHandler extends UiHandler {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.UP:
|
case Button.UP:
|
||||||
if (this.cursor >= 2)
|
if (this.cursor >= 2)
|
||||||
success = this.setCursor(this.cursor - 2);
|
success = this.setCursor(this.cursor - 2);
|
||||||
break;
|
break;
|
||||||
case keyCodes.DOWN:
|
case Button.DOWN:
|
||||||
if (this.cursor < 2)
|
if (this.cursor < 2)
|
||||||
success = this.setCursor(this.cursor + 2);
|
success = this.setCursor(this.cursor + 2);
|
||||||
break;
|
break;
|
||||||
case keyCodes.LEFT:
|
case Button.LEFT:
|
||||||
if (this.cursor % 2 === 1)
|
if (this.cursor % 2 === 1)
|
||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(this.cursor - 1);
|
||||||
break;
|
break;
|
||||||
case keyCodes.RIGHT:
|
case Button.RIGHT:
|
||||||
if (this.cursor % 2 === 0)
|
if (this.cursor % 2 === 0)
|
||||||
success = this.setCursor(this.cursor + 1);
|
success = this.setCursor(this.cursor + 1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { ModifierTier, ModifierType } from "../modifier";
|
import { ModifierTier, ModifierType } from "../modifier";
|
||||||
import { getPokeballAtlasKey, PokeballType } from "../pokeball";
|
import { getPokeballAtlasKey, PokeballType } from "../pokeball";
|
||||||
import { addTextObject, TextStyle } from "../text";
|
import { addTextObject, TextStyle } from "../text";
|
||||||
|
@ -87,8 +87,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
|
||||||
if (!this.awaitingActionInput)
|
if (!this.awaitingActionInput)
|
||||||
|
@ -96,7 +95,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
if (keyCode === keyCodes.Z) {
|
if (button === Button.ACTION) {
|
||||||
success = true;
|
success = true;
|
||||||
if (this.onActionInput) {
|
if (this.onActionInput) {
|
||||||
const originalOnActionInput = this.onActionInput;
|
const originalOnActionInput = this.onActionInput;
|
||||||
|
@ -104,7 +103,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||||
this.onActionInput = null;
|
this.onActionInput = null;
|
||||||
originalOnActionInput(this.cursor);
|
originalOnActionInput(this.cursor);
|
||||||
}
|
}
|
||||||
} else if (keyCode === keyCodes.X) {
|
} else if (button === Button.CANCEL) {
|
||||||
success = true;
|
success = true;
|
||||||
if (this.onActionInput) {
|
if (this.onActionInput) {
|
||||||
const originalOnActionInput = this.onActionInput;
|
const originalOnActionInput = this.onActionInput;
|
||||||
|
@ -113,12 +112,12 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||||
originalOnActionInput(-1);
|
originalOnActionInput(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.LEFT:
|
case Button.LEFT:
|
||||||
if (this.cursor)
|
if (this.cursor)
|
||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(this.cursor - 1);
|
||||||
break;
|
break;
|
||||||
case keyCodes.RIGHT:
|
case Button.RIGHT:
|
||||||
if (this.cursor < this.options.length - 1)
|
if (this.cursor < this.options.length - 1)
|
||||||
success = this.setCursor(this.cursor + 1);
|
success = this.setCursor(this.cursor + 1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { CommandPhase } from "../battle-phases";
|
import { CommandPhase } from "../battle-phases";
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { PlayerPokemon } from "../pokemon";
|
import { PlayerPokemon } from "../pokemon";
|
||||||
import { addTextObject, TextStyle } from "../text";
|
import { addTextObject, TextStyle } from "../text";
|
||||||
import { Command } from "./command-ui-handler";
|
import { Command } from "./command-ui-handler";
|
||||||
|
@ -123,15 +123,14 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
: PartyUiHandler.FilterAll;
|
: PartyUiHandler.FilterAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
|
|
||||||
if (this.pendingPrompt)
|
if (this.pendingPrompt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.awaitingActionInput) {
|
if (this.awaitingActionInput) {
|
||||||
if (keyCode === keyCodes.Z || keyCode === keyCodes.X) {
|
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||||
if (this.onActionInput) {
|
if (this.onActionInput) {
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
const originalOnActionInput = this.onActionInput;
|
const originalOnActionInput = this.onActionInput;
|
||||||
|
@ -146,7 +145,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
if (this.optionsMode) {
|
if (this.optionsMode) {
|
||||||
if (keyCode === keyCodes.Z) {
|
if (button === Button.ACTION) {
|
||||||
const option = this.options[this.optionsCursor];
|
const option = this.options[this.optionsCursor];
|
||||||
if (option === PartyOption.SHIFT || option === PartyOption.SEND_OUT || option === PartyOption.APPLY) {
|
if (option === PartyOption.SHIFT || option === PartyOption.SEND_OUT || option === PartyOption.APPLY) {
|
||||||
let filterResult: string = this.selectFilter(this.scene.getParty()[this.cursor]);
|
let filterResult: string = this.selectFilter(this.scene.getParty()[this.cursor]);
|
||||||
|
@ -175,32 +174,32 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
ui.setModeWithoutClear(Mode.SUMMARY, this.scene.getParty()[this.cursor]).then(() => this.clearOptions());
|
ui.setModeWithoutClear(Mode.SUMMARY, this.scene.getParty()[this.cursor]).then(() => this.clearOptions());
|
||||||
} else if (option === PartyOption.CANCEL)
|
} else if (option === PartyOption.CANCEL)
|
||||||
this.processInput(keyCodes.X);
|
this.processInput(Button.CANCEL);
|
||||||
} else if (keyCode === keyCodes.X) {
|
} else if (button === Button.CANCEL) {
|
||||||
this.clearOptions();
|
this.clearOptions();
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.UP:
|
case Button.UP:
|
||||||
success = this.setCursor(this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1);
|
success = this.setCursor(this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1);
|
||||||
break;
|
break;
|
||||||
case keyCodes.DOWN:
|
case Button.DOWN:
|
||||||
success = this.setCursor(this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0);
|
success = this.setCursor(this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (keyCode === keyCodes.Z) {
|
if (button === Button.ACTION) {
|
||||||
if (this.cursor < 6) {
|
if (this.cursor < 6) {
|
||||||
this.showOptions();
|
this.showOptions();
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
} else if (this.partyUiMode === PartyUiMode.FAINT_SWITCH)
|
} else if (this.partyUiMode === PartyUiMode.FAINT_SWITCH)
|
||||||
ui.playError();
|
ui.playError();
|
||||||
else
|
else
|
||||||
this.processInput(keyCodes.X);
|
this.processInput(Button.CANCEL);
|
||||||
return;
|
return;
|
||||||
} else if (keyCode === keyCodes.X) {
|
} else if (button === Button.CANCEL) {
|
||||||
if (this.partyUiMode !== PartyUiMode.FAINT_SWITCH) {
|
if (this.partyUiMode !== PartyUiMode.FAINT_SWITCH) {
|
||||||
if (this.selectCallback) {
|
if (this.selectCallback) {
|
||||||
const selectCallback = this.selectCallback;
|
const selectCallback = this.selectCallback;
|
||||||
|
@ -217,18 +216,18 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
|
|
||||||
const slotCount = this.partySlots.length;
|
const slotCount = this.partySlots.length;
|
||||||
|
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.UP:
|
case Button.UP:
|
||||||
success = this.setCursor(this.cursor ? this.cursor < 6 ? this.cursor - 1 : slotCount - 1 : 6);
|
success = this.setCursor(this.cursor ? this.cursor < 6 ? this.cursor - 1 : slotCount - 1 : 6);
|
||||||
break;
|
break;
|
||||||
case keyCodes.DOWN:
|
case Button.DOWN:
|
||||||
success = this.setCursor(this.cursor < 6 ? this.cursor < slotCount - 1 ? this.cursor + 1 : 6 : 0);
|
success = this.setCursor(this.cursor < 6 ? this.cursor < slotCount - 1 ? this.cursor + 1 : 6 : 0);
|
||||||
break;
|
break;
|
||||||
case keyCodes.LEFT:
|
case Button.LEFT:
|
||||||
if (this.cursor && this.cursor < 6)
|
if (this.cursor && this.cursor < 6)
|
||||||
success = this.setCursor(0);
|
success = this.setCursor(0);
|
||||||
break;
|
break;
|
||||||
case keyCodes.RIGHT:
|
case Button.RIGHT:
|
||||||
if (!this.cursor)
|
if (!this.cursor)
|
||||||
success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || 1 : 1);
|
success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || 1 : 1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { allSpecies } from "../pokemon-species";
|
import { allSpecies } from "../pokemon-species";
|
||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
import UiHandler from "./uiHandler";
|
import UiHandler from "./uiHandler";
|
||||||
|
@ -41,14 +41,13 @@ export default class StarterSelectUiHandler extends UiHandler {
|
||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
if (keyCode === keyCodes.Z) {
|
if (button === Button.ACTION) {
|
||||||
} else if (keyCode === keyCodes.X) {
|
} else if (button === Button.CANCEL) {
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
import UiHandler from "./uiHandler";
|
import UiHandler from "./uiHandler";
|
||||||
import * as Utils from "../utils";
|
import * as Utils from "../utils";
|
||||||
|
@ -170,17 +170,16 @@ export default class SummaryUiHandler extends UiHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer) {
|
processInput(button: Button) {
|
||||||
if (this.transitioning)
|
if (this.transitioning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
if (this.moveSelect) {
|
if (this.moveSelect) {
|
||||||
if (keyCode === keyCodes.Z) {
|
if (button === Button.ACTION) {
|
||||||
if (this.moveCursor < this.pokemon.moveset.length) {
|
if (this.moveCursor < this.pokemon.moveset.length) {
|
||||||
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE)
|
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE)
|
||||||
this.moveSelectFunction(this.moveCursor);
|
this.moveSelectFunction(this.moveCursor);
|
||||||
|
@ -213,37 +212,37 @@ export default class SummaryUiHandler extends UiHandler {
|
||||||
}
|
}
|
||||||
success = true;
|
success = true;
|
||||||
} else if (this.moveCursor === 4)
|
} else if (this.moveCursor === 4)
|
||||||
this.processInput(keyCodes.X);
|
this.processInput(Button.CANCEL);
|
||||||
else
|
else
|
||||||
ui.playError();
|
ui.playError();
|
||||||
} else if (keyCode === keyCodes.X) {
|
} else if (button === Button.CANCEL) {
|
||||||
this.hideMoveSelect();
|
this.hideMoveSelect();
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.UP:
|
case Button.UP:
|
||||||
success = this.setCursor(this.moveCursor ? this.moveCursor - 1 : 4);
|
success = this.setCursor(this.moveCursor ? this.moveCursor - 1 : 4);
|
||||||
break;
|
break;
|
||||||
case keyCodes.DOWN:
|
case Button.DOWN:
|
||||||
success = this.setCursor(this.moveCursor < 4 ? this.moveCursor + 1 : 0);
|
success = this.setCursor(this.moveCursor < 4 ? this.moveCursor + 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (keyCode === keyCodes.Z) {
|
if (button === Button.ACTION) {
|
||||||
if (this.cursor === Page.MOVES) {
|
if (this.cursor === Page.MOVES) {
|
||||||
this.showMoveSelect();
|
this.showMoveSelect();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
} else if (keyCode === keyCodes.X) {
|
} else if (button === Button.CANCEL) {
|
||||||
ui.setMode(Mode.PARTY);
|
ui.setMode(Mode.PARTY);
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
const pages = Utils.getEnumValues(Page);
|
const pages = Utils.getEnumValues(Page);
|
||||||
switch (keyCode) {
|
switch (button) {
|
||||||
case keyCodes.UP:
|
case Button.UP:
|
||||||
case keyCodes.DOWN:
|
case Button.DOWN:
|
||||||
const isDown = keyCode === keyCodes.DOWN;
|
const isDown = button === Button.DOWN;
|
||||||
const party = this.scene.getParty();
|
const party = this.scene.getParty();
|
||||||
const partyMemberIndex = party.indexOf(this.pokemon);
|
const partyMemberIndex = party.indexOf(this.pokemon);
|
||||||
if ((isDown && partyMemberIndex < party.length - 1) || (!isDown && partyMemberIndex)) {
|
if ((isDown && partyMemberIndex < party.length - 1) || (!isDown && partyMemberIndex)) {
|
||||||
|
@ -252,11 +251,11 @@ export default class SummaryUiHandler extends UiHandler {
|
||||||
this.show([ party[partyMemberIndex + (isDown ? 1 : -1)], this.summaryUiMode, page ]);
|
this.show([ party[partyMemberIndex + (isDown ? 1 : -1)], this.summaryUiMode, page ]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case keyCodes.LEFT:
|
case Button.LEFT:
|
||||||
if (this.cursor)
|
if (this.cursor)
|
||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(this.cursor - 1);
|
||||||
break;
|
break;
|
||||||
case keyCodes.RIGHT:
|
case Button.RIGHT:
|
||||||
if (this.cursor < pages.length - 1)
|
if (this.cursor < pages.length - 1)
|
||||||
success = this.setCursor(this.cursor + 1);
|
success = this.setCursor(this.cursor + 1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { default as BattleScene } from '../battle-scene';
|
import { Button, default as BattleScene } from '../battle-scene';
|
||||||
import UiHandler from './uiHandler';
|
import UiHandler from './uiHandler';
|
||||||
import BattleMessageUiHandler from './battle-message-ui-handler';
|
import BattleMessageUiHandler from './battle-message-ui-handler';
|
||||||
import CommandUiHandler from './command-ui-handler';
|
import CommandUiHandler from './command-ui-handler';
|
||||||
|
@ -79,11 +79,11 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||||
return this.handlers[Mode.MESSAGE] as BattleMessageUiHandler;
|
return this.handlers[Mode.MESSAGE] as BattleMessageUiHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(keyCode: integer): void {
|
processInput(button: Button): void {
|
||||||
if (this.transitioning)
|
if (this.transitioning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.getHandler().processInput(keyCode);
|
this.getHandler().processInput(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
showText(text: string, delay?: integer, callback?: Function, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer): void {
|
showText(text: string, delay?: integer, callback?: Function, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer): void {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import UI, { Mode } from "./ui";
|
import UI, { Mode } from "./ui";
|
||||||
|
|
||||||
export default abstract class UiHandler {
|
export default abstract class UiHandler {
|
||||||
|
@ -18,7 +18,7 @@ export default abstract class UiHandler {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract processInput(keyCode: integer);
|
abstract processInput(button: Button);
|
||||||
|
|
||||||
getUi() {
|
getUi() {
|
||||||
return this.scene.ui;
|
return this.scene.ui;
|
||||||
|
|
Loading…
Reference in New Issue