fix(game): 修复输了能进下一关的Bug、换关后塔残留、召唤按钮太小、战斗前不能发激励
This commit is contained in:
@@ -365,8 +365,11 @@ export function createGameScene(PhaserLib: typeof Phaser): typeof Phaser.Scene {
|
||||
this.waveManager.startNextWave()
|
||||
const waveNum = this.waveManager.getCurrentWaveNumber()
|
||||
this.hud.showWaveBanner(waveNum, this.waveManager.totalWaves)
|
||||
// 波次开始音效
|
||||
AudioEngine.getInstance().playWaveStart()
|
||||
// 通知 React 层:战斗已开始,允许发起激励
|
||||
if (typeof window !== 'undefined') {
|
||||
;(window as any).__gameWaveStarted = true
|
||||
}
|
||||
}
|
||||
|
||||
private onWeeklyReport(): void {
|
||||
@@ -375,7 +378,11 @@ export function createGameScene(PhaserLib: typeof Phaser): typeof Phaser.Scene {
|
||||
}
|
||||
|
||||
private onMapCleared(): void {
|
||||
// 若游戏已失败,不触发地图切换
|
||||
if (this.manager.gameState === 'defeat') return
|
||||
|
||||
this.mapInTransition = true
|
||||
this.autoNextWaveTimer = -1
|
||||
this.isWaveRunning = false
|
||||
this.hud.disableWaveButton()
|
||||
this.hud.setWaveButtonText('关卡完成!')
|
||||
@@ -390,6 +397,8 @@ export function createGameScene(PhaserLib: typeof Phaser): typeof Phaser.Scene {
|
||||
this.manager.totalWaveCleared += currentMap.waveCount
|
||||
this.manager.currentMapIndex = nextIndex
|
||||
this.waveManager.clearAllEnemies()
|
||||
// 清除上一关所有防御塔
|
||||
this.towerManager.clearAllTowers()
|
||||
this.loadMap(ALL_MAPS[nextIndex])
|
||||
this.hud.enableWaveButton()
|
||||
this.hud.setWaveButtonText('▶ 召唤下一波')
|
||||
|
||||
@@ -258,6 +258,17 @@ export class TowerManager {
|
||||
return this.towers
|
||||
}
|
||||
|
||||
/** 切换地图时清除所有防御塔(静默销毁,不播放音效) */
|
||||
clearAllTowers(): void {
|
||||
for (const tower of this.towers) {
|
||||
tower.destroy()
|
||||
}
|
||||
this.towers = []
|
||||
this.occupiedCells.clear()
|
||||
this.infoLabel?.destroy()
|
||||
this.infoLabel = null
|
||||
}
|
||||
|
||||
hasTowerAt(gridX: number, gridY: number): boolean {
|
||||
return this.occupiedCells.has(`${gridX},${gridY}`)
|
||||
}
|
||||
|
||||
@@ -23,25 +23,27 @@ export class HUD {
|
||||
*/
|
||||
createWaveButton(onClick: () => void): void {
|
||||
if (this.waveBtn) this.waveBtn.destroy()
|
||||
this._onClick = onClick // 保存引用,供 enableWaveButton 重新绑定
|
||||
this._onClick = onClick
|
||||
|
||||
this.waveBtn = this.scene.add
|
||||
.text(GAME_WIDTH - 160, HUD_HEIGHT + 20, '▶ 召唤下一波', {
|
||||
fontFamily: "'Press Start 2P', monospace",
|
||||
fontSize: '9px',
|
||||
.text(GAME_WIDTH / 2, HUD_HEIGHT + 16, '▶ 召唤下一波', {
|
||||
fontFamily: 'VT323, monospace',
|
||||
fontSize: '26px',
|
||||
color: '#A78BFA',
|
||||
backgroundColor: '#1e3a5f',
|
||||
padding: { x: 10, y: 6 },
|
||||
padding: { x: 20, y: 8 },
|
||||
stroke: '#7C3AED',
|
||||
strokeThickness: 1,
|
||||
})
|
||||
.setOrigin(0, 0)
|
||||
.setOrigin(0.5, 0)
|
||||
.setDepth(20)
|
||||
.setInteractive({ useHandCursor: true })
|
||||
|
||||
this.waveBtn.on('pointerover', () => {
|
||||
if (this.waveBtn) this.waveBtn.setStyle({ backgroundColor: '#2d5a8e' })
|
||||
if (this.waveBtn) this.waveBtn.setStyle({ backgroundColor: '#2d5a8e', color: '#C4B5FD' })
|
||||
})
|
||||
this.waveBtn.on('pointerout', () => {
|
||||
if (this.waveBtn) this.waveBtn.setStyle({ backgroundColor: '#1e3a5f' })
|
||||
if (this.waveBtn) this.waveBtn.setStyle({ backgroundColor: '#1e3a5f', color: '#A78BFA' })
|
||||
})
|
||||
this.waveBtn.on('pointerdown', () => onClick())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user