Add shiny sparkle animation to egg hatch scene

Add shiny sparkle animation to egg hatch scene; implement missing logic for same seed trainer party member generation
pull/14/head
Flashfyre 2023-12-26 12:29:18 -05:00
parent e265c1961f
commit 97124c2710
3 changed files with 38 additions and 19 deletions

View File

@ -26,6 +26,7 @@ export class EggHatchPhase extends BattlePhase {
private eggCrackSprite: Phaser.GameObjects.Sprite;
private eggLightraysOverlay: Phaser.GameObjects.Sprite;
private pokemonSprite: Phaser.GameObjects.Sprite;
private pokemonShinySparkle: Phaser.GameObjects.Sprite;
private infoContainer: Phaser.GameObjects.Container;
private statsContainer: StatsContainer;
@ -80,6 +81,11 @@ export class EggHatchPhase extends BattlePhase {
this.eggHatchContainer.add((this.pokemonSprite = getPokemonSprite()));
this.pokemonShinySparkle = this.scene.add.sprite(this.pokemonSprite.x, this.pokemonSprite.y, 'shiny');
this.pokemonShinySparkle.setVisible(false);
this.eggHatchContainer.add(this.pokemonShinySparkle);
this.eggHatchOverlay = this.scene.add.rectangle(0, -this.scene.game.canvas.height / 6, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6, 0xFFFFFF);
this.eggHatchOverlay.setOrigin(0, 0);
this.eggHatchOverlay.setAlpha(0);
@ -173,18 +179,25 @@ export class EggHatchPhase extends BattlePhase {
ease: 'Cubic.easeIn'
});
this.scene.time.delayedCall(Utils.fixedInt(1500), () => {
const isShiny = pokemon.isShiny();
if (pokemon.species.mythical)
this.scene.validateAchv(achvs.HATCH_MYTHICAL);
if (pokemon.species.legendary)
this.scene.validateAchv(achvs.HATCH_LEGENDARY);
if (pokemon.isShiny())
if (isShiny)
this.scene.validateAchv(achvs.HATCH_SHINY);
this.eggContainer.setVisible(false);
this.pokemonSprite.play(pokemon.getSpriteKey(true));
this.pokemonSprite.setVisible(true);
this.scene.time.delayedCall(Utils.fixedInt(1000), () => {
pokemon.cry();
this.scene.time.delayedCall(Utils.fixedInt(1250), () => {
if (isShiny) {
this.scene.time.delayedCall(Utils.fixedInt(1250), () => {
this.pokemonShinySparkle.play('sparkle');
this.scene.playSound('sparkle');
});
}
this.scene.time.delayedCall(Utils.fixedInt(!isShiny ? 1250 : 1750), () => {
this.scene.tweens.add({
targets: this.infoContainer,
duration: Utils.fixedInt(750),

View File

@ -197,22 +197,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.add(sprite);
this.add(tintSprite);
if (this.shiny) {
const shinySparkle = this.scene.add.sprite(0, 0, 'shiny');
shinySparkle.setVisible(false);
shinySparkle.setOrigin(0.5, 1);
const frameNames = this.scene.anims.generateFrameNames('shiny', { suffix: '.png', end: 34 });
this.scene.anims.create({
key: 'sparkle',
frames: frameNames,
frameRate: 32,
showOnStart: true,
hideOnComplete: true,
});
this.add(shinySparkle);
this.shinySparkle = shinySparkle;
}
if (this.isShiny() && !this.shinySparkle)
this.initShinySparkle();
}
isOnField(): boolean {
@ -388,6 +374,23 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
: this.maskSprite;
}
initShinySparkle(): void {
const shinySparkle = this.scene.add.sprite(0, 0, 'shiny');
shinySparkle.setVisible(false);
shinySparkle.setOrigin(0.5, 1);
const frameNames = this.scene.anims.generateFrameNames('shiny', { suffix: '.png', end: 34 });
this.scene.anims.create({
key: 'sparkle',
frames: frameNames,
frameRate: 32,
showOnStart: true,
hideOnComplete: true,
});
this.add(shinySparkle);
this.shinySparkle = shinySparkle;
}
playAnim(): void {
this.getSprite().play(this.getBattleSpriteKey());
this.getTintSprite().play(this.getBattleSpriteKey());
@ -729,6 +732,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if ((E ^ F) < 32)
console.log('REAL SHINY!!');
if (this.shiny)
this.initShinySparkle();
return this.shiny;
}

View File

@ -140,7 +140,7 @@ export default class Trainer extends Phaser.GameObjects.Container {
: this.genNewPartyMemberSpecies(level);
ret = new EnemyPokemon(this.scene, species, level, true);
}, this.config.hasStaticParty ? this.config.getDerivedType() + ((index + 1) << 8) : this.scene.currentBattle.waveIndex + (this.config.getDerivedType() << 10) + ((index + 1) << 8));
}, this.config.hasStaticParty ? this.config.getDerivedType() + ((index + 1) << 8) : this.scene.currentBattle.waveIndex + (this.config.getDerivedType() << 10) + (((!this.config.useSameSeedForAllMembers ? index : 0) + 1) << 8));
return ret;
}