feat(game/ui): 升级胜利/失败结算界面,胜利弹窗显示绩效等级评定,失败弹窗仿钉钉风格
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import type Phaser from 'phaser'
|
||||
import { GAME_WIDTH, HUD_HEIGHT } from '../constants'
|
||||
import { GameManager } from '../GameManager'
|
||||
import { showVictoryModal, showDefeatModal } from './EndScreenModal'
|
||||
|
||||
/**
|
||||
* 游戏 HUD 辅助工具
|
||||
* 负责管理"召唤下一波"按钮和波次提示横幅
|
||||
* 负责管理"召唤下一波"按钮、波次提示横幅、胜利/失败结算弹窗
|
||||
*/
|
||||
export class HUD {
|
||||
private scene: Phaser.Scene
|
||||
@@ -34,18 +36,12 @@ export class HUD {
|
||||
.setInteractive({ useHandCursor: true })
|
||||
|
||||
this.waveBtn.on('pointerover', () => {
|
||||
if (this.waveBtn) {
|
||||
this.waveBtn.setStyle({ backgroundColor: '#2d5a8e' })
|
||||
}
|
||||
if (this.waveBtn) this.waveBtn.setStyle({ backgroundColor: '#2d5a8e' })
|
||||
})
|
||||
this.waveBtn.on('pointerout', () => {
|
||||
if (this.waveBtn) {
|
||||
this.waveBtn.setStyle({ backgroundColor: '#1e3a5f' })
|
||||
}
|
||||
})
|
||||
this.waveBtn.on('pointerdown', () => {
|
||||
onClick()
|
||||
if (this.waveBtn) this.waveBtn.setStyle({ backgroundColor: '#1e3a5f' })
|
||||
})
|
||||
this.waveBtn.on('pointerdown', () => onClick())
|
||||
}
|
||||
|
||||
/** 更新按钮文字(如禁用状态) */
|
||||
@@ -67,6 +63,7 @@ export class HUD {
|
||||
/**
|
||||
* 显示波次开始横幅
|
||||
* @param waveNumber 当前波次(1-based)
|
||||
* @param totalWaves 总波次数
|
||||
*/
|
||||
showWaveBanner(waveNumber: number, totalWaves: number): void {
|
||||
const isBoss = waveNumber === totalWaves
|
||||
@@ -98,10 +95,10 @@ export class HUD {
|
||||
})
|
||||
}
|
||||
|
||||
/** 显示周报触发提示 */
|
||||
/** 显示周报触发提示横幅 */
|
||||
showWeeklyReportAlert(): void {
|
||||
const banner = this.scene.add
|
||||
.text(GAME_WIDTH / 2, HUD_HEIGHT + 120, '📋 季度周报截止!效率翻倍!', {
|
||||
.text(GAME_WIDTH / 2, HUD_HEIGHT + 120, '周报时间到!请选择正确黑话!', {
|
||||
fontFamily: "'Press Start 2P', monospace",
|
||||
fontSize: '11px',
|
||||
color: '#FCD34D',
|
||||
@@ -122,51 +119,40 @@ export class HUD {
|
||||
})
|
||||
}
|
||||
|
||||
/** 显示胜利画面 */
|
||||
/** 显示胜利画面(完整绩效评级弹窗,委托给 EndScreenModal) */
|
||||
showVictory(): void {
|
||||
const overlay = this.scene.add.graphics()
|
||||
overlay.fillStyle(0x000000, 0.6)
|
||||
overlay.fillRect(0, 0, GAME_WIDTH, 720)
|
||||
overlay.setDepth(50)
|
||||
const manager = GameManager.getInstance()
|
||||
const kpi = manager.kpi
|
||||
const hc = manager.hc
|
||||
|
||||
this.scene.add
|
||||
.text(GAME_WIDTH / 2, 300, '🎉 大厂保卫成功!', {
|
||||
fontFamily: "'Press Start 2P', monospace",
|
||||
fontSize: '22px',
|
||||
color: '#A78BFA',
|
||||
backgroundColor: '#0A1628',
|
||||
padding: { x: 24, y: 12 },
|
||||
})
|
||||
.setOrigin(0.5, 0.5)
|
||||
.setDepth(55)
|
||||
let grade: string
|
||||
let gradeColor: string
|
||||
let gradeDesc: string
|
||||
|
||||
this.scene.add
|
||||
.text(GAME_WIDTH / 2, 380, 'KPI 绩效已发放!', {
|
||||
fontFamily: 'VT323, monospace',
|
||||
fontSize: '24px',
|
||||
color: '#A78BFA',
|
||||
})
|
||||
.setOrigin(0.5, 0.5)
|
||||
.setDepth(55)
|
||||
if (kpi >= 80) {
|
||||
grade = 'S级 "超出预期"'
|
||||
gradeColor = '#fbbf24'
|
||||
gradeDesc = '恭喜晋升为高级打工人!福报已在路上...'
|
||||
} else if (kpi >= 60) {
|
||||
grade = 'A级 "达成预期"'
|
||||
gradeColor = '#34d399'
|
||||
gradeDesc = '表现良好,明年涨薪3%(扣去通胀后-2%)'
|
||||
} else if (kpi >= 40) {
|
||||
grade = 'B级 "基本达成"'
|
||||
gradeColor = '#60a5fa'
|
||||
gradeDesc = '还需努力,下月开始996'
|
||||
} else {
|
||||
grade = 'C级 "未达预期"'
|
||||
gradeColor = '#f87171'
|
||||
gradeDesc = '已被纳入待优化名单'
|
||||
}
|
||||
|
||||
showVictoryModal({ kpi, hc, grade, gradeColor, gradeDesc })
|
||||
}
|
||||
|
||||
/** 显示失败画面 */
|
||||
/** 显示失败画面(仿钉钉退群通知,委托给 EndScreenModal) */
|
||||
showGameOver(): void {
|
||||
const overlay = this.scene.add.graphics()
|
||||
overlay.fillStyle(0x000000, 0.7)
|
||||
overlay.fillRect(0, 0, GAME_WIDTH, 720)
|
||||
overlay.setDepth(50)
|
||||
|
||||
this.scene.add
|
||||
.text(GAME_WIDTH / 2, 300, 'KPI 归零!被裁了!', {
|
||||
fontFamily: "'Press Start 2P', monospace",
|
||||
fontSize: '18px',
|
||||
color: '#EF4444',
|
||||
backgroundColor: '#0A1628',
|
||||
padding: { x: 24, y: 12 },
|
||||
})
|
||||
.setOrigin(0.5, 0.5)
|
||||
.setDepth(55)
|
||||
showDefeatModal()
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
|
||||
Reference in New Issue
Block a user