Consume processed pirate shots reliably
This commit is contained in:
parent
07114e85dc
commit
c7188e4f8f
@ -79,8 +79,6 @@ class GameScene extends Phaser.Scene {
|
||||
|
||||
this.player = this.physics.add.sprite(1200, 1550, 'airships', 0);
|
||||
this.player.setDepth(6).setCollideWorldBounds(true).setDisplaySize(74, 74);
|
||||
this.playerBaseScaleX = this.player.scaleX;
|
||||
this.playerBaseScaleY = this.player.scaleY;
|
||||
this.player.body.setAllowGravity(false);
|
||||
this.player.body.setSize(42, 56, true);
|
||||
this.player.play('player-idle');
|
||||
@ -537,6 +535,7 @@ class GameScene extends Phaser.Scene {
|
||||
shot.body.setAllowGravity(false);
|
||||
shot.setData('bornAt', this.time.now);
|
||||
shot.setData('damage', damage);
|
||||
if (group === this.pirateShots) shot.setData('playerHitQueued', false);
|
||||
shot.setVelocity(
|
||||
Math.cos(angle) * SHOT_SPEED * velocityScale + ship.body.velocity.x * 0.25,
|
||||
Math.sin(angle) * SHOT_SPEED * velocityScale + ship.body.velocity.y * 0.25,
|
||||
@ -631,6 +630,10 @@ class GameScene extends Phaser.Scene {
|
||||
this.playerHull = result.hull;
|
||||
const { totalDamage, appliedHits, gameOver } = result;
|
||||
|
||||
for (const impact of hits) {
|
||||
if (impact.shot?.active) impact.shot.destroy();
|
||||
}
|
||||
|
||||
if (appliedHits > 0) {
|
||||
try {
|
||||
for (const impact of hits) {
|
||||
@ -689,20 +692,18 @@ class GameScene extends Phaser.Scene {
|
||||
if (!this.player?.active) return;
|
||||
|
||||
this.tweens.killTweensOf(this.player);
|
||||
this.player.setScale(this.playerBaseScaleX, this.playerBaseScaleY);
|
||||
this.player.setAlpha(1);
|
||||
this.player.setTint(0xffd7d7);
|
||||
|
||||
this.tweens.add({
|
||||
targets: this.player,
|
||||
scaleX: this.playerBaseScaleX * 1.12,
|
||||
scaleY: this.playerBaseScaleY * 1.12,
|
||||
alpha: 0.62,
|
||||
duration: 70,
|
||||
alpha: 0.45,
|
||||
duration: 65,
|
||||
yoyo: true,
|
||||
repeat: 1,
|
||||
ease: 'Quad.easeOut',
|
||||
onComplete: () => {
|
||||
if (!this.player?.active) return;
|
||||
this.player.setScale(this.playerBaseScaleX, this.playerBaseScaleY);
|
||||
this.player.setAlpha(1);
|
||||
this.player.clearTint();
|
||||
},
|
||||
|
||||
@ -208,8 +208,19 @@ test('processed player hits drive sprite and HUD hit reactions', async () => {
|
||||
|
||||
assert.match(game, /this\.playerHitSequence \+= 1/);
|
||||
assert.match(game, /playPlayerHitReaction\(damage = PIRATE_SHOT_DAMAGE\)/);
|
||||
assert.match(game, /scaleX: this\.playerBaseScaleX \* 1\.12/);
|
||||
assert.match(game, /alpha: 0\.45/);
|
||||
assert.match(game, /repeat: 1/);
|
||||
assert.match(game, /this\.cameras\.main\.shake\(120/);
|
||||
assert.doesNotMatch(game, /scaleX: this\.playerBaseScaleX/);
|
||||
assert.match(hud, /steam-player-card\.steam-hit/);
|
||||
assert.match(hud, /pulsePlayerHit\(state\.player\.hitSequence \?\? 0\)/);
|
||||
});
|
||||
|
||||
|
||||
test('processed pirate shots are consumed and later projectiles start clean', async () => {
|
||||
const source = await read('src/game-v4.js');
|
||||
|
||||
assert.match(source, /if \(group === this\.pirateShots\) shot\.setData\('playerHitQueued', false\)/);
|
||||
assert.match(source, /for \(const impact of hits\) \{[\s\S]*?if \(impact\.shot\?\.active\) impact\.shot\.destroy\(\)/);
|
||||
assert.match(source, /if \(shot\.getData\('playerHitQueued'\)\) return/);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user