Files
test1/game/enemies/TroubleMaker.ts

54 lines
1.5 KiB
TypeScript

import type Phaser from 'phaser'
import { EnemyBase, type PathPoint } from './EnemyBase'
import { GameManager } from '../GameManager'
import { getRandomQuote } from '../data/quotes'
export class TroubleMaker extends EnemyBase {
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
super(scene, pathPoints, 80, 80, 5, 20)
this.drawSprite()
}
drawSprite(): void {
if (!this.sprite) return
this.sprite.clear()
// 三角形(叹号形状)
this.sprite.fillStyle(0xfca5a5, 1)
this.sprite.fillTriangle(0, -14, -12, 10, 12, 10)
// 叹号
this.sprite.fillStyle(0x7f1d1d, 1)
this.sprite.fillRect(-2, -6, 4, 8)
this.sprite.fillRect(-2, 6, 4, 4)
this.sprite.setDepth(10)
this.sprite.setPosition(this.x, this.y)
}
protected override onDeath(): void {
// 劳动仲裁:死亡时扣玩家 20 HC
const manager = GameManager.getInstance()
manager.spendHC(20)
// 显示提示文字
const txt = this.scene.add
.text(this.x, this.y - 20, '劳动仲裁! -20HC', {
fontFamily: 'VT323, monospace',
fontSize: '16px',
color: '#FCA5A5',
backgroundColor: '#7F1D1D',
padding: { x: 4, y: 2 },
})
.setOrigin(0.5, 1)
.setDepth(25)
this.scene.tweens.add({
targets: txt,
y: this.y - 50,
alpha: 0,
duration: 1500,
onComplete: () => txt.destroy(),
})
}
getQuote(): string {
return getRandomQuote('TroubleMaker')
}
}