feat(game/enemies): 完善怪物头顶语录飘字系统,集成语录数据文件,添加跟随移动和淡出动画
This commit is contained in:
@@ -1,11 +1,6 @@
|
|||||||
import type Phaser from 'phaser'
|
import type Phaser from 'phaser'
|
||||||
import { EnemyBase, type PathPoint } from './EnemyBase'
|
import { EnemyBase, type PathPoint } from './EnemyBase'
|
||||||
|
import { getRandomQuote } from '../data/quotes'
|
||||||
const QUOTES = [
|
|
||||||
'我来教大家怎么做事',
|
|
||||||
'你们缺乏战略眼光',
|
|
||||||
'这不是执行力的问题',
|
|
||||||
]
|
|
||||||
|
|
||||||
export class BossVP extends EnemyBase {
|
export class BossVP extends EnemyBase {
|
||||||
private skillTimer: number = 20000
|
private skillTimer: number = 20000
|
||||||
@@ -108,6 +103,6 @@ export class BossVP extends EnemyBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getQuote(): string {
|
getQuote(): string {
|
||||||
return QUOTES[Math.floor(Math.random() * QUOTES.length)]
|
return getRandomQuote('BossVP')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,10 @@ export abstract class EnemyBase {
|
|||||||
this.moveAlongPath(delta)
|
this.moveAlongPath(delta)
|
||||||
this.drawHealthBar()
|
this.drawHealthBar()
|
||||||
this.sprite.setPosition(this.x, this.y)
|
this.sprite.setPosition(this.x, this.y)
|
||||||
|
// 语录文字跟随怪物移动
|
||||||
|
if (this.quoteText && this.quoteText.alpha > 0) {
|
||||||
|
this.quoteText.setPosition(this.x, this.y - 30)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected processDOT(delta: number): void {
|
protected processDOT(delta: number): void {
|
||||||
@@ -229,12 +233,19 @@ export abstract class EnemyBase {
|
|||||||
|
|
||||||
protected onDeath(): void {}
|
protected onDeath(): void {}
|
||||||
|
|
||||||
/** 显示头顶语录(短暂) */
|
/** 显示头顶语录(出生后随机触发,3秒后淡出) */
|
||||||
showQuote(): void {
|
showQuote(): void {
|
||||||
|
if (this.isDead || !this.quoteText) return
|
||||||
this.quoteText.setText(this.getQuote())
|
this.quoteText.setText(this.getQuote())
|
||||||
|
this.quoteText.setPosition(this.x, this.y - 30)
|
||||||
this.quoteText.setAlpha(1)
|
this.quoteText.setAlpha(1)
|
||||||
this.scene.time.delayedCall(1500, () => {
|
// 3秒后淡出动画
|
||||||
if (this.quoteText) this.quoteText.setAlpha(0)
|
this.scene.tweens.add({
|
||||||
|
targets: this.quoteText,
|
||||||
|
alpha: 0,
|
||||||
|
duration: 800,
|
||||||
|
delay: 2200,
|
||||||
|
ease: 'Linear',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type Phaser from 'phaser'
|
import type Phaser from 'phaser'
|
||||||
import { EnemyBase, type PathPoint } from './EnemyBase'
|
import { EnemyBase, type PathPoint } from './EnemyBase'
|
||||||
|
import { getRandomQuote } from '../data/quotes'
|
||||||
const QUOTES = ['求转正!', '我愿意加班!', '卷!卷!卷!']
|
|
||||||
|
|
||||||
export class FreshGraduate extends EnemyBase {
|
export class FreshGraduate extends EnemyBase {
|
||||||
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
|
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
|
||||||
@@ -19,6 +18,6 @@ export class FreshGraduate extends EnemyBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getQuote(): string {
|
getQuote(): string {
|
||||||
return QUOTES[Math.floor(Math.random() * QUOTES.length)]
|
return getRandomQuote('FreshGraduate')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type Phaser from 'phaser'
|
import type Phaser from 'phaser'
|
||||||
import { EnemyBase, type PathPoint } from './EnemyBase'
|
import { EnemyBase, type PathPoint } from './EnemyBase'
|
||||||
|
import { getRandomQuote } from '../data/quotes'
|
||||||
const QUOTES = ['我为公司立过功!', '我有10年经验!', '年龄不是问题!']
|
|
||||||
|
|
||||||
export class OldEmployee extends EnemyBase {
|
export class OldEmployee extends EnemyBase {
|
||||||
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
|
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
|
||||||
@@ -34,6 +33,6 @@ export class OldEmployee extends EnemyBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getQuote(): string {
|
getQuote(): string {
|
||||||
return QUOTES[Math.floor(Math.random() * QUOTES.length)]
|
return getRandomQuote('OldEmployee')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import type Phaser from 'phaser'
|
import type Phaser from 'phaser'
|
||||||
import { EnemyBase, type PathPoint } from './EnemyBase'
|
import { EnemyBase, type PathPoint } from './EnemyBase'
|
||||||
import { GameManager } from '../GameManager'
|
import { GameManager } from '../GameManager'
|
||||||
|
import { getRandomQuote } from '../data/quotes'
|
||||||
const QUOTES = ['录音笔已开启', '这是违法的!', '我要仲裁!']
|
|
||||||
|
|
||||||
export class TroubleMaker extends EnemyBase {
|
export class TroubleMaker extends EnemyBase {
|
||||||
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
|
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
|
||||||
@@ -49,6 +48,6 @@ export class TroubleMaker extends EnemyBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getQuote(): string {
|
getQuote(): string {
|
||||||
return QUOTES[Math.floor(Math.random() * QUOTES.length)]
|
return getRandomQuote('TroubleMaker')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user