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

@@ -60,7 +60,7 @@ export class Tooltip extends ecs.Entity {
this.remove(TooltipCom);
super.destroy();
}
static load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",s_uuid:number=1001,parent:any=null,cd:number=1,fac:number=FacSet.MON,triggerType:string="") {
static load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",s_uuid:number=1001,parent:any=null,cd:number=1,fac:number=FacSet.MON,triggerType:string="",debuffIcon:string="") {
let node: Node;
if (Tooltip.pool.size() > 0) {
node = Tooltip.pool.get()!;
@@ -75,7 +75,7 @@ export class Tooltip extends ecs.Entity {
node.active = true;
var sv = node.getComponent(TooltipCom)!;
sv.init(type, vaule, s_uuid, fac, triggerType);
sv.init(type, vaule, s_uuid, fac, triggerType, debuffIcon);
// this.add(sv); // 不要添加到单例实体上,否则会覆盖或导致单例被销毁
}

View File

@@ -29,6 +29,8 @@ export class TooltipCom extends CCComp {
fac: number = FacSet.MON;
/** 当前技能喊话对应的触发类型(空字符串表示普通主动技能) */
triggerType: string = "";
/** DoT 飘字需激活的 debuff 图标节点名loss_life/hp/debuff 下的子节点,如 FireDamage空串=普通伤害 */
debuffIcon: string = "";
// 动画参数配置
private readonly popDuration = 0.15;
@@ -43,12 +45,13 @@ export class TooltipCom extends CCComp {
}
/** 初始化并播放动画 */
init(type: number, value: string, uuid: number, fac: number = FacSet.MON, triggerType: string = "") {
init(type: number, value: string, uuid: number, fac: number = FacSet.MON, triggerType: string = "", debuffIcon: string = "") {
this.stype = type;
this.value = value;
this.s_uuid = uuid;
this.fac = fac;
this.triggerType = triggerType;
this.debuffIcon = debuffIcon;
// 初始化或获取 UIOpacity 组件
this._uiOpacity = this.node.getComponent(UIOpacity);
@@ -94,6 +97,7 @@ export class TooltipCom extends CCComp {
this.node.setPosition(v3(this.node.position.x + offsetX, currentY));
this.node.setSiblingIndex(topSiblingIndex);
this.setupLabel(this.fac === FacSet.HERO ? "hloss" : "loss_life", "hp", this.value);
this.setupDebuffIcon(); // DoT 伤害时点亮 loss_life/hp/debuff 下的对应图标
scaleMax = 1.5;
break;
case TooltipTypes.health: // 治疗
@@ -164,6 +168,20 @@ export class TooltipCom extends CCComp {
}
}
/**
* DoT 伤害飘字:激活 loss_life/hp/debuff 下指定的 debuff 图标子节点。
* 仅怪物普通伤害loss_life路径调用debuffIcon 为空或未找到节点时静默跳过。
*/
private setupDebuffIcon() {
if (!this.debuffIcon) return;
const debuffNode = this.node.getChildByName("loss_life")?.getChildByName("hp")?.getChildByName("debuff");
if (!debuffNode) return;
// 先全部隐藏(对象池复用防残留),再点亮目标图标
for (const child of debuffNode.children) {
child.active = child.name === this.debuffIcon;
}
}
/**
* 根据技能触发类型激活对应的背景标识节点
* 仅 TooltipTypes.skill 走此分支,其他飘字类型不受影响