Add spliced endless mode and splice indicator

This commit is contained in:
Flashfyre committed 2023-11-04 19:46:48 -04:00
1 parent e07339e3eb
commit b85bb0916d
16 files changed
+152 -34

No files matched your search

+15
View File
@@ -24,6 +24,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
private nameText: Phaser.GameObjects.Text;
private genderText: Phaser.GameObjects.Text;
private ownedIcon: Phaser.GameObjects.Sprite;
private splicedIcon: Phaser.GameObjects.Sprite;
private statusIndicator: Phaser.GameObjects.Sprite;
private levelContainer: Phaser.GameObjects.Container;
private hpBar: Phaser.GameObjects.Image;
@@ -69,6 +70,13 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
this.add(this.ownedIcon);
}
this.splicedIcon = this.scene.add.sprite(0, 0, 'icon_spliced');
this.splicedIcon.setVisible(false);
this.splicedIcon.setOrigin(0, 0);
this.splicedIcon.setPositionRelative(this.nameText, 0, 2);
this.splicedIcon.setInteractive(new Phaser.Geom.Rectangle(0, 0, 5, 7), Phaser.Geom.Rectangle.Contains);
this.add(this.splicedIcon);
this.statusIndicator = this.scene.add.sprite(0, 0, 'statuses');
this.statusIndicator.setVisible(false);
this.statusIndicator.setOrigin(0, 0);
@@ -113,6 +121,13 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
this.genderText.setColor(getGenderColor(pokemon.gender));
this.genderText.setPositionRelative(this.nameText, nameTextWidth, 0);
this.splicedIcon.setPositionRelative(this.nameText, nameTextWidth + this.genderText.displayWidth + 1, 1);
this.splicedIcon.setVisible(!!pokemon.fusionSpecies);
if (this.splicedIcon.visible) {
this.splicedIcon.on('pointerover', () => (this.scene as BattleScene).ui.showTooltip(null, `Spliced with ${pokemon.fusionSpecies.name}`));
this.splicedIcon.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip());
}
if (!this.player) {
const speciesOwned = !!pokemon.scene.gameData.getDefaultDexEntry(pokemon.species)?.entry?.caught;
this.ownedIcon.setVisible(speciesOwned);
+45 -4
View File
@@ -1,4 +1,6 @@
import BattleScene from "../battle-scene";
import BattleScene, { Button } from "../battle-scene";
import { GameMode, gameModeNames } from "../game-mode";
import { Unlockables } from "../system/unlockables";
import OptionSelectUiHandler from "./option-select-ui-handler";
import { Mode } from "./ui";
@@ -9,14 +11,53 @@ export default class GameModeSelectUiHandler extends OptionSelectUiHandler {
}
getWindowWidth(): integer {
return 64;
return 104;
}
getWindowHeight(): number {
return 64;
return (this.getOptions().length + 1) * 16;
}
getOptions(): string[] {
return [ 'Classic', 'Endless', 'Cancel' ];
const ret = [ gameModeNames[GameMode.CLASSIC] ];
if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
ret.push(gameModeNames[GameMode.ENDLESS]);
if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE])
ret.push(gameModeNames[GameMode.SPLICED_ENDLESS]);
}
ret.push('Cancel');
return ret;
}
show(args: any[]) {
if (args.length === 2 && args[0] instanceof Function && args[1] instanceof Function) {
this.setupOptions();
super.show(args);
this.handlers = args as Function[];
this.optionSelectContainer.setVisible(true);
this.setCursor(0);
}
}
processInput(button: Button) {
const ui = this.getUi();
const options = this.getOptions();
if (button === Button.ACTION || button === Button.CANCEL) {
if (button === Button.CANCEL)
this.setCursor(options.length - 1);
if (this.cursor < options.length - 1) {
const gameMode = Object.values(gameModeNames).indexOf(options[this.cursor]) as GameMode;
this.handlers[0](gameMode);
} else
this.handlers[1]();
this.clear();
ui.playSelect();
} else
return super.processInput(button);
}
}
+17 -7
View File
@@ -8,6 +8,7 @@ export default abstract class OptionSelectUiHandler extends UiHandler {
protected optionSelectContainer: Phaser.GameObjects.Container;
protected optionSelectBg: Phaser.GameObjects.NineSlice;
protected optionSelectText: Phaser.GameObjects.Text;
private cursorObj: Phaser.GameObjects.Image;
@@ -24,22 +25,31 @@ export default abstract class OptionSelectUiHandler extends UiHandler {
setup() {
const ui = this.getUi();
this.optionSelectContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - (this.getWindowWidth() + 1), -(this.getWindowWidth() + 1));
this.optionSelectContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 1, -48);
this.optionSelectContainer.setVisible(false);
ui.add(this.optionSelectContainer);
this.optionSelectBg = this.scene.add.nineslice(0, 0, 'window', null, this.getWindowWidth(), this.getWindowHeight(), 6, 6, 6, 6);
this.optionSelectBg.setOrigin(0, 1);
this.optionSelectBg.setOrigin(1, 1);
this.optionSelectContainer.add(this.optionSelectBg);
this.setupOptions();
this.setCursor(0);
}
protected setupOptions() {
const options = this.getOptions();
const optionSelectText = addTextObject(this.scene, 0, 0, options.join('\n'), TextStyle.WINDOW, { maxLines: options.length });
optionSelectText.setPositionRelative(this.optionSelectBg, 16, 9);
optionSelectText.setLineSpacing(12);
this.optionSelectContainer.add(optionSelectText);
if (this.optionSelectText)
this.optionSelectText.destroy();
this.setCursor(0);
this.optionSelectText = addTextObject(this.scene, 0, 0, options.join('\n'), TextStyle.WINDOW, { maxLines: options.length });
this.optionSelectText.setPositionRelative(this.optionSelectBg, 16, 9);
this.optionSelectText.setLineSpacing(12);
this.optionSelectContainer.add(this.optionSelectText);
this.optionSelectBg.width = Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth());
this.optionSelectBg.height = this.getWindowHeight();
}
show(args: any[]) {
+1 -3
View File
@@ -371,9 +371,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
};
if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
ui.setMode(Mode.STARTER_SELECT);
ui.showText('Select a game mode.', null, () => {
ui.setModeWithoutClear(Mode.GAME_MODE_SELECT, () => startRun(GameMode.CLASSIC), () => startRun(GameMode.ENDLESS), cancel);
});
ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.GAME_MODE_SELECT, startRun, cancel));
} else
startRun(GameMode.CLASSIC);
}, cancel);
+4 -2
View File
@@ -146,10 +146,12 @@ export default class UI extends Phaser.GameObjects.Container {
showTooltip(title: string, content: string, overlap?: boolean): void {
this.tooltipContainer.setVisible(true);
this.tooltipTitle.setText(title);
this.tooltipTitle.setText(title || '');
const wrappedContent = this.tooltipContent.runWordWrap(content);
this.tooltipContent.setText(wrappedContent);
this.tooltipBg.height = 31 + 10.5 * (wrappedContent.split('\n').length - 1);
this.tooltipContent.y = title ? 16 : 4;
this.tooltipBg.width = Math.min(Math.max(this.tooltipTitle.displayWidth, this.tooltipContent.displayWidth) + 12, 684);
this.tooltipBg.height = (title ? 31 : 19) + 10.5 * (wrappedContent.split('\n').length - 1);
if (overlap)
(this.scene as BattleScene).uiContainer.moveAbove(this.tooltipContainer, this);
else