41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type Phaser from 'phaser'
|
|
import { TowerBase } from './TowerBase'
|
|
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, 'tower-ppt')
|
|
}
|
|
|
|
attack(_target: EnemyBase): void {
|
|
// AOE 攻击由 TowerManager.updatePPTTower 直接调用 attackAoe
|
|
}
|
|
|
|
attackAoe(enemies: EnemyBase[]): void {
|
|
const rangePx = this.attackRange * this.cellW
|
|
this.showAoeEffect(rangePx)
|
|
for (const e of enemies) {
|
|
if (e.isDead) continue
|
|
const dx = e.x - this.px
|
|
const dy = e.y - this.py
|
|
if (Math.sqrt(dx * dx + dy * dy) <= rangePx) {
|
|
e.takeDamage(this.attackDamage)
|
|
e.addSlow(0.4, 2000)
|
|
}
|
|
}
|
|
}
|
|
|
|
private showAoeEffect(rangePx: number): void {
|
|
const g = this.scene.add.graphics()
|
|
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.15, scaleY: 1.15,
|
|
duration: 450, onComplete: () => g.destroy(),
|
|
})
|
|
}
|
|
}
|