feat(game): 新增3个角色、修复实习生攻击特效、加速开发子弹、每波结束自动进入下一波

This commit is contained in:
Cloud Bot
2026-03-24 07:47:41 +00:00
parent 300f4c432f
commit c8b8c7109f
9 changed files with 392 additions and 66 deletions

View File

@@ -23,17 +23,20 @@ void MAP_ROWS; void GAME_HEIGHT; void GAME_WIDTH; void BAR_X; void BAR_Y; void B
/** 所有游戏精灵的 key → public path 映射 */
const SPRITE_ASSETS: Record<string, string> = {
'tower-intern': '/game-assets/tower-intern.png',
'tower-senior': '/game-assets/tower-senior.png',
'tower-ppt': '/game-assets/tower-ppt.png',
'tower-hrbp': '/game-assets/tower-hrbp.png',
'enemy-fresh': '/game-assets/enemy-fresh.png',
'enemy-old': '/game-assets/enemy-old.png',
'enemy-trouble': '/game-assets/enemy-trouble.png',
'enemy-boss': '/game-assets/enemy-boss.png',
'deco-coffee': '/game-assets/deco-coffee.png',
'deco-monitor': '/game-assets/deco-monitor.png',
'deco-desk': '/game-assets/deco-desk.png',
'tower-intern': '/game-assets/tower-intern.png',
'tower-senior': '/game-assets/tower-senior.png',
'tower-ppt': '/game-assets/tower-ppt.png',
'tower-hrbp': '/game-assets/tower-hrbp.png',
'tower-pm': '/game-assets/tower-pm.png',
'tower-ops': '/game-assets/tower-ops.png',
'tower-outsource': '/game-assets/tower-outsource.png',
'enemy-fresh': '/game-assets/enemy-fresh.png',
'enemy-old': '/game-assets/enemy-old.png',
'enemy-trouble': '/game-assets/enemy-trouble.png',
'enemy-boss': '/game-assets/enemy-boss.png',
'deco-coffee': '/game-assets/deco-coffee.png',
'deco-monitor': '/game-assets/deco-monitor.png',
'deco-desk': '/game-assets/deco-desk.png',
}
export function createGameScene(PhaserLib: typeof Phaser): typeof Phaser.Scene {
@@ -134,6 +137,8 @@ export function createGameScene(PhaserLib: typeof Phaser): typeof Phaser.Scene {
*/
private loadMap(mapConfig: MapConfig): void {
this.currentPathTiles = buildPathTiles(mapConfig.waypoints)
// 同步路径格给 TowerManager用于建塔合法性判断
this.towerManager.setCurrentPathTiles(this.currentPathTiles)
this.bgObject?.destroy()
this.bgObject = renderMapBackground(this, mapConfig.bgKey)
drawAllTiles(this.tileGraphics, null, this.currentPathTiles, mapConfig)
@@ -151,8 +156,13 @@ export function createGameScene(PhaserLib: typeof Phaser): typeof Phaser.Scene {
mapConfig.waypoints
)
this.mapInTransition = false
this.isWaveRunning = false
}
// 自动下一波倒计时ms-1 表示未激活
private autoNextWaveTimer: number = -1
private readonly AUTO_WAVE_DELAY = 3000 // 3 秒后自动开始
update(_time: number, delta: number): void {
if (this.manager.gameState !== 'playing' && this.manager.gameState !== 'idle') return
if (this.mapInTransition) return
@@ -160,19 +170,35 @@ export function createGameScene(PhaserLib: typeof Phaser): typeof Phaser.Scene {
this.towerManager.update(delta, this.waveManager.getAllActiveEnemies())
this.waveManager.update(delta)
// 当前波次怪物全灭且还有下一波时,启动自动倒计时
if (
this.isWaveRunning &&
this.waveManager.getAllActiveEnemies().length === 0 &&
this.waveManager.hasMoreWaves()
) {
this.isWaveRunning = false
this.hud.enableWaveButton()
this.hud.setWaveButtonText('▶ 召唤下一波')
if (this.autoNextWaveTimer < 0) {
this.autoNextWaveTimer = this.AUTO_WAVE_DELAY
this.hud.setWaveButtonText('3s 后自动开始...')
this.hud.enableWaveButton()
}
}
// 自动倒计时
if (this.autoNextWaveTimer > 0) {
this.autoNextWaveTimer -= delta
const sec = Math.ceil(this.autoNextWaveTimer / 1000)
this.hud.setWaveButtonText(`${sec}s 后自动开始...`)
if (this.autoNextWaveTimer <= 0) {
this.autoNextWaveTimer = -1
this.onWaveButtonClick()
}
}
}
private onWaveButtonClick(): void {
if (!this.waveManager.hasMoreWaves() || this.isWaveRunning || this.mapInTransition) return
this.autoNextWaveTimer = -1
this.isWaveRunning = true
this.hud.disableWaveButton()
this.hud.setWaveButtonText('波次进行中...')