feat: 为工具提示添加阵营区分显示

扩展 Tooltip 系统以支持根据伤害来源的阵营(英雄或怪物)显示不同的文本标签。修改 HeroViewComp 调用时传递阵营信息,TooltipCom 根据阵营选择对应的本地化键名。同时调整了工具提示预制件的默认激活状态和文本颜色。
This commit is contained in:
panw
2026-03-24 10:16:31 +08:00
parent 78d4b10a88
commit abcbeff9ab
4 changed files with 13 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ import { _decorator, Collider2D, Contact2DType, v3, IPhysics2DContact, Vec3, twe
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { SkillSet } from "../common/config/SkillSet";
import { TooltipTypes } from "../common/config/GameSet";
import { FacSet, TooltipTypes } from "../common/config/GameSet";
import { Tooltip } from "./Tooltip";
const { ccclass, property } = _decorator;
@@ -14,6 +14,7 @@ export class TooltipCom extends CCComp {
stype: number = 1; // 1:减少生命值2增加生命值3技能图标
value: string = "";
s_uuid: number = 1001;
fac: number = FacSet.MON;
// 动画参数配置
private readonly popDuration = 0.15;
@@ -28,10 +29,11 @@ export class TooltipCom extends CCComp {
}
/** 初始化并播放动画 */
init(type: number, value: string, uuid: number) {
init(type: number, value: string, uuid: number, fac: number = FacSet.MON) {
this.stype = type;
this.value = value;
this.s_uuid = uuid;
this.fac = fac;
// 初始化或获取 UIOpacity 组件
this._uiOpacity = this.node.getComponent(UIOpacity);
@@ -76,7 +78,7 @@ export class TooltipCom extends CCComp {
case TooltipTypes.life: // 普通伤害
this.node.setPosition(v3(this.node.position.x + offsetX, currentY));
this.node.setSiblingIndex(topSiblingIndex);
this.setupLabel("loss_life", "hp", this.value);
this.setupLabel(this.fac === FacSet.HERO ? "hloss" : "loss_life", "hp", this.value);
scaleMax = 1.5;
break;
case TooltipTypes.health: // 治疗