refactor(skill&atk): 优化伤害飘字与debuff图标显示逻辑

1. 调整fb-1、fb-3、fb-5、fb-6技能预制体的攻击偏移与跑动类型参数
2. 重构debuff图标映射逻辑,提取公共常量供多模块复用
3. 为DoT伤害飘字添加debuff图标显示功能,统一伤害与debuff展示流程
4. 修复tooltip预制体默认激活状态问题
This commit is contained in:
panFD
2026-08-15 14:55:51 +08:00
parent e8c6a7ca6a
commit 667ec1abfb
10 changed files with 50 additions and 28 deletions

View File

@@ -57,6 +57,7 @@ export class HeroViewComp extends CCComp {
private damageQueue: Array<{
damage: number,
isCrit: boolean,
debuffIcon: string,
}> = [];
private isProcessingDamage: boolean = false;
private damageInterval: number = 0.01; // 伤害数字显示间隔
@@ -209,7 +210,7 @@ export class HeroViewComp extends CCComp {
Tooltip.load(pos, TooltipTypes.skill, value, s_uuid, this.node, 1, this.model?.fac ?? FacSet.MON, triggerType);
}
/** 血量提示(伤害数字) */
private hp_tip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 0) {
private hp_tip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 0, debuffIcon: string = "") {
let x = this.node.position.x;
// 获取怪物高度的一半,定位到中心点
let halfHeight = 0;
@@ -221,7 +222,7 @@ export class HeroViewComp extends CCComp {
// 起点设为怪物中心偏下位置,使其在血条下方
let ny = this.node.position.y + halfHeight - 15;
let pos = v3(x, ny, 0);
Tooltip.load(pos, type, value, s_uuid, this.node.parent, 1, this.model?.fac ?? FacSet.MON);
Tooltip.load(pos, type, value, s_uuid, this.node.parent, 1, this.model?.fac ?? FacSet.MON, "", debuffIcon);
}
/** 护盾减免提示 */
@@ -449,11 +450,11 @@ export class HeroViewComp extends CCComp {
/** 显示伤害数字 */
showDamage(damage: number, isCrit: boolean) {
showDamage(damage: number, isCrit: boolean, debuffIcon: string = "") {
this.damageQueue.push({
damage,
isCrit,
debuffIcon,
});
}
@@ -464,7 +465,7 @@ export class HeroViewComp extends CCComp {
this.isProcessingDamage = true;
const damageInfo = this.damageQueue.shift()!;
this.showDamageImmediate(damageInfo.damage, damageInfo.isCrit);
this.showDamageImmediate(damageInfo.damage, damageInfo.isCrit, damageInfo.debuffIcon);
// 设置延时处理下一个伤
this.scheduleOnce(() => {
@@ -473,7 +474,7 @@ export class HeroViewComp extends CCComp {
}
/** 立即显示伤害效果 */
private showDamageImmediate(damage: number, isCrit: boolean) {
private showDamageImmediate(damage: number, isCrit: boolean, debuffIcon: string = "") {
if (!this.model) return;
const damageText = NumberFormatter.formatNumber(Math.max(0, Math.floor(damage)));
@@ -481,7 +482,7 @@ export class HeroViewComp extends CCComp {
if (isCrit) {
this.hp_tip(TooltipTypes.crit, damageText);
} else {
this.hp_tip(TooltipTypes.life, damageText);
this.hp_tip(TooltipTypes.life, damageText, 1001, 0, debuffIcon);
}
}
reset() {