diff --git a/src/game/scenes/BattleScene.ts b/src/game/scenes/BattleScene.ts index 9a4c282..082f527 100644 --- a/src/game/scenes/BattleScene.ts +++ b/src/game/scenes/BattleScene.ts @@ -1035,6 +1035,9 @@ type UnitView = { type UnitDirection = 'south' | 'east' | 'north' | 'west'; type UnitActionPose = 'attack' | 'strategy' | 'item' | 'hurt'; +const levelUpCelebrationPoseSequence: UnitActionPose[] = ['strategy', 'item', 'attack', 'strategy', 'item', 'attack', 'strategy']; +const levelUpCelebrationStepOffsets = [0, -4, 0, -6, -2, 0, -3]; + type BattlePhase = 'idle' | 'moving' | 'command' | 'targeting' | 'animating' | 'resolved'; type BattleCommand = 'attack' | 'strategy' | 'item' | 'wait'; type DamageCommand = Exclude; @@ -5156,7 +5159,7 @@ export class BattleScene extends Phaser.Scene { })); banner.setOrigin(0.5); banner.setDepth(depth + 7); - await this.playUnitCelebrationFrames(sprite); + await this.playUnitCelebrationFrames(sprite, animation.unit); } private createResultLevelUpBurst(x: number, y: number, depth: number) { @@ -5182,26 +5185,30 @@ export class BattleScene extends Phaser.Scene { }); } - private playUnitCelebrationFrames(sprite: Phaser.GameObjects.Sprite) { + private playUnitCelebrationFrames(sprite: Phaser.GameObjects.Sprite, unit: UnitData) { const baseY = sprite.y; + const baseX = sprite.x; const baseAngle = sprite.angle; - const poses: UnitActionPose[] = ['item', 'attack', 'strategy', 'attack', 'item', 'attack']; + const preferredPose = this.celebrationPose(unit); + const poses = [preferredPose, ...levelUpCelebrationPoseSequence]; return new Promise((resolve) => { poses.forEach((pose, index) => { - this.time.delayedCall(index * 110, () => { + this.time.delayedCall(index * 120, () => { if (!sprite.active) { return; } sprite.setFrame(this.unitActionFrameIndex('south', pose)); - sprite.setY(baseY + (index % 2 === 0 ? -7 : 2)); - sprite.setAngle(baseAngle + (index % 2 === 0 ? -3 : 3)); + sprite.setX(baseX + (index % 2 === 0 ? 0 : 1)); + sprite.setY(baseY + levelUpCelebrationStepOffsets[index % levelUpCelebrationStepOffsets.length]); + sprite.setAngle(baseAngle); }); }); - this.time.delayedCall(poses.length * 110 + 80, () => { + this.time.delayedCall(poses.length * 120 + 90, () => { if (sprite.active) { + sprite.setX(baseX); sprite.setY(baseY); sprite.setAngle(baseAngle); - sprite.setFrame(this.unitActionFrameIndex('south', 'item')); + sprite.setFrame(this.unitActionFrameIndex('south', preferredPose)); } resolve(); }); @@ -7149,8 +7156,8 @@ export class BattleScene extends Phaser.Scene { } } - if (celebration) { - await this.playGrowthCelebration(celebration); + if (celebration && config.celebrant) { + await this.playGrowthCelebration(celebration, config.celebrant); } } @@ -7276,8 +7283,8 @@ export class BattleScene extends Phaser.Scene { return 'item'; } - private playGrowthCelebration(sprite: Phaser.GameObjects.Sprite) { - return this.playUnitCelebrationFrames(sprite); + private playGrowthCelebration(sprite: Phaser.GameObjects.Sprite, unit: UnitData) { + return this.playUnitCelebrationFrames(sprite, unit); } private combatPortraitKey(unit: UnitData) {