commit 42d1b3e8c7a9f5b6e4d3c2a1b0f9e8d7c6b5a4f3

Author: AI Assistant <ai@user.com>
Date:   2024-01-01 12:00:00

Add wave 4 with new enemy type and enhance enemy shooting mechanics

- Added wave 4 configuration with special enemies (texture 4)
- Modified enemy shooting logic to handle all waves including wave 2
- Implemented fan-shaped bullet spread for texture 4 enemies
- Updated enemy behavior to support new shooting patterns across multiple waves
This commit is contained in:
Brian Fertig 2025-08-13 20:24:25 -06:00
parent 68a49a69bc
commit 39aa857524
1 changed files with 30 additions and 16 deletions

View File

@ -45,6 +45,11 @@ export class GameScene extends Phaser.Scene {
waveNumber: 3, waveNumber: 3,
time: 60000, time: 60000,
enemyTypes: [3] // Special enemies in wave 3 enemyTypes: [3] // Special enemies in wave 3
},
{
waveNumber: 4,
time: 80000,
enemyTypes: [4] // Special enemies in wave 3
} }
]; ];
} }
@ -357,20 +362,6 @@ export class GameScene extends Phaser.Scene {
enemy.shootTimer = null; enemy.shootTimer = null;
} }
} }
// Wave 2: Enemies that can shoot
else if (this.currentWave >= 1 && texture > 0 && texture <= 2) {
enemy.canShoot = true;
enemy.canMissle = false;
// Only set up shooting timer if it doesn't exist yet
if (!enemy.shootTimer) {
enemy.shootTimer = this.time.addEvent({
delay: Phaser.Math.Between(1000, 3000),
callback: () => this.enemyShoot(enemy, texture),
callbackScope: this,
loop: true
});
}
}
// Wave 3: Enemies with missles // Wave 3: Enemies with missles
else if (this.currentWave >= 3 && texture === 3) { else if (this.currentWave >= 3 && texture === 3) {
enemy.canMissle = true; enemy.canMissle = true;
@ -384,6 +375,20 @@ export class GameScene extends Phaser.Scene {
}); });
} }
} }
// Wave 2: Enemies that can shoot
else if (this.currentWave >= 1 && texture > 0 && texture <= 4) {
enemy.canShoot = true;
enemy.canMissle = false;
// Only set up shooting timer if it doesn't exist yet
if (!enemy.shootTimer) {
enemy.shootTimer = this.time.addEvent({
delay: Phaser.Math.Between(1000, 3000),
callback: () => this.enemyShoot(enemy, texture),
callbackScope: this,
loop: true
});
}
}
} }
hitEnemy(bullet, enemy) { hitEnemy(bullet, enemy) {
@ -497,8 +502,17 @@ export class GameScene extends Phaser.Scene {
// Only shoot if enemy can shoot and isn't destroyed // Only shoot if enemy can shoot and isn't destroyed
if (!enemy.canShoot || !enemy.active) return; if (!enemy.canShoot || !enemy.active) return;
// Check if this is wave 3 and enemy has texture 2 (special shooting) if (texture === 4) {
if (this.currentWave >= 2 && enemy.waveNumber >= 2 && texture === 2) { const fan = [1.3, 1.5, 1.7, 1.9];
fan.forEach((value) => {
const bullet = this.enemyBullets.create(enemy.x, enemy.y, 'enemyBullet');
const speed = 200;
bullet.setVelocityX(Math.cos(value) * speed);
bullet.setVelocityY(Math.sin(value) * speed);
bullet.setScale(1.5);
});
} else if (this.currentWave >= 2 && enemy.waveNumber >= 2 && texture === 2) {
// Shoot toward player // Shoot toward player
const angle = Phaser.Math.Angle.Between( const angle = Phaser.Math.Angle.Between(
enemy.x, enemy.x,