From abcbeff9abaf364f473695aa43e751d77217f663 Mon Sep 17 00:00:00 2001 From: panw Date: Tue, 24 Mar 2026 10:16:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=BA=E5=B7=A5=E5=85=B7=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=B7=BB=E5=8A=A0=E9=98=B5=E8=90=A5=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 扩展 Tooltip 系统以支持根据伤害来源的阵营(英雄或怪物)显示不同的文本标签。修改 HeroViewComp 调用时传递阵营信息,TooltipCom 根据阵营选择对应的本地化键名。同时调整了工具提示预制件的默认激活状态和文本颜色。 --- assets/resources/game/skill/buff/tooltip.prefab | 8 ++++---- assets/script/game/hero/HeroViewComp.ts | 2 +- assets/script/game/skill/Tooltip.ts | 6 +++--- assets/script/game/skill/TooltipCom.ts | 8 +++++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/assets/resources/game/skill/buff/tooltip.prefab b/assets/resources/game/skill/buff/tooltip.prefab index ca2c6ce3..2ff08b71 100644 --- a/assets/resources/game/skill/buff/tooltip.prefab +++ b/assets/resources/game/skill/buff/tooltip.prefab @@ -106,7 +106,7 @@ "__id__": 3 } ], - "_active": true, + "_active": false, "_components": [ { "__id__": 17 @@ -565,7 +565,7 @@ "__id__": 21 } ], - "_active": true, + "_active": false, "_components": [ { "__id__": 35 @@ -2000,8 +2000,8 @@ "_color": { "__type__": "cc.Color", "r": 255, - "g": 68, - "b": 68, + "g": 140, + "b": 0, "a": 255 }, "_string": "9999", diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index e50514d2..981aa2bd 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -286,7 +286,7 @@ export class HeroViewComp extends CCComp { // 起点设为怪物中心位置 + 20偏移 let ny = this.node.position.y + halfHeight + 20; let pos = v3(x, ny, 0); - Tooltip.load(pos, type, value, s_uuid, this.node.parent); + Tooltip.load(pos, type, value, s_uuid, this.node.parent, 1, this.model?.fac ?? FacSet.MON); } /** 护盾吸收提示 */ diff --git a/assets/script/game/skill/Tooltip.ts b/assets/script/game/skill/Tooltip.ts index cac8743c..928fe884 100644 --- a/assets/script/game/skill/Tooltip.ts +++ b/assets/script/game/skill/Tooltip.ts @@ -1,6 +1,6 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; -import { BoxSet } from "../common/config/GameSet"; +import { BoxSet, FacSet } from "../common/config/GameSet"; import { SkillSet } from "../common/config/SkillSet"; import { smc } from "../common/SingletonModuleComp"; import { TooltipCom } from "./TooltipCom"; @@ -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) { + 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) { 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); + sv.init(type, vaule, s_uuid, fac); // this.add(sv); // 不要添加到单例实体上,否则会覆盖或导致单例被销毁 } diff --git a/assets/script/game/skill/TooltipCom.ts b/assets/script/game/skill/TooltipCom.ts index 97157dc0..053d39cf 100644 --- a/assets/script/game/skill/TooltipCom.ts +++ b/assets/script/game/skill/TooltipCom.ts @@ -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: // 治疗