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

@@ -8,39 +8,56 @@ export class SeniorDevTower extends TowerBase {
}
attack(target: EnemyBase): void {
this.fireBullet(target)
this.fireCodeBullet(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)
private fireCodeBullet(target: EnemyBase): void {
// 随机代码符号作为子弹
const symbols = ['</>', '{}', '=>', '??', '&&', '||', '++', '!=']
const sym = symbols[Math.floor(Math.random() * symbols.length)]
const bullet = this.scene.add.text(this.px, this.py, sym, {
fontFamily: 'monospace',
fontSize: '13px',
color: '#86efac',
stroke: '#14532d',
strokeThickness: 2,
}).setOrigin(0.5, 0.5).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
// 子弹速度 1200px/s比原来快 2.4 倍
const duration = (dist / 1200) * 1000
this.scene.tweens.add({
targets: bullet,
x: target.x, y: target.y,
x: target.x,
y: target.y,
duration,
ease: 'Linear',
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())
// DOT 命中:绿色代码粒子爆散
for (let i = 0; i < 4; i++) {
const p = this.scene.add.text(
target.x, target.y,
['bug', 'err', '!!!', '???'][i],
{ fontFamily: 'monospace', fontSize: '10px', color: '#22c55e' }
).setOrigin(0.5, 0.5).setDepth(15)
const angle = (i / 4) * Math.PI * 2
this.scene.tweens.add({
targets: p,
x: target.x + Math.cos(angle) * 22,
y: target.y + Math.sin(angle) * 22,
alpha: 0,
duration: 400,
onComplete: () => p.destroy(),
})
}
}
},
})