sprite display fix

This commit is contained in:
James Diefenbach 2024-08-30 21:16:02 +10:00
parent 1de58d9890
commit 5b51e77830
3 changed files with 44 additions and 25 deletions

View File

@ -314,7 +314,6 @@ export class EggHatchPhase extends Phase {
*/ */
doReveal(): void { doReveal(): void {
// set the previous dex data so info container can show new unlocks in egg summary // set the previous dex data so info container can show new unlocks in egg summary
this.eggHatchData.setDex();
const isShiny = this.pokemon.isShiny(); const isShiny = this.pokemon.isShiny();
if (this.pokemon.species.subLegendary) { if (this.pokemon.species.subLegendary) {
this.scene.validateAchv(achvs.HATCH_SUB_LEGENDARY); this.scene.validateAchv(achvs.HATCH_SUB_LEGENDARY);
@ -449,7 +448,6 @@ export class EggHatchPhase extends Phase {
*/ */
generatePokemon(): PlayerPokemon { generatePokemon(): PlayerPokemon {
this.eggHatchData = this.hatchScene.generatePokemon(this.egg); this.eggHatchData = this.hatchScene.generatePokemon(this.egg);
this.eggHatchData.setDex();
return this.eggHatchData.pokemon; return this.eggHatchData.pokemon;
} }
} }

View File

@ -139,6 +139,8 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
this.pokemonIconsContainer.setVisible(true); this.pokemonIconsContainer.setVisible(true);
this.eggHatchBg.setVisible(true); this.eggHatchBg.setVisible(true);
this.infoContainer.hideDisplayPokemon();
this.eggHatchData.forEach( (value: EggHatchData, i: number) => { this.eggHatchData.forEach( (value: EggHatchData, i: number) => {
const x = (i % 11) * 18; const x = (i % 11) * 18;
const y = Math.floor(i / 11) * 18; const y = Math.floor(i / 11) * 18;
@ -210,8 +212,10 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
em.setScale(0.5); em.setScale(0.5);
em.setVisible(value.eggMoveUnlocked); em.setVisible(value.eggMoveUnlocked);
this.pokemonIconsContainer.add(em); this.pokemonIconsContainer.add(em);
if (i === 0) {
this.infoContainer.displayPokemon(displayPokemon);
}
}); });
this.setCursor(0); this.setCursor(0);
return true; return true;

View File

@ -13,6 +13,7 @@ import { getEggTierForSpecies } from "#app/data/egg.js";
import { starterColors } from "../battle-scene"; import { starterColors } from "../battle-scene";
import { argbFromRgba } from "@material/material-color-utilities"; import { argbFromRgba } from "@material/material-color-utilities";
import { EggHatchData } from "#app/data/egg-hatch-data.js"; import { EggHatchData } from "#app/data/egg-hatch-data.js";
import { PlayerPokemon } from "#app/field/pokemon.js";
/** /**
* Class for the hatch info summary of each pokemon * Class for the hatch info summary of each pokemon
@ -114,30 +115,22 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
} }
/** /**
* Updates the info container with the appropriate dex data and starter entry from the hatchInfo * Disable the sprite (and replace with substitute)
* Also updates the displayed name, number, egg moves and main animated sprite for the pokemon
* @param hatchInfo The EggHatchData of the pokemon / new hatch to show
*/ */
showHatchInfo(hatchInfo: EggHatchData) { hideDisplayPokemon() {
console.log("showing hatch info", hatchInfo.pokemon.name); this.currentPokemonSprite.setVisible(false);
this.pokemonEggMovesContainer.setVisible(true); }
const displayPokemon = hatchInfo.pokemon; /**
const species = displayPokemon.species; * Display a given pokemon sprite with animations
const female = displayPokemon.gender === Gender.FEMALE; */
const formIndex = displayPokemon.formIndex; displayPokemon(pokemon: PlayerPokemon) {
const shiny = displayPokemon.shiny; console.log("displaying pokemon", pokemon.name);
const variant = displayPokemon.variant; const species = pokemon.species;
const female = pokemon.gender === Gender.FEMALE;
super.show(displayPokemon, false, 1, hatchInfo.getDex(), hatchInfo.getStarterEntry(), true); const formIndex = pokemon.formIndex;
const colorScheme = starterColors[species.speciesId]; const shiny = pokemon.shiny;
const variant = pokemon.variant;
this.pokemonCandyIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[0])));
this.pokemonCandyIcon.setVisible(true);
this.pokemonCandyOverlayIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[1])));
this.pokemonCandyOverlayIcon.setVisible(true);
this.pokemonCandyCountText.setText(`x${this.scene.gameData.starterData[species.speciesId].candyCount}`);
this.pokemonCandyCountText.setVisible(true);
species.loadAssets(this.scene, female, formIndex, shiny, variant, true).then(() => { species.loadAssets(this.scene, female, formIndex, shiny, variant, true).then(() => {
// if (assetLoadCancelled.value) { // if (assetLoadCancelled.value) {
// return; // return;
@ -152,6 +145,30 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
this.currentPokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female, formIndex, shiny, variant)); this.currentPokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female, formIndex, shiny, variant));
// this.pokemonSprite.setVisible(!this.statsMode); // this.pokemonSprite.setVisible(!this.statsMode);
}); });
}
/**
* Updates the info container with the appropriate dex data and starter entry from the hatchInfo
* Also updates the displayed name, number, egg moves and main animated sprite for the pokemon
* @param hatchInfo The EggHatchData of the pokemon / new hatch to show
*/
showHatchInfo(hatchInfo: EggHatchData) {
console.log("showing hatch info", hatchInfo.pokemon.name);
this.pokemonEggMovesContainer.setVisible(true);
const pokemon = hatchInfo.pokemon;
const species = pokemon.species;
this.displayPokemon(pokemon);
super.show(pokemon, false, 1, hatchInfo.getDex(), hatchInfo.getStarterEntry(), true);
const colorScheme = starterColors[species.speciesId];
this.pokemonCandyIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[0])));
this.pokemonCandyIcon.setVisible(true);
this.pokemonCandyOverlayIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[1])));
this.pokemonCandyOverlayIcon.setVisible(true);
this.pokemonCandyCountText.setText(`x${this.scene.gameData.starterData[species.speciesId].candyCount}`);
this.pokemonCandyCountText.setVisible(true);
this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4)); this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4));
this.pokemonNameText.setText(species.name); this.pokemonNameText.setText(species.name);