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,
time: 60000,
enemyTypes: [3] // Special enemies in wave 3
},
{
waveNumber: 4,
time: 80000,
enemyTypes: [4] // Special enemies in wave 3
}
];
}
@ -356,20 +361,6 @@ export class GameScene extends Phaser.Scene {
enemy.shootTimer.remove();
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
else if (this.currentWave >= 3 && texture === 3) {
@ -383,6 +374,20 @@ export class GameScene extends Phaser.Scene {
loop: true
});
}
}
// 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
});
}
}
}
@ -497,8 +502,17 @@ export class GameScene extends Phaser.Scene {
// Only shoot if enemy can shoot and isn't destroyed
if (!enemy.canShoot || !enemy.active) return;
// Check if this is wave 3 and enemy has texture 2 (special shooting)
if (this.currentWave >= 2 && enemy.waveNumber >= 2 && texture === 2) {
if (texture === 4) {
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
const angle = Phaser.Math.Angle.Between(
enemy.x,