|
|
@@ -250,6 +250,12 @@ export class EnemyController extends BaseSingleton {
|
|
|
|
|
|
// 游戏开始
|
|
|
startGame() {
|
|
|
+ // 检查游戏是否已经结束,如果结束则不开始生成敌人
|
|
|
+ if (this.gameManager && typeof this.gameManager.isGameOver === 'function' && this.gameManager.isGameOver()) {
|
|
|
+ console.log('[EnemyController] 游戏已经结束,不启动敌人生成');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
this.gameStarted = true;
|
|
|
|
|
|
// 确保enemyContainer节点存在
|
|
|
@@ -282,6 +288,13 @@ export class EnemyController extends BaseSingleton {
|
|
|
spawnEnemy() {
|
|
|
if (!this.gameStarted || !this.enemyPrefab) return;
|
|
|
|
|
|
+ // 检查游戏是否已经结束,如果结束则不生成敌人
|
|
|
+ if (this.gameManager && typeof this.gameManager.isGameOver === 'function' && this.gameManager.isGameOver()) {
|
|
|
+ console.log('[EnemyController] 游戏已经结束,不再生成敌人');
|
|
|
+ this.unschedule(this.spawnEnemy); // 取消定时生成
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 随机决定从上方还是下方生成
|
|
|
const fromTop = Math.random() > 0.5;
|
|
|
|
|
|
@@ -444,6 +457,12 @@ export class EnemyController extends BaseSingleton {
|
|
|
|
|
|
// 恢复生成敌人
|
|
|
public resumeSpawning(): void {
|
|
|
+ // 检查游戏是否已经结束,如果结束则不恢复生成敌人
|
|
|
+ if (this.gameManager && typeof this.gameManager.isGameOver === 'function' && this.gameManager.isGameOver()) {
|
|
|
+ console.log('[EnemyController] 游戏已经结束,不恢复敌人生成');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (this.gameStarted) {
|
|
|
this.schedule(this.spawnEnemy, this.spawnInterval);
|
|
|
}
|
|
|
@@ -673,6 +692,12 @@ export class EnemyController extends BaseSingleton {
|
|
|
|
|
|
/** 显示每波开始提示,随后开启敌人生成 */
|
|
|
public showStartWavePromptUI(duration: number = 2) {
|
|
|
+ // 检查游戏是否已经结束,如果结束则不显示波次提示
|
|
|
+ if (this.gameManager && typeof this.gameManager.isGameOver === 'function' && this.gameManager.isGameOver()) {
|
|
|
+ console.log('[EnemyController] 游戏已经结束,不显示波次提示');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (!this.startWaveUI) return;
|
|
|
this.startWaveUI.active = true;
|
|
|
// 暂停生成(确保未重复)
|
|
|
@@ -680,6 +705,13 @@ export class EnemyController extends BaseSingleton {
|
|
|
if (duration > 0) {
|
|
|
this.scheduleOnce(() => {
|
|
|
if (this.startWaveUI) this.startWaveUI.active = false;
|
|
|
+
|
|
|
+ // 再次检查游戏是否已经结束,如果结束则不开始生成敌人
|
|
|
+ if (this.gameManager && typeof this.gameManager.isGameOver === 'function' && this.gameManager.isGameOver()) {
|
|
|
+ console.log('[EnemyController] 游戏已经结束,不启动敌人生成(延时检查)');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 真正开始/恢复生成敌人
|
|
|
this.startGame();
|
|
|
}, duration);
|