49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import type Phaser from 'phaser'
|
|
import { TowerBase } from './TowerBase'
|
|
import type { EnemyBase } from '../enemies/EnemyBase'
|
|
|
|
export class SeniorDevTower extends TowerBase {
|
|
constructor(scene: Phaser.Scene, gridX: number, gridY: number) {
|
|
super(scene, gridX, gridY, 120, 5, 30, 1.0, 'tower-senior')
|
|
}
|
|
|
|
attack(target: EnemyBase): void {
|
|
this.fireBullet(target)
|
|
}
|
|
|
|
private fireBullet(target: EnemyBase): void {
|
|
const bullet = this.scene.add.graphics()
|
|
bullet.fillStyle(0x22c55e, 1)
|
|
bullet.fillRoundedRect(-5, -5, 10, 10, 2)
|
|
// 添加绿色发光
|
|
bullet.lineStyle(1, 0x86efac, 0.8)
|
|
bullet.strokeRoundedRect(-6, -6, 12, 12, 3)
|
|
bullet.setPosition(this.px, this.py)
|
|
bullet.setDepth(13)
|
|
|
|
const dx = target.x - this.px
|
|
const dy = target.y - this.py
|
|
const dist = Math.sqrt(dx * dx + dy * dy)
|
|
const duration = (dist / 500) * 1000
|
|
|
|
this.scene.tweens.add({
|
|
targets: bullet,
|
|
x: target.x, y: target.y,
|
|
duration,
|
|
onComplete: () => {
|
|
bullet.destroy()
|
|
if (!target.isDead) {
|
|
target.takeDamage(this.attackDamage)
|
|
target.addDOT(10, 3000)
|
|
// DOT 命中效果
|
|
const fx = this.scene.add.graphics()
|
|
fx.lineStyle(2, 0x22c55e, 0.8)
|
|
fx.strokeCircle(target.x, target.y, 14)
|
|
fx.setDepth(15)
|
|
this.scene.time.delayedCall(300, () => fx.destroy())
|
|
}
|
|
},
|
|
})
|
|
}
|
|
}
|