Add starter moves on starter select (WiP)

This commit is contained in:
Flashfyre 2024-02-20 22:53:33 -05:00
parent 6460e736a7
commit 58ba0ec52d
4 changed files with 468 additions and 0 deletions

View File

@ -0,0 +1,419 @@
{
"textures": [
{
"image": "type_bgs.png",
"format": "RGBA8888",
"size": {
"w": 14,
"h": 266
},
"scale": 1,
"frames": [
{
"filename": "unknown",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
}
},
{
"filename": "bug",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 14,
"w": 14,
"h": 14
}
},
{
"filename": "dark",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 28,
"w": 14,
"h": 14
}
},
{
"filename": "dragon",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 42,
"w": 14,
"h": 14
}
},
{
"filename": "electric",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 56,
"w": 14,
"h": 14
}
},
{
"filename": "fairy",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 70,
"w": 14,
"h": 14
}
},
{
"filename": "fighting",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 84,
"w": 14,
"h": 14
}
},
{
"filename": "fire",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 98,
"w": 14,
"h": 14
}
},
{
"filename": "flying",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 112,
"w": 14,
"h": 14
}
},
{
"filename": "ghost",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 126,
"w": 14,
"h": 14
}
},
{
"filename": "grass",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 140,
"w": 14,
"h": 14
}
},
{
"filename": "ground",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 154,
"w": 14,
"h": 14
}
},
{
"filename": "ice",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 168,
"w": 14,
"h": 14
}
},
{
"filename": "normal",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 182,
"w": 14,
"h": 14
}
},
{
"filename": "poison",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 196,
"w": 14,
"h": 14
}
},
{
"filename": "psychic",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 210,
"w": 14,
"h": 14
}
},
{
"filename": "rock",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 224,
"w": 14,
"h": 14
}
},
{
"filename": "steel",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 238,
"w": 14,
"h": 14
}
},
{
"filename": "water",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 14,
"h": 14
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 14,
"h": 14
},
"frame": {
"x": 0,
"y": 252,
"w": 14,
"h": 14
}
}
]
}
],
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "3.0",
"smartupdate": "$TexturePacker:SmartUpdate:f14cf47d9a8f1d40c8e03aa6ba00fff3:6fc4227b57a95d429a1faad4280f7ec8:5961efbfbf4c56b8745347e7a663a14f$"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

View File

