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

@@ -4,57 +4,37 @@ import type { EnemyBase } from '../enemies/EnemyBase'
export class PPTMasterTower extends TowerBase {
constructor(scene: Phaser.Scene, gridX: number, gridY: number) {
super(scene, gridX, gridY, 100, 3, 5, 1.5)
this.drawSprite()
super(scene, gridX, gridY, 100, 3, 5, 1.5, 'tower-ppt')
}
drawSprite(): void {
if (!this.sprite) return
this.sprite.clear()
// 橙色圆形
this.sprite.fillStyle(0xf59e0b, 1)
this.sprite.fillCircle(0, 0, 16)
// 圆心白点
this.sprite.fillStyle(0xffffff, 0.9)
this.sprite.fillCircle(0, 0, 5)
this.sprite.setPosition(this.px, this.py)
this.sprite.setDepth(10)
attack(_target: EnemyBase): void {
// AOE 攻击由 TowerManager.updatePPTTower 直接调用 attackAoe
}
attack(target: EnemyBase): void {
// AOE 攻击:对射程内所有怪物造成伤害 + 减速
this.showAoeEffect()
}
/** 该方法由 TowerManager 调用,传入全体敌人 */
attackAoe(enemies: EnemyBase[]): void {
const rangePx = this.attackRange * 80 // TILE_SIZE
this.showAoeEffect()
const rangePx = this.attackRange * this.cellW
this.showAoeEffect(rangePx)
for (const e of enemies) {
if (e.isDead) continue
const dx = e.sprite.x - this.px
const dy = e.sprite.y - this.py
const dist = Math.sqrt(dx * dx + dy * dy)
if (dist <= rangePx) {
const dx = e.x - this.px
const dy = e.y - this.py
if (Math.sqrt(dx * dx + dy * dy) <= rangePx) {
e.takeDamage(this.attackDamage)
// 黑话领域减速40%持续2秒
e.addSlow(0.4, 2000)
}
}
}
private showAoeEffect(): void {
private showAoeEffect(rangePx: number): void {
const g = this.scene.add.graphics()
g.lineStyle(2, 0xf59e0b, 0.8)
g.strokeCircle(this.px, this.py, this.attackRange * 80)
g.setDepth(12)
g.lineStyle(2, 0xf59e0b, 0.7)
g.strokeCircle(this.px, this.py, rangePx)
g.fillStyle(0xf59e0b, 0.07)
g.fillCircle(this.px, this.py, rangePx)
g.setDepth(8)
this.scene.tweens.add({
targets: g,
alpha: 0,
scaleX: 1.2,
scaleY: 1.2,
duration: 400,
onComplete: () => g.destroy(),
targets: g, alpha: 0, scaleX: 1.15, scaleY: 1.15,
duration: 450, onComplete: () => g.destroy(),
})
}
}