2023-04-05 13:35:15 +01:00
|
|
|
import BattleScene from "../battle-scene";
|
|
|
|
import { Mode } from "./ui";
|
|
|
|
import UiHandler from "./uiHandler";
|
2023-04-06 16:30:22 +01:00
|
|
|
import * as Utils from "../utils";
|
2023-04-07 03:24:13 +01:00
|
|
|
import { PlayerPokemon } from "../pokemon";
|
|
|
|
import { Type } from "../type";
|
|
|
|
import { TextStyle, addTextObject } from "../text";
|
2023-04-09 01:35:45 +01:00
|
|
|
import Move, { MoveCategory } from "../move";
|
|
|
|
import { getPokeballAtlasKey } from "../pokeball";
|
|
|
|
import { getGenderColor, getGenderSymbol } from "../gender";
|
2023-04-05 13:35:15 +01:00
|
|
|
|
2023-04-06 15:05:12 +01:00
|
|
|
enum Page {
|
|
|
|
PROFILE,
|
|
|
|
MOVES
|
|
|
|
}
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
export enum SummaryUiMode {
|
|
|
|
DEFAULT,
|
|
|
|
LEARN_MOVE
|
|
|
|
}
|
|
|
|
|
2023-04-05 13:35:15 +01:00
|
|
|
export default class SummaryUiHandler extends UiHandler {
|
2023-04-07 03:24:13 +01:00
|
|
|
private summaryUiMode: SummaryUiMode;
|
|
|
|
|
2023-04-05 13:35:15 +01:00
|
|
|
private summaryContainer: Phaser.GameObjects.Container;
|
2023-04-09 01:35:45 +01:00
|
|
|
private numberText: Phaser.GameObjects.Text;
|
2023-04-07 18:23:55 +01:00
|
|
|
private pokemonSprite: Phaser.GameObjects.Sprite;
|
2023-04-09 01:35:45 +01:00
|
|
|
private nameText: Phaser.GameObjects.Text;
|
|
|
|
private pokeball: Phaser.GameObjects.Sprite;
|
|
|
|
private levelText: Phaser.GameObjects.Text;
|
|
|
|
private genderText: Phaser.GameObjects.Text;
|
2023-04-06 16:30:22 +01:00
|
|
|
private summaryPageContainer: Phaser.GameObjects.Container;
|
2023-04-07 03:24:13 +01:00
|
|
|
private movesContainer: Phaser.GameObjects.Container;
|
2023-04-07 05:17:55 +01:00
|
|
|
private moveDescriptionText: Phaser.GameObjects.Text;
|
2023-04-07 03:24:13 +01:00
|
|
|
private moveCursorObj: Phaser.GameObjects.Sprite;
|
|
|
|
private selectedMoveCursorObj: Phaser.GameObjects.Sprite;
|
2023-04-07 05:17:55 +01:00
|
|
|
private moveRowsContainer: Phaser.GameObjects.Container;
|
2023-04-07 03:24:13 +01:00
|
|
|
private extraMoveRowContainer: Phaser.GameObjects.Container;
|
2023-04-09 01:35:45 +01:00
|
|
|
private moveEffectContainer: Phaser.GameObjects.Container;
|
|
|
|
private movePowerText: Phaser.GameObjects.Text;
|
|
|
|
private moveAccuracyText: Phaser.GameObjects.Text;
|
|
|
|
private moveCategoryIcon: Phaser.GameObjects.Sprite;
|
2023-04-06 16:30:22 +01:00
|
|
|
private summaryPageTransitionContainer: Phaser.GameObjects.Container;
|
2023-04-06 15:05:12 +01:00
|
|
|
|
2023-04-07 18:23:55 +01:00
|
|
|
private moveDescriptionScrollTween: Phaser.Tweens.Tween;
|
2023-04-07 05:17:55 +01:00
|
|
|
private moveCursorBlinkTimer: Phaser.Time.TimerEvent;
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
private pokemon: PlayerPokemon;
|
|
|
|
private newMove: Move;
|
|
|
|
private moveSelectFunction: Function;
|
2023-04-06 16:30:22 +01:00
|
|
|
private transitioning: boolean;
|
2023-04-09 01:35:45 +01:00
|
|
|
private moveEffectsVisible: boolean;
|
2023-04-05 13:35:15 +01:00
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
private moveSelect: boolean;
|
|
|
|
private moveCursor: integer;
|
|
|
|
private selectedMoveIndex: integer;
|
|
|
|
|
2023-04-05 13:35:15 +01:00
|
|
|
constructor(scene: BattleScene) {
|
|
|
|
super(scene, Mode.SUMMARY);
|
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
const ui = this.getUi();
|
|
|
|
|
|
|
|
this.summaryContainer = this.scene.add.container(0, 0);
|
|
|
|
this.summaryContainer.setVisible(false);
|
|
|
|
ui.add(this.summaryContainer);
|
|
|
|
|
|
|
|
const summaryBg = this.scene.add.image(0, 0, 'summary_bg');
|
2023-04-06 15:05:12 +01:00
|
|
|
summaryBg.setOrigin(0, 1);
|
2023-04-05 13:35:15 +01:00
|
|
|
this.summaryContainer.add(summaryBg);
|
|
|
|
|
2023-04-09 01:35:45 +01:00
|
|
|
this.numberText = addTextObject(this.scene, 17, -150, '000', TextStyle.SUMMARY);
|
|
|
|
this.numberText.setOrigin(0, 1);
|
|
|
|
this.summaryContainer.add(this.numberText);
|
|
|
|
|
2023-04-07 18:23:55 +01:00
|
|
|
this.pokemonSprite = this.scene.add.sprite(56, -106, `pkmn__sub`);
|
|
|
|
this.summaryContainer.add(this.pokemonSprite);
|
|
|
|
|
2023-04-09 01:35:45 +01:00
|
|
|
this.nameText = addTextObject(this.scene, 6, -39, '', TextStyle.SUMMARY);
|
|
|
|
this.nameText.setOrigin(0, 1);
|
|
|
|
this.summaryContainer.add(this.nameText);
|
|
|
|
|
|
|
|
this.pokeball = this.scene.add.sprite(6, -23, 'pb');
|
|
|
|
this.pokeball.setOrigin(0, 1);
|
|
|
|
this.summaryContainer.add(this.pokeball);
|
|
|
|
|
|
|
|
this.levelText = addTextObject(this.scene, 36, -22, '', TextStyle.SUMMARY);
|
|
|
|
this.levelText.setOrigin(0, 1);
|
|
|
|
this.summaryContainer.add(this.levelText);
|
|
|
|
|
|
|
|
this.genderText = addTextObject(this.scene, 96, -22, '', TextStyle.SUMMARY);
|
|
|
|
this.genderText.setOrigin(0, 1);
|
|
|
|
this.summaryContainer.add(this.genderText);
|
|
|
|
|
|
|
|
this.moveEffectContainer = this.scene.add.container(106, -62);
|
|
|
|
this.summaryContainer.add(this.moveEffectContainer);
|
|
|
|
|
|
|
|
const moveEffectBg = this.scene.add.image(0, 0, 'summary_moves_effect');
|
|
|
|
moveEffectBg.setOrigin(0, 0);
|
|
|
|
this.moveEffectContainer.add(moveEffectBg);
|
|
|
|
|
|
|
|
this.movePowerText = addTextObject(this.scene, 99, 27, '0', TextStyle.WINDOW);
|
|
|
|
this.movePowerText.setOrigin(1, 1);
|
|
|
|
this.moveEffectContainer.add(this.movePowerText);
|
|
|
|
|
|
|
|
this.moveAccuracyText = addTextObject(this.scene, 99, 43, '0', TextStyle.WINDOW);
|
|
|
|
this.moveAccuracyText.setOrigin(1, 1);
|
|
|
|
this.moveEffectContainer.add(this.moveAccuracyText);
|
|
|
|
|
|
|
|
this.moveCategoryIcon = this.scene.add.sprite(99, 57, 'categories');
|
|
|
|
this.moveCategoryIcon.setOrigin(1, 1);
|
|
|
|
this.moveEffectContainer.add(this.moveCategoryIcon);
|
|
|
|
|
2023-04-06 16:30:22 +01:00
|
|
|
const getSummaryPageBg = () => {
|
|
|
|
const ret = this.scene.add.sprite(0, 0, this.getPageKey(0));
|
|
|
|
ret.setOrigin(0, 1);
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
this.summaryContainer.add((this.summaryPageContainer = this.scene.add.container(106, 0)));
|
|
|
|
this.summaryPageContainer.add(getSummaryPageBg());
|
|
|
|
this.summaryPageContainer.setVisible(false);
|
|
|
|
this.summaryContainer.add((this.summaryPageTransitionContainer = this.scene.add.container(106, 0)));
|
|
|
|
this.summaryPageTransitionContainer.add(getSummaryPageBg());
|
|
|
|
this.summaryPageTransitionContainer.setVisible(false);
|
2023-04-06 15:05:12 +01:00
|
|
|
}
|
|
|
|
|
2023-04-06 16:30:22 +01:00
|
|
|
getPageKey(page?: integer) {
|
|
|
|
if (page === undefined)
|
|
|
|
page = this.cursor;
|
|
|
|
return `summary_${Page[page].toLowerCase()}`;
|
2023-04-05 13:35:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
show(args: any[]) {
|
|
|
|
super.show(args);
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
this.pokemon = args[0] as PlayerPokemon;
|
|
|
|
this.summaryUiMode = args.length > 1 ? args[1] as SummaryUiMode : SummaryUiMode.DEFAULT;
|
|
|
|
|
2023-04-05 13:35:15 +01:00
|
|
|
this.summaryContainer.setVisible(true);
|
2023-04-06 16:30:22 +01:00
|
|
|
this.cursor = -1;
|
2023-04-07 03:24:13 +01:00
|
|
|
|
2023-04-09 01:35:45 +01:00
|
|
|
this.numberText.setText(Utils.padInt(this.pokemon.species.speciesId, 3));
|
|
|
|
|
2023-04-07 18:23:55 +01:00
|
|
|
this.pokemonSprite.play(this.pokemon.getSpriteKey());
|
2023-04-07 03:24:13 +01:00
|
|
|
this.pokemon.cry();
|
|
|
|
|
2023-04-09 01:35:45 +01:00
|
|
|
this.nameText.setText(this.pokemon.name);
|
|
|
|
this.pokeball.setFrame(getPokeballAtlasKey(this.pokemon.pokeball));
|
|
|
|
this.levelText.setText(this.pokemon.level.toString());
|
|
|
|
this.genderText.setText(getGenderSymbol(this.pokemon.gender));
|
|
|
|
this.genderText.setColor(getGenderColor(this.pokemon.gender));
|
|
|
|
this.genderText.setShadowColor(getGenderColor(this.pokemon.gender, true));
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
switch (this.summaryUiMode) {
|
|
|
|
case SummaryUiMode.DEFAULT:
|
2023-04-09 01:35:45 +01:00
|
|
|
const page = args.length < 2 ? Page.PROFILE : args[2] as Page;
|
|
|
|
this.hideMoveEffect(true);
|
|
|
|
this.setCursor(page);
|
2023-04-07 03:24:13 +01:00
|
|
|
break;
|
|
|
|
case SummaryUiMode.LEARN_MOVE:
|
|
|
|
this.newMove = args[2] as Move;
|
|
|
|
this.moveSelectFunction = args[3] as Function;
|
|
|
|
|
2023-04-09 01:35:45 +01:00
|
|
|
this.showMoveEffect(true);
|
2023-04-07 03:24:13 +01:00
|
|
|
this.setCursor(Page.MOVES);
|
|
|
|
this.showMoveSelect();
|
|
|
|
break;
|
|
|
|
}
|
2023-04-05 13:35:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
processInput(keyCode: integer) {
|
2023-04-06 16:30:22 +01:00
|
|
|
if (this.transitioning)
|
|
|
|
return;
|
|
|
|
|
2023-04-05 13:35:15 +01:00
|
|
|
const ui = this.getUi();
|
|
|
|
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
|
2023-04-06 15:05:12 +01:00
|
|
|
|
2023-04-06 16:30:22 +01:00
|
|
|
let success = false;
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
if (this.moveSelect) {
|
|
|
|
if (keyCode === keyCodes.Z) {
|
|
|
|
if (this.moveCursor < this.pokemon.moveset.length) {
|
|
|
|
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE)
|
|
|
|
this.moveSelectFunction(this.moveCursor);
|
2023-04-07 05:17:55 +01:00
|
|
|
else {
|
2023-04-07 18:23:55 +01:00
|
|
|
if (this.selectedMoveIndex === -1) {
|
2023-04-07 05:17:55 +01:00
|
|
|
this.selectedMoveIndex = this.moveCursor;
|
2023-04-07 18:23:55 +01:00
|
|
|
this.setCursor(this.moveCursor);
|
|
|
|
} else {
|
2023-04-07 05:17:55 +01:00
|
|
|
if (this.selectedMoveIndex !== this.moveCursor) {
|
|
|
|
const tempMove = this.pokemon.moveset[this.selectedMoveIndex];
|
|
|
|
this.pokemon.moveset[this.selectedMoveIndex] = this.pokemon.moveset[this.moveCursor];
|
|
|
|
this.pokemon.moveset[this.moveCursor] = tempMove;
|
|
|
|
|
|
|
|
const selectedMoveRow = this.moveRowsContainer.getAt(this.selectedMoveIndex) as Phaser.GameObjects.Container;
|
|
|
|
const switchMoveRow = this.moveRowsContainer.getAt(this.moveCursor) as Phaser.GameObjects.Container;
|
|
|
|
|
|
|
|
this.moveRowsContainer.moveTo(selectedMoveRow, this.moveCursor);
|
|
|
|
this.moveRowsContainer.moveTo(switchMoveRow, this.selectedMoveIndex);
|
|
|
|
|
|
|
|
selectedMoveRow.setY(this.moveCursor * 16);
|
|
|
|
switchMoveRow.setY(this.selectedMoveIndex * 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.selectedMoveIndex = -1;
|
|
|
|
if (this.selectedMoveCursorObj) {
|
|
|
|
this.selectedMoveCursorObj.destroy();
|
|
|
|
this.selectedMoveCursorObj = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-07 03:24:13 +01:00
|
|
|
success = true;
|
|
|
|
} else if (this.moveCursor === 4)
|
|
|
|
this.processInput(keyCodes.X);
|
2023-04-07 05:17:55 +01:00
|
|
|
else
|
|
|
|
ui.playError();
|
2023-04-07 03:24:13 +01:00
|
|
|
} else if (keyCode === keyCodes.X) {
|
|
|
|
this.hideMoveSelect();
|
|
|
|
success = true;
|
|
|
|
} else {
|
|
|
|
switch (keyCode) {
|
|
|
|
case keyCodes.UP:
|
|
|
|
success = this.setCursor(this.moveCursor ? this.moveCursor - 1 : 4);
|
|
|
|
break;
|
|
|
|
case keyCodes.DOWN:
|
|
|
|
success = this.setCursor(this.moveCursor < 4 ? this.moveCursor + 1 : 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-04-06 16:30:22 +01:00
|
|
|
} else {
|
2023-04-07 03:24:13 +01:00
|
|
|
if (keyCode === keyCodes.Z) {
|
|
|
|
if (this.cursor === Page.MOVES) {
|
|
|
|
this.showMoveSelect();
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
} else if (keyCode === keyCodes.X) {
|
|
|
|
ui.setMode(Mode.PARTY);
|
|
|
|
success = true;
|
|
|
|
} else {
|
|
|
|
const pages = Utils.getEnumValues(Page);
|
|
|
|
switch (keyCode) {
|
2023-04-09 01:35:45 +01:00
|
|
|
case keyCodes.UP:
|
|
|
|
case keyCodes.DOWN:
|
|
|
|
const isDown = keyCode === keyCodes.DOWN;
|
|
|
|
const party = this.scene.getParty();
|
|
|
|
const partyMemberIndex = party.indexOf(this.pokemon);
|
|
|
|
if ((isDown && partyMemberIndex < party.length - 1) || (!isDown && partyMemberIndex)) {
|
|
|
|
const page = this.cursor;
|
|
|
|
this.clear();
|
|
|
|
this.show([ party[partyMemberIndex + (isDown ? 1 : -1)], this.summaryUiMode, page ]);
|
|
|
|
}
|
|
|
|
break;
|
2023-04-07 03:24:13 +01:00
|
|
|
case keyCodes.LEFT:
|
|
|
|
if (this.cursor)
|
|
|
|
success = this.setCursor(this.cursor - 1);
|
|
|
|
break;
|
|
|
|
case keyCodes.RIGHT:
|
|
|
|
if (this.cursor < pages.length - 1)
|
|
|
|
success = this.setCursor(this.cursor + 1);
|
|
|
|
break;
|
|
|
|
}
|
2023-04-06 16:30:22 +01:00
|
|
|
}
|
2023-04-06 15:05:12 +01:00
|
|
|
}
|
2023-04-06 16:30:22 +01:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
ui.playSelect();
|
2023-04-05 13:35:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setCursor(cursor: integer): boolean {
|
2023-04-07 03:24:13 +01:00
|
|
|
let changed: boolean;
|
|
|
|
|
|
|
|
if (this.moveSelect) {
|
|
|
|
changed = this.moveCursor !== cursor;
|
|
|
|
if (changed) {
|
|
|
|
this.moveCursor = cursor;
|
|
|
|
|
2023-04-07 05:17:55 +01:00
|
|
|
const selectedMove = this.getSelectedMove();
|
|
|
|
|
2023-04-09 01:35:45 +01:00
|
|
|
if (selectedMove) {
|
|
|
|
this.movePowerText.setText(selectedMove.power >= 0 ? selectedMove.power.toString() : '---');
|
|
|
|
this.moveAccuracyText.setText(selectedMove.accuracy >= 0 ? selectedMove.accuracy.toString() : '---');
|
|
|
|
this.moveCategoryIcon.setFrame(MoveCategory[selectedMove.category].toLowerCase());
|
|
|
|
this.showMoveEffect();
|
|
|
|
} else
|
|
|
|
this.hideMoveEffect();
|
|
|
|
|
2023-04-07 05:17:55 +01:00
|
|
|
this.moveDescriptionText.setText(selectedMove?.effect || '');
|
2023-04-07 18:23:55 +01:00
|
|
|
const moveDescriptionLineCount = Math.floor(this.moveDescriptionText.displayHeight / 14.83);
|
|
|
|
|
|
|
|
if (this.moveDescriptionScrollTween) {
|
|
|
|
this.moveDescriptionScrollTween.remove();
|
|
|
|
this.moveDescriptionScrollTween = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (moveDescriptionLineCount > 3) {
|
|
|
|
this.moveDescriptionText.setY(84);
|
|
|
|
this.moveDescriptionScrollTween = this.scene.tweens.add({
|
|
|
|
targets: this.moveDescriptionText,
|
|
|
|
delay: 2000,
|
|
|
|
loop: -1,
|
|
|
|
loopDelay: 2000,
|
|
|
|
duration: (moveDescriptionLineCount - 3) * 2000,
|
|
|
|
y: `-=${14.83 * (moveDescriptionLineCount - 3)}`,
|
|
|
|
onLoop: () => {
|
|
|
|
this.moveDescriptionText.setY(84);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-04-07 05:17:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.moveCursorObj) {
|
|
|
|
this.moveCursorObj = this.scene.add.sprite(-2, 0, 'summary_moves_cursor', 'highlight');
|
|
|
|
this.moveCursorObj.setOrigin(0, 1);
|
|
|
|
this.movesContainer.add(this.moveCursorObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.moveCursorObj.setY(16 * this.moveCursor + 1);
|
|
|
|
|
|
|
|
if (this.moveCursorBlinkTimer)
|
|
|
|
this.moveCursorBlinkTimer.destroy();
|
2023-04-07 18:23:55 +01:00
|
|
|
this.moveCursorObj.setVisible(true);
|
2023-04-07 05:17:55 +01:00
|
|
|
this.moveCursorBlinkTimer = this.scene.time.addEvent({
|
|
|
|
loop: true,
|
|
|
|
delay: 600,
|
|
|
|
callback: () => {
|
|
|
|
this.moveCursorObj.setVisible(false);
|
|
|
|
this.scene.time.delayedCall(100, () => {
|
2023-04-09 01:35:45 +01:00
|
|
|
if (!this.moveCursorObj)
|
|
|
|
return;
|
2023-04-07 05:17:55 +01:00
|
|
|
this.moveCursorObj.setVisible(true);
|
|
|
|
});
|
2023-04-07 03:24:13 +01:00
|
|
|
}
|
2023-04-07 05:17:55 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
if (this.selectedMoveIndex > -1) {
|
|
|
|
if (!this.selectedMoveCursorObj) {
|
|
|
|
this.selectedMoveCursorObj = this.scene.add.sprite(-2, 0, 'summary_moves_cursor', 'select');
|
|
|
|
this.selectedMoveCursorObj.setOrigin(0, 1);
|
|
|
|
this.movesContainer.add(this.selectedMoveCursorObj);
|
|
|
|
this.movesContainer.moveBelow(this.selectedMoveCursorObj, this.moveCursorObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.selectedMoveCursorObj.setY(16 * this.selectedMoveIndex + 1);
|
2023-04-07 03:24:13 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
changed = this.cursor !== cursor;
|
|
|
|
if (changed) {
|
|
|
|
const forward = this.cursor < cursor;
|
|
|
|
this.cursor = cursor;
|
|
|
|
|
|
|
|
if (this.summaryPageContainer.visible) {
|
|
|
|
this.transitioning = true;
|
|
|
|
this.populatePageContainer(this.summaryPageTransitionContainer, forward ? cursor : cursor + 1);
|
|
|
|
if (forward)
|
|
|
|
this.summaryPageTransitionContainer.x += 214;
|
|
|
|
else
|
|
|
|
this.populatePageContainer(this.summaryPageContainer);
|
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: this.summaryPageTransitionContainer,
|
|
|
|
x: forward ? '-=214' : '+=214',
|
|
|
|
duration: 250,
|
|
|
|
onComplete: () => {
|
|
|
|
if (forward)
|
|
|
|
this.populatePageContainer(this.summaryPageContainer);
|
|
|
|
else
|
|
|
|
this.summaryPageTransitionContainer.x -= 214;
|
|
|
|
this.summaryPageTransitionContainer.setVisible(false);
|
|
|
|
this.transitioning = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.summaryPageTransitionContainer.setVisible(true);
|
|
|
|
} else {
|
2023-04-06 16:30:22 +01:00
|
|
|
this.populatePageContainer(this.summaryPageContainer);
|
2023-04-07 03:24:13 +01:00
|
|
|
this.summaryPageContainer.setVisible(true);
|
|
|
|
}
|
2023-04-06 16:30:22 +01:00
|
|
|
}
|
2023-04-05 13:35:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
2023-04-06 16:30:22 +01:00
|
|
|
populatePageContainer(pageContainer: Phaser.GameObjects.Container, page?: Page) {
|
|
|
|
if (page === undefined)
|
|
|
|
page = this.cursor;
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
if (pageContainer.getAll().length > 1) {
|
|
|
|
if (this.movesContainer)
|
|
|
|
this.movesContainer.removeAll(true);
|
2023-04-06 16:30:22 +01:00
|
|
|
pageContainer.removeBetween(1, undefined, true);
|
2023-04-07 03:24:13 +01:00
|
|
|
}
|
|
|
|
const pageBg = (pageContainer.getAt(0) as Phaser.GameObjects.Sprite);
|
|
|
|
pageBg.setTexture(this.getPageKey(page));
|
2023-04-06 16:30:22 +01:00
|
|
|
|
|
|
|
switch (page) {
|
|
|
|
case Page.MOVES:
|
2023-04-07 03:24:13 +01:00
|
|
|
this.movesContainer = this.scene.add.container(5, -pageBg.height + 26);
|
|
|
|
pageContainer.add(this.movesContainer);
|
|
|
|
|
|
|
|
this.extraMoveRowContainer = this.scene.add.container(0, 64);
|
2023-04-07 05:17:55 +01:00
|
|
|
this.extraMoveRowContainer.setVisible(false);
|
2023-04-07 03:24:13 +01:00
|
|
|
this.movesContainer.add(this.extraMoveRowContainer);
|
|
|
|
|
|
|
|
const extraRowOverlay = this.scene.add.image(-2, 1, 'summary_moves_overlay_row');
|
|
|
|
extraRowOverlay.setOrigin(0, 1);
|
|
|
|
this.extraMoveRowContainer.add(extraRowOverlay);
|
|
|
|
|
|
|
|
const extraRowText = addTextObject(this.scene, 35, 0, this.summaryUiMode === SummaryUiMode.LEARN_MOVE ? this.newMove.name : 'CANCEL',
|
|
|
|
this.summaryUiMode === SummaryUiMode.LEARN_MOVE ? TextStyle.SUMMARY_RED : TextStyle.SUMMARY);
|
|
|
|
extraRowText.setOrigin(0, 1);
|
|
|
|
this.extraMoveRowContainer.add(extraRowText);
|
|
|
|
|
2023-04-10 18:54:06 +01:00
|
|
|
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) {
|
|
|
|
const newMoveTypeIcon = this.scene.add.sprite(0, 0, 'types', Type[this.newMove.type].toLowerCase());
|
|
|
|
newMoveTypeIcon.setOrigin(0, 1);
|
|
|
|
this.extraMoveRowContainer.add(newMoveTypeIcon);
|
|
|
|
}
|
|
|
|
|
2023-04-07 05:17:55 +01:00
|
|
|
this.moveRowsContainer = this.scene.add.container(0, 0);
|
|
|
|
this.movesContainer.add(this.moveRowsContainer);
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
for (let m = 0; m < 4; m++) {
|
|
|
|
const move = m < this.pokemon.moveset.length ? this.pokemon.moveset[m] : null;
|
2023-04-07 05:17:55 +01:00
|
|
|
const moveRowContainer = this.scene.add.container(0, 16 * m);
|
|
|
|
this.moveRowsContainer.add(moveRowContainer);
|
2023-04-07 03:24:13 +01:00
|
|
|
|
|
|
|
if (move) {
|
2023-04-07 05:17:55 +01:00
|
|
|
const typeIcon = this.scene.add.sprite(0, 0, 'types', Type[move.getMove().type].toLowerCase());
|
2023-04-07 03:24:13 +01:00
|
|
|
typeIcon.setOrigin(0, 1);
|
2023-04-07 05:17:55 +01:00
|
|
|
moveRowContainer.add(typeIcon);
|
2023-04-07 03:24:13 +01:00
|
|
|
}
|
|
|
|
|
2023-04-07 05:17:55 +01:00
|
|
|
const moveText = addTextObject(this.scene, 35, 0, move ? move.getName() : '-', TextStyle.SUMMARY);
|
2023-04-07 03:24:13 +01:00
|
|
|
moveText.setOrigin(0, 1);
|
2023-04-07 05:17:55 +01:00
|
|
|
moveRowContainer.add(moveText);
|
2023-04-07 03:24:13 +01:00
|
|
|
}
|
2023-04-07 05:17:55 +01:00
|
|
|
|
|
|
|
this.moveDescriptionText = addTextObject(this.scene, 2, 84, '', TextStyle.WINDOW, { wordWrap: { width: 900 } });
|
|
|
|
this.movesContainer.add(this.moveDescriptionText);
|
|
|
|
|
|
|
|
const maskRect = this.scene.make.graphics({});
|
2023-04-07 18:23:55 +01:00
|
|
|
maskRect.setScale(6);
|
2023-04-07 05:17:55 +01:00
|
|
|
maskRect.fillStyle(0xFFFFFF);
|
|
|
|
maskRect.beginPath();
|
2023-04-07 18:23:55 +01:00
|
|
|
maskRect.fillRect(112, 130, 150, 46);
|
2023-04-07 05:17:55 +01:00
|
|
|
|
|
|
|
const moveDescriptionTextMask = maskRect.createGeometryMask();
|
|
|
|
|
|
|
|
this.moveDescriptionText.setMask(moveDescriptionTextMask);
|
2023-04-06 16:30:22 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-07 05:17:55 +01:00
|
|
|
getSelectedMove(): Move {
|
|
|
|
if (this.cursor !== Page.MOVES)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
if (this.moveCursor < 4 && this.moveCursor < this.pokemon.moveset.length)
|
|
|
|
return this.pokemon.moveset[this.moveCursor].getMove();
|
|
|
|
else if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE && this.moveCursor === 4)
|
|
|
|
return this.newMove;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-04-07 03:24:13 +01:00
|
|
|
showMoveSelect() {
|
|
|
|
this.moveSelect = true;
|
2023-04-07 05:17:55 +01:00
|
|
|
this.extraMoveRowContainer.setVisible(true);
|
|
|
|
this.selectedMoveIndex = -1;
|
2023-04-07 03:24:13 +01:00
|
|
|
this.setCursor(0);
|
2023-04-09 01:35:45 +01:00
|
|
|
this.showMoveEffect();
|
2023-04-07 03:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hideMoveSelect() {
|
|
|
|
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) {
|
|
|
|
this.moveSelectFunction(4);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.moveSelect = false;
|
2023-04-07 05:17:55 +01:00
|
|
|
this.extraMoveRowContainer.setVisible(false);
|
|
|
|
if (this.moveCursorBlinkTimer) {
|
|
|
|
this.moveCursorBlinkTimer.destroy();
|
|
|
|
this.moveCursorBlinkTimer = null;
|
|
|
|
}
|
|
|
|
if (this.moveCursorObj) {
|
|
|
|
this.moveCursorObj.destroy();
|
|
|
|
this.moveCursorObj = null;
|
|
|
|
}
|
|
|
|
if (this.selectedMoveCursorObj) {
|
|
|
|
this.selectedMoveCursorObj.destroy();
|
|
|
|
this.selectedMoveCursorObj = null;
|
|
|
|
}
|
2023-04-09 01:35:45 +01:00
|
|
|
|
|
|
|
this.hideMoveEffect();
|
|
|
|
}
|
|
|
|
|
|
|
|
showMoveEffect(instant?: boolean) {
|
|
|
|
if (this.moveEffectsVisible)
|
|
|
|
return;
|
|
|
|
this.moveEffectsVisible = true;
|
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: this.moveEffectContainer,
|
|
|
|
x: 6,
|
|
|
|
duration: instant ? 0 : 250,
|
|
|
|
ease: 'Sine.easeOut'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
hideMoveEffect(instant?: boolean) {
|
|
|
|
if (!this.moveEffectsVisible)
|
|
|
|
return;
|
|
|
|
this.moveEffectsVisible = false;
|
|
|
|
this.scene.tweens.add({
|
|
|
|
targets: this.moveEffectContainer,
|
|
|
|
x: 106,
|
|
|
|
duration: instant ? 0 : 250,
|
|
|
|
ease: 'Sine.easeIn'
|
|
|
|
});
|
2023-04-07 03:24:13 +01:00
|
|
|
}
|
|
|
|
|
2023-04-05 13:35:15 +01:00
|
|
|
clear() {
|
|
|
|
super.clear();
|
2023-04-07 03:24:13 +01:00
|
|
|
this.pokemon = null;
|
2023-04-06 16:30:22 +01:00
|
|
|
this.cursor = -1;
|
2023-04-07 03:24:13 +01:00
|
|
|
this.newMove = null;
|
2023-04-10 18:54:06 +01:00
|
|
|
if (this.moveSelect) {
|
|
|
|
this.moveSelect = false;
|
|
|
|
this.moveSelectFunction = null;
|
|
|
|
this.extraMoveRowContainer.setVisible(false);
|
|
|
|
if (this.moveCursorBlinkTimer) {
|
|
|
|
this.moveCursorBlinkTimer.destroy();
|
|
|
|
this.moveCursorBlinkTimer = null;
|
|
|
|
}
|
|
|
|
if (this.moveCursorObj) {
|
|
|
|
this.moveCursorObj.destroy();
|
|
|
|
this.moveCursorObj = null;
|
|
|
|
}
|
|
|
|
if (this.selectedMoveCursorObj) {
|
|
|
|
this.selectedMoveCursorObj.destroy();
|
|
|
|
this.selectedMoveCursorObj = null;
|
|
|
|
}
|
|
|
|
this.hideMoveEffect(true);
|
|
|
|
}
|
2023-04-05 13:35:15 +01:00
|
|
|
this.summaryContainer.setVisible(false);
|
2023-04-06 16:30:22 +01:00
|
|
|
this.summaryPageContainer.setVisible(false);
|
2023-04-05 13:35:15 +01:00
|
|
|
}
|
|
|
|
}
|