@ -241,6 +241,7 @@ export default class BattleScene extends Phaser.Scene {
this.loadImage('icon_spliced', 'ui'); this.loadImage('icon_spliced', 'ui');
this.loadImage('icon_tera', 'ui'); this.loadImage('icon_tera', 'ui');
this.loadImage('type_tera', 'ui'); this.loadImage('type_tera', 'ui');
this.loadAtlas('type_bgs', 'ui');
this.loadImage('pb_tray_overlay_player', 'ui'); this.loadImage('pb_tray_overlay_player', 'ui');
this.loadImage('pb_tray_overlay_enemy', 'ui'); this.loadImage('pb_tray_overlay_enemy', 'ui');

View File

@ -18,6 +18,9 @@ import { Nature, getNatureName } from "../data/nature";
import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
import { pokemonFormChanges } from "../data/pokemon-forms"; import { pokemonFormChanges } from "../data/pokemon-forms";
import { Tutorial, handleTutorial } from "../tutorial"; import { Tutorial, handleTutorial } from "../tutorial";
import { pokemonSpeciesLevelMoves } from "../data/pokemon-level-moves";
import { allMoves } from "../data/move";
import { Type } from "../data/type";
export type StarterSelectCallback = (starters: Starter[]) => void; export type StarterSelectCallback = (starters: Starter[]) => void;
@ -46,6 +49,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
private pokemonNatureText: BBCodeText; private pokemonNatureText: BBCodeText;
private pokemonCaughtCountLabelText: Phaser.GameObjects.Text; private pokemonCaughtCountLabelText: Phaser.GameObjects.Text;
private pokemonCaughtCountText: Phaser.GameObjects.Text; private pokemonCaughtCountText: Phaser.GameObjects.Text;
private pokemonMoveContainers: Phaser.GameObjects.Container[];
private pokemonMoveBgs: Phaser.GameObjects.NineSlice[];
private pokemonMoveLabels: Phaser.GameObjects.Text[];
private genOptionsText: Phaser.GameObjects.Text; private genOptionsText: Phaser.GameObjects.Text;
private instructionsText: Phaser.GameObjects.Text; private instructionsText: Phaser.GameObjects.Text;
private starterSelectMessageBox: Phaser.GameObjects.NineSlice; private starterSelectMessageBox: Phaser.GameObjects.NineSlice;
@ -171,6 +177,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonCaughtCountText.setOrigin(0, 0); this.pokemonCaughtCountText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonCaughtCountText); this.starterSelectContainer.add(this.pokemonCaughtCountText);
this.pokemonMoveContainers = [];
this.pokemonMoveBgs = [];
this.pokemonMoveLabels = [];
this.genOptionsText = addTextObject(this.scene, 124, 7, '', TextStyle.WINDOW, { fontSize: 72, lineSpacing: 39, align: 'center' }); this.genOptionsText = addTextObject(this.scene, 124, 7, '', TextStyle.WINDOW, { fontSize: 72, lineSpacing: 39, align: 'center' });
this.genOptionsText.setShadowOffset(4.5, 4.5); this.genOptionsText.setShadowOffset(4.5, 4.5);
this.genOptionsText.setOrigin(0.5, 0); this.genOptionsText.setOrigin(0.5, 0);
@ -290,6 +300,27 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`); this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`);
this.starterSelectContainer.add(this.pokemonSprite); this.starterSelectContainer.add(this.pokemonSprite);
for (let m = 0; m < 4; m++) {
const moveContainer = this.scene.add.container(102, 16 + 7 * m);
moveContainer.setScale(0.5);
const moveBg = this.scene.add.nineslice(0, 0, 'type_bgs', 'unknown', 92, 14, 2, 2, 2, 2);
moveBg.setOrigin(1, 0);
const moveLabel = addTextObject(this.scene, -moveBg.width / 2, 0, 'Thunder Wave', TextStyle.PARTY);
moveLabel.setOrigin(0.5, 0);
this.pokemonMoveBgs.push(moveBg);
this.pokemonMoveLabels.push(moveLabel);
moveContainer.add(moveBg);
moveContainer.add(moveLabel);
this.pokemonMoveContainers.push(moveContainer);
this.starterSelectContainer.add(moveContainer);
}
this.instructionsText = addTextObject(this.scene, 4, 156, '', TextStyle.PARTY, { fontSize: '42px' }); this.instructionsText = addTextObject(this.scene, 4, 156, '', TextStyle.PARTY, { fontSize: '42px' });
this.starterSelectContainer.add(this.instructionsText); this.starterSelectContainer.add(this.instructionsText);
@ -492,6 +523,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.toggleStatsMode(); this.toggleStatsMode();
ui.setMode(Mode.STARTER_SELECT); ui.setMode(Mode.STARTER_SELECT);
} }
},
{
label: 'Cancel',
handler: () => {
ui.setMode(Mode.STARTER_SELECT);
}
} }
], ],
yOffset: 47 yOffset: 47
@ -861,6 +898,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.assetLoadCancelled = null; this.assetLoadCancelled = null;
} }
const starterMoves = [];
if (species) { if (species) {
const dexEntry = this.scene.gameData.dexData[species.speciesId]; const dexEntry = this.scene.gameData.dexData[species.speciesId];
if (!dexEntry.caughtAttr) { if (!dexEntry.caughtAttr) {
@ -934,6 +973,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonAbilityText.setShadowColor(getTextColor(!isHidden ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true)); this.pokemonAbilityText.setShadowColor(getTextColor(!isHidden ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true));
this.pokemonNatureText.setText(getNatureName(natureIndex as unknown as Nature, true, true)); this.pokemonNatureText.setText(getNatureName(natureIndex as unknown as Nature, true, true));
starterMoves.push(...pokemonSpeciesLevelMoves[species.speciesId].slice(0, 4).filter(lm => lm[0] <= 5).map(lm => lm[1]));
} else { } else {
this.pokemonAbilityText.setText(''); this.pokemonAbilityText.setText('');
this.pokemonNatureText.setText(''); this.pokemonNatureText.setText('');
@ -944,6 +985,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonNatureText.setText(''); this.pokemonNatureText.setText('');
} }
for (let m = 0; m < 4; m++) {
const move = m < starterMoves.length ? allMoves[starterMoves[m]] : null;
this.pokemonMoveBgs[m].setFrame(Type[move ? move.type : Type.UNKNOWN].toString().toLowerCase());
this.pokemonMoveLabels[m].setText(move ? move.name : '-');
this.pokemonMoveContainers[m].setVisible(!!move);
}
this.updateInstructions(); this.updateInstructions();
} }