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 eggCrackSprite: Phaser.GameObjects.Sprite;
private eggLightraysOverlay: Phaser.GameObjects.Sprite; private eggLightraysOverlay: Phaser.GameObjects.Sprite;
private pokemonSprite: Phaser.GameObjects.Sprite; private pokemonSprite: Phaser.GameObjects.Sprite;
private pokemonShinySparkle: Phaser.GameObjects.Sprite;
private infoContainer: Phaser.GameObjects.Container; private infoContainer: Phaser.GameObjects.Container;
private statsContainer: StatsContainer; private statsContainer: StatsContainer;
@ -80,6 +81,11 @@ export class EggHatchPhase extends BattlePhase {
this.eggHatchContainer.add((this.pokemonSprite = getPokemonSprite())); 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 = 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.setOrigin(0, 0);
this.eggHatchOverlay.setAlpha(0); this.eggHatchOverlay.setAlpha(0);
@ -173,18 +179,25 @@ export class EggHatchPhase extends BattlePhase {
ease: 'Cubic.easeIn' ease: 'Cubic.easeIn'
}); });
this.scene.time.delayedCall(Utils.fixedInt(1500), () => { this.scene.time.delayedCall(Utils.fixedInt(1500), () => {
const isShiny = pokemon.isShiny();
if (pokemon.species.mythical) if (pokemon.species.mythical)
this.scene.validateAchv(achvs.HATCH_MYTHICAL); this.scene.validateAchv(achvs.HATCH_MYTHICAL);
if (pokemon.species.legendary) if (pokemon.species.legendary)
this.scene.validateAchv(achvs.HATCH_LEGENDARY); this.scene.validateAchv(achvs.HATCH_LEGENDARY);
if (pokemon.isShiny()) if (isShiny)
this.scene.validateAchv(achvs.HATCH_SHINY); this.scene.validateAchv(achvs.HATCH_SHINY);
this.eggContainer.setVisible(false); this.eggContainer.setVisible(false);
this.pokemonSprite.play(pokemon.getSpriteKey(true)); this.pokemonSprite.play(pokemon.getSpriteKey(true));
this.pokemonSprite.setVisible(true); this.pokemonSprite.setVisible(true);
this.scene.time.delayedCall(Utils.fixedInt(1000), () => { this.scene.time.delayedCall(Utils.fixedInt(1000), () => {
pokemon.cry(); pokemon.cry();
if (isShiny) {
this.scene.time.delayedCall(Utils.fixedInt(1250), () => { 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({ this.scene.tweens.add({
targets: this.infoContainer, targets: this.infoContainer,
duration: Utils.fixedInt(750), duration: Utils.fixedInt(750),

View File

@ -197,22 +197,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.add(sprite); this.add(sprite);
this.add(tintSprite); this.add(tintSprite);
if (this.shiny) { if (this.isShiny() && !this.shinySparkle)
const shinySparkle = this.scene.add.sprite(0, 0, 'shiny'); this.initShinySparkle();
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;
}
} }
isOnField(): boolean { isOnField(): boolean {
@ -388,6 +374,23 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
: this.maskSprite; : 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 { playAnim(): void {
this.getSprite().play(this.getBattleSpriteKey()); this.getSprite().play(this.getBattleSpriteKey());
this.getTintSprite().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) if ((E ^ F) < 32)
console.log('REAL SHINY!!'); console.log('REAL SHINY!!');
if (this.shiny)
this.initShinySparkle();
return this.shiny; return this.shiny;
} }

View File

@ -140,7 +140,7 @@ export default class Trainer extends Phaser.GameObjects.Container {
: this.genNewPartyMemberSpecies(level); : this.genNewPartyMemberSpecies(level);
ret = new EnemyPokemon(this.scene, species, level, true); 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; return ret;
} }