Files
test1/game/enemies/OldEmployee.ts

40 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type Phaser from 'phaser'
import { EnemyBase, type PathPoint } from './EnemyBase'
const QUOTES = ['我为公司立过功!', '我有10年经验', '年龄不是问题!']
export class OldEmployee extends EnemyBase {
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
super(scene, pathPoints, 150, 50, 8, 30)
this.shieldCount = 3
this.drawSprite()
}
drawSprite(): void {
if (!this.sprite) return
this.sprite.clear()
// 大蓝方块
this.sprite.fillStyle(0x93c5fd, 1)
this.sprite.fillRect(-10, -10, 20, 20)
// 护盾外框(金色)
this.sprite.lineStyle(2, 0xfbbf24, 0.8)
this.sprite.strokeRect(-12, -12, 24, 24)
this.sprite.setDepth(10)
this.sprite.setPosition(this.x, this.y)
}
override drawHealthBar(): void {
super.drawHealthBar()
// 绘制护盾数量标记
if (!this.healthBar) return
for (let i = 0; i < this.shieldCount; i++) {
this.healthBar.fillStyle(0xfbbf24, 1)
this.healthBar.fillRect(this.x - 15 + i * 11, this.y - 28, 8, 4)
}
}
getQuote(): string {
return QUOTES[Math.floor(Math.random() * QUOTES.length)]
}
}