feat(config,skill): 新增通用文字飘字提示功能

1. 新增TooltipTypes.tip枚举类型,支持调用方自定义文字和颜色
2. 扩展Tooltip.load和hp_tip方法,增加tipColor参数传递自定义颜色
3. 新增setupTipLabel工具方法,处理通用文字飘字的UI设置
4. 优化现有tip类型的注释和默认颜色逻辑,修复对象池复用颜色残留问题
5. 修复heroSet.ts导入多余空格问题
This commit is contained in:
panFD
2026-09-07 21:08:26 +08:00
parent 95a8c0e1d6
commit d559fdbaa4
6 changed files with 401 additions and 956 deletions

View File

@@ -17,6 +17,8 @@ export class TooltipCom extends CCComp {
fac: number = FacSet.MON;
/** DoT 飘字需激活的 debuff 图标节点名(loss_life/hp/debuff 下的子节点,如 FireDamage);空串=普通伤害 */
debuffIcon: string = "";
/** 通用文字飘字(TooltipTypes.tip)的自定义颜色,null 表示使用预制体默认色 */
tipColor: Color | null = null;
// 动画参数配置
private readonly popDuration = 0.15;
@@ -31,12 +33,13 @@ export class TooltipCom extends CCComp {
}
/** 初始化并播放动画 */
init(type: number, value: string, uuid: number, fac: number = FacSet.MON, debuffIcon: string = "") {
init(type: number, value: string, uuid: number, fac: number = FacSet.MON, debuffIcon: string = "", tipColor: Color | null = null) {
this.stype = type;
this.value = value;
this.s_uuid = uuid;
this.fac = fac;
this.debuffIcon = debuffIcon;
this.tipColor = tipColor;
// 初始化或获取 UIOpacity 组件
this._uiOpacity = this.node.getComponent(UIOpacity);
@@ -132,16 +135,22 @@ export class TooltipCom extends CCComp {
this.node.setPosition(v3(this.node.position.x, currentY - 60));
this.node.setSiblingIndex(topSiblingIndex);
break;
case TooltipTypes.shield: // 护盾减免
case TooltipTypes.shield: // 护盾吸收伤害:显示“吸收”+ 数值
this.node.setPosition(v3(this.node.position.x + offsetX, currentY));
this.node.setSiblingIndex(topSiblingIndex);
this.setupLabel("add_life", "hp", "0");
isHeal = true;
this.setupTipLabel(`吸收 ${this.value}`, this.tipColor ?? new Color(79, 195, 247, 255)); // 默认蓝
isHeal = true; // 垂直上飘,区别于伤害随机横飘
break;
case TooltipTypes.miss: // 闪避
this.node.setPosition(v3(this.node.position.x + offsetX, currentY));
this.node.setSiblingIndex(topSiblingIndex);
this.setupLabel("add_life", "hp", "闪避");
this.setupTipLabel(this.value || "闪避", this.tipColor ?? new Color(255, 255, 255, 255)); // 默认白
isHeal = true;
break;
case TooltipTypes.tip: // 通用文字飘字
this.node.setPosition(v3(this.node.position.x + offsetX, currentY));
this.node.setSiblingIndex(topSiblingIndex);
this.setupTipLabel(this.value, this.tipColor);
isHeal = true;
break;
}
@@ -158,6 +167,22 @@ export class TooltipCom extends CCComp {
}
}
/**
* 通用文字飘字:激活 words 节点并设置文字与颜色
* 预制体需包含 words/name 结构(Label);与 skill 节点区分,走漂移上飘动画而非原地淡出
* 对象池复用安全:未传色时恢复默认白,避免上次自定义色残留
*/
private setupTipLabel(text: string, color: Color | null = null) {
const words = this.node.getChildByName("words");
if (!words) return;
words.active = true;
const label = words.getChildByName("name")?.getComponent(Label);
if (label) {
label.string = text;
label.color = color ?? Color.WHITE.clone();
}
}
/**
* DoT 伤害飘字:激活 loss_life/hp/debuff 下指定的 debuff 图标子节点。
* 仅怪物普通伤害(loss_life)路径调用;debuffIcon 为空或未找到节点时静默跳过。