Refactor modifiers
This commit is contained in:
1 parent
4ec91695f7
commit
15105231ba
14 files changed
+1919
-1551
No files matched your search
@@ -33,7 +33,15 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
}
|
||||
|
||||
show(args: any[]) {
|
||||
if (this.active || args.length !== 2 || !(args[0] instanceof Array) || !args[0].length || !(args[1] instanceof Function))
|
||||
if (this.active) {
|
||||
if (args.length === 2) {
|
||||
this.awaitingActionInput = true;
|
||||
this.onActionInput = args[1];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length !== 2 || !(args[0] instanceof Array) || !args[0].length || !(args[1] instanceof Function))
|
||||
return;
|
||||
|
||||
super.show(args);
|
||||
@@ -92,6 +100,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
success = true;
|
||||
if (this.onActionInput) {
|
||||
const originalOnActionInput = this.onActionInput;
|
||||
this.awaitingActionInput = false;
|
||||
this.onActionInput = null;
|
||||
originalOnActionInput(this.cursor);
|
||||
}
|
||||
@@ -99,6 +108,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
success = true;
|
||||
if (this.onActionInput) {
|
||||
const originalOnActionInput = this.onActionInput;
|
||||
this.awaitingActionInput = false;
|
||||
this.onActionInput = null;
|
||||
originalOnActionInput(-1);
|
||||
}
|
||||
|
||||
@@ -158,6 +158,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
selectCallback(this.cursor);
|
||||
} else if (this.cursor)
|
||||
(this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor);
|
||||
if (this.partyUiMode !== PartyUiMode.MODIFIER)
|
||||
ui.playSelect();
|
||||
return;
|
||||
} else {
|
||||
this.clearOptions();
|
||||
@@ -396,9 +398,9 @@ class PartySlot extends Phaser.GameObjects.Container {
|
||||
|
||||
this.add(slotPb);
|
||||
|
||||
const pokemonIcon = this.scene.add.sprite(slotPb.x, slotPb.y, this.pokemon.getIconAtlasKey());
|
||||
const pokemonIcon = this.scene.add.sprite(slotPb.x, slotPb.y, this.pokemon.species.getIconAtlasKey());
|
||||
console.log(pokemonIcon)
|
||||
pokemonIcon.play(this.pokemon.getIconKey());
|
||||
pokemonIcon.play(this.pokemon.species.getIconKey());
|
||||
this.slotPokemonIcon = pokemonIcon;
|
||||
|
||||
this.add(pokemonIcon);
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import BattleScene from "../battle-scene";
|
||||
import { allSpecies } from "../pokemon-species";
|
||||
import { Mode } from "./ui";
|
||||
import UiHandler from "./uiHandler";
|
||||
|
||||
export default class StarterSelectUiHandler extends UiHandler {
|
||||
private starterSelectContainer: Phaser.GameObjects.Container;
|
||||
|
||||
constructor(scene: BattleScene) {
|
||||
super(scene, Mode.STARTER_SELECT);
|
||||
}
|
||||
|
||||
setup() {
|
||||
const ui = this.getUi();
|
||||
|
||||
this.starterSelectContainer = this.scene.add.container(0, -this.scene.game.canvas.height / 6);
|
||||
this.starterSelectContainer.setVisible(false);
|
||||
ui.add(this.starterSelectContainer);
|
||||
|
||||
let s = 0;
|
||||
|
||||
for (let species of allSpecies) {
|
||||
if (species.getSpeciesForLevel(1) !== species.speciesId || species.generation >= 6)
|
||||
continue;
|
||||
species.generateIconAnim(this.scene);
|
||||
const x = (s % 24) * 13;
|
||||
const y = Math.floor(s / 24) * 13;
|
||||
const icon = this.scene.add.sprite(x, y, species.getIconAtlasKey());
|
||||
icon.setScale(0.5);
|
||||
icon.setOrigin(0, 0);
|
||||
icon.play(species.getIconKey()).stop();
|
||||
this.starterSelectContainer.add(icon);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
show(args: any[]) {
|
||||
super.show(args);
|
||||
|
||||
this.starterSelectContainer.setVisible(true);
|
||||
this.setCursor(0);
|
||||
}
|
||||
|
||||
processInput(keyCode: integer) {
|
||||
const ui = this.getUi();
|
||||
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
||||
|
||||
let success = false;
|
||||
|
||||
if (keyCode === keyCodes.Z) {
|
||||
} else if (keyCode === keyCodes.X) {
|
||||
} else {
|
||||
}
|
||||
|
||||
if (success)
|
||||
ui.playSelect();
|
||||
}
|
||||
|
||||
setCursor(cursor: integer): boolean {
|
||||
let changed: boolean = this.cursor !== cursor;
|
||||
|
||||
if (changed) {
|
||||
const forward = this.cursor < cursor;
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
clear() {
|
||||
super.clear();
|
||||
this.cursor = -1;
|
||||
this.starterSelectContainer.setVisible(false);
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -9,6 +9,7 @@ import ConfirmUiHandler from './confirm-ui-handler';
|
||||
import ModifierSelectUiHandler from './modifier-select-ui-handler';
|
||||
import BallUiHandler from './ball-ui-handler';
|
||||
import SummaryUiHandler from './summary-ui-handler';
|
||||
import StarterSelectUiHandler from './starter-select-ui-handler';
|
||||
|
||||
export enum Mode {
|
||||
MESSAGE = 0,
|
||||
@@ -18,12 +19,14 @@ export enum Mode {
|
||||
CONFIRM,
|
||||
MODIFIER_SELECT,
|
||||
PARTY,
|
||||
SUMMARY
|
||||
SUMMARY,
|
||||
STARTER_SELECT,
|
||||
};
|
||||
|
||||
const transitionModes = [
|
||||
Mode.PARTY,
|
||||
Mode.SUMMARY
|
||||
Mode.SUMMARY,
|
||||
Mode.STARTER_SELECT,
|
||||
];
|
||||
|
||||
export default class UI extends Phaser.GameObjects.Container {
|
||||
@@ -45,7 +48,8 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||
new ConfirmUiHandler(scene),
|
||||
new ModifierSelectUiHandler(scene),
|
||||
new PartyUiHandler(scene),
|
||||
new SummaryUiHandler(scene)
|
||||
new SummaryUiHandler(scene),
|
||||
new StarterSelectUiHandler(scene)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user