fix(game): 修复底部塔面板不可见问题,改用React层实现,并用AI素材替换Graphics像素块

This commit is contained in:
Cloud Bot
2026-03-21 08:32:23 +00:00
parent 66b7776f32
commit 085aa0a407
14 changed files with 405 additions and 469 deletions

View File

@@ -10,37 +10,18 @@ export class InternTower extends TowerBase {
public onSelfDestroy?: (tower: InternTower) => void
constructor(scene: Phaser.Scene, gridX: number, gridY: number) {
super(scene, gridX, gridY, 50, 1, 15, 1.5)
this.drawSprite()
}
drawSprite(): void {
if (!this.sprite) return
this.sprite.clear()
// 绿色小人(圆头+十字身体)
this.sprite.fillStyle(0x22c55e, 1)
this.sprite.fillCircle(0, -12, 8)
// 身体
this.sprite.fillRect(-3, -4, 6, 14)
// 手臂
this.sprite.fillRect(-12, -2, 24, 4)
this.sprite.setPosition(this.px, this.py)
this.sprite.setDepth(10)
super(scene, gridX, gridY, 50, 1, 15, 1.5, 'tower-intern')
}
override update(delta: number, enemies: EnemyBase[]): void {
if (this.destroyed) return
super.update(delta, enemies)
// 被动每秒1%概率离场
this.selfDestroyTimer += delta
if (this.selfDestroyTimer >= this.SELF_DESTROY_INTERVAL) {
this.selfDestroyTimer -= this.SELF_DESTROY_INTERVAL
if (Math.random() < 0.01) {
// 退还 25 HC
GameManager.getInstance().addHC(25)
this.showMessage('实习生跑路!+25HC')
this.showMessage('实习生跑路!+25HC', '#22C55E')
this.destroyed = true
this.onSelfDestroy?.(this)
this.destroy()
@@ -50,42 +31,32 @@ export class InternTower extends TowerBase {
}
attack(target: EnemyBase): void {
// 整顿职场5% 概率秒杀 HP < 500 的怪物
if (Math.random() < 0.05 && target.hp < 500) {
target.takeDamage(9999)
this.showMessage('整顿职场!秒杀!')
this.showMessage('整顿职场!秒杀!', '#A3E635')
} else {
target.takeDamage(this.attackDamage)
}
// 近战效果(闪光)
this.showMeleeEffect(target)
}
private showMeleeEffect(target: EnemyBase): void {
const g = this.scene.add.graphics()
g.fillStyle(0x22c55e, 0.7)
g.fillCircle(target.sprite.x, target.sprite.y, 10)
g.fillStyle(0x22c55e, 0.6)
g.fillCircle(target.x, target.y, 12)
g.setDepth(15)
this.scene.time.delayedCall(150, () => g.destroy())
}
private showMessage(msg: string): void {
private showMessage(msg: string, color: string): void {
const txt = this.scene.add
.text(this.px, this.py - 30, msg, {
fontFamily: 'VT323, monospace',
fontSize: '14px',
color: '#22C55E',
backgroundColor: '#14532D',
padding: { x: 4, y: 2 },
})
.setOrigin(0.5, 1)
.setDepth(20)
fontFamily: 'VT323, monospace', fontSize: '14px',
color, backgroundColor: '#052e16', padding: { x: 4, y: 2 },
}).setOrigin(0.5, 1).setDepth(20)
this.scene.tweens.add({
targets: txt,
y: this.py - 55,
alpha: 0,
duration: 1200,
onComplete: () => txt.destroy(),
targets: txt, y: this.py - 55, alpha: 0,
duration: 1200, onComplete: () => txt.destroy(),
})
}
}