Refine level up unit celebration animation
This commit is contained in:
@@ -1035,6 +1035,9 @@ type UnitView = {
|
|||||||
type UnitDirection = 'south' | 'east' | 'north' | 'west';
|
type UnitDirection = 'south' | 'east' | 'north' | 'west';
|
||||||
type UnitActionPose = 'attack' | 'strategy' | 'item' | 'hurt';
|
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 BattlePhase = 'idle' | 'moving' | 'command' | 'targeting' | 'animating' | 'resolved';
|
||||||
type BattleCommand = 'attack' | 'strategy' | 'item' | 'wait';
|
type BattleCommand = 'attack' | 'strategy' | 'item' | 'wait';
|
||||||
type DamageCommand = Exclude<BattleCommand, 'wait'>;
|
type DamageCommand = Exclude<BattleCommand, 'wait'>;
|
||||||
@@ -5156,7 +5159,7 @@ export class BattleScene extends Phaser.Scene {
|
|||||||
}));
|
}));
|
||||||
banner.setOrigin(0.5);
|
banner.setOrigin(0.5);
|
||||||
banner.setDepth(depth + 7);
|
banner.setDepth(depth + 7);
|
||||||
await this.playUnitCelebrationFrames(sprite);
|
await this.playUnitCelebrationFrames(sprite, animation.unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private createResultLevelUpBurst(x: number, y: number, depth: number) {
|
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 baseY = sprite.y;
|
||||||
|
const baseX = sprite.x;
|
||||||
const baseAngle = sprite.angle;
|
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<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
poses.forEach((pose, index) => {
|
poses.forEach((pose, index) => {
|
||||||
this.time.delayedCall(index * 110, () => {
|
this.time.delayedCall(index * 120, () => {
|
||||||
if (!sprite.active) {
|
if (!sprite.active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sprite.setFrame(this.unitActionFrameIndex('south', pose));
|
sprite.setFrame(this.unitActionFrameIndex('south', pose));
|
||||||
sprite.setY(baseY + (index % 2 === 0 ? -7 : 2));
|
sprite.setX(baseX + (index % 2 === 0 ? 0 : 1));
|
||||||
sprite.setAngle(baseAngle + (index % 2 === 0 ? -3 : 3));
|
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) {
|
if (sprite.active) {
|
||||||
|
sprite.setX(baseX);
|
||||||
sprite.setY(baseY);
|
sprite.setY(baseY);
|
||||||
sprite.setAngle(baseAngle);
|
sprite.setAngle(baseAngle);
|
||||||
sprite.setFrame(this.unitActionFrameIndex('south', 'item'));
|
sprite.setFrame(this.unitActionFrameIndex('south', preferredPose));
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
@@ -7149,8 +7156,8 @@ export class BattleScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (celebration) {
|
if (celebration && config.celebrant) {
|
||||||
await this.playGrowthCelebration(celebration);
|
await this.playGrowthCelebration(celebration, config.celebrant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7276,8 +7283,8 @@ export class BattleScene extends Phaser.Scene {
|
|||||||
return 'item';
|
return 'item';
|
||||||
}
|
}
|
||||||
|
|
||||||
private playGrowthCelebration(sprite: Phaser.GameObjects.Sprite) {
|
private playGrowthCelebration(sprite: Phaser.GameObjects.Sprite, unit: UnitData) {
|
||||||
return this.playUnitCelebrationFrames(sprite);
|
return this.playUnitCelebrationFrames(sprite, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private combatPortraitKey(unit: UnitData) {
|
private combatPortraitKey(unit: UnitData) {
|
||||||
|
|||||||
Reference in New Issue
Block a user