feat: 为工具提示添加阵营区分显示
扩展 Tooltip 系统以支持根据伤害来源的阵营(英雄或怪物)显示不同的文本标签。修改 HeroViewComp 调用时传递阵营信息,TooltipCom 根据阵营选择对应的本地化键名。同时调整了工具提示预制件的默认激活状态和文本颜色。
This commit is contained in:
@@ -106,7 +106,7 @@
|
|||||||
"__id__": 3
|
"__id__": 3
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 17
|
"__id__": 17
|
||||||
@@ -565,7 +565,7 @@
|
|||||||
"__id__": 21
|
"__id__": 21
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 35
|
"__id__": 35
|
||||||
@@ -2000,8 +2000,8 @@
|
|||||||
"_color": {
|
"_color": {
|
||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
"g": 68,
|
"g": 140,
|
||||||
"b": 68,
|
"b": 0,
|
||||||
"a": 255
|
"a": 255
|
||||||
},
|
},
|
||||||
"_string": "9999",
|
"_string": "9999",
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
// 起点设为怪物中心位置 + 20偏移
|
// 起点设为怪物中心位置 + 20偏移
|
||||||
let ny = this.node.position.y + halfHeight + 20;
|
let ny = this.node.position.y + halfHeight + 20;
|
||||||
let pos = v3(x, ny, 0);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 护盾吸收提示 */
|
/** 护盾吸收提示 */
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
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 { SkillSet } from "../common/config/SkillSet";
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
import { TooltipCom } from "./TooltipCom";
|
import { TooltipCom } from "./TooltipCom";
|
||||||
@@ -60,7 +60,7 @@ export class Tooltip extends ecs.Entity {
|
|||||||
this.remove(TooltipCom);
|
this.remove(TooltipCom);
|
||||||
super.destroy();
|
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;
|
let node: Node;
|
||||||
if (Tooltip.pool.size() > 0) {
|
if (Tooltip.pool.size() > 0) {
|
||||||
node = Tooltip.pool.get()!;
|
node = Tooltip.pool.get()!;
|
||||||
@@ -75,7 +75,7 @@ export class Tooltip extends ecs.Entity {
|
|||||||
node.active = true;
|
node.active = true;
|
||||||
|
|
||||||
var sv = node.getComponent(TooltipCom)!;
|
var sv = node.getComponent(TooltipCom)!;
|
||||||
sv.init(type, vaule, s_uuid);
|
sv.init(type, vaule, s_uuid, fac);
|
||||||
|
|
||||||
// this.add(sv); // 不要添加到单例实体上,否则会覆盖或导致单例被销毁
|
// this.add(sv); // 不要添加到单例实体上,否则会覆盖或导致单例被销毁
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { _decorator, Collider2D, Contact2DType, v3, IPhysics2DContact, Vec3, twe
|
|||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { SkillSet } from "../common/config/SkillSet";
|
import { SkillSet } from "../common/config/SkillSet";
|
||||||
import { TooltipTypes } from "../common/config/GameSet";
|
import { FacSet, TooltipTypes } from "../common/config/GameSet";
|
||||||
import { Tooltip } from "./Tooltip";
|
import { Tooltip } from "./Tooltip";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
@@ -14,6 +14,7 @@ export class TooltipCom extends CCComp {
|
|||||||
stype: number = 1; // 1:减少生命值,2:增加生命值,3:技能图标
|
stype: number = 1; // 1:减少生命值,2:增加生命值,3:技能图标
|
||||||
value: string = "";
|
value: string = "";
|
||||||
s_uuid: number = 1001;
|
s_uuid: number = 1001;
|
||||||
|
fac: number = FacSet.MON;
|
||||||
|
|
||||||
// 动画参数配置
|
// 动画参数配置
|
||||||
private readonly popDuration = 0.15;
|
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.stype = type;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.s_uuid = uuid;
|
this.s_uuid = uuid;
|
||||||
|
this.fac = fac;
|
||||||
|
|
||||||
// 初始化或获取 UIOpacity 组件
|
// 初始化或获取 UIOpacity 组件
|
||||||
this._uiOpacity = this.node.getComponent(UIOpacity);
|
this._uiOpacity = this.node.getComponent(UIOpacity);
|
||||||
@@ -76,7 +78,7 @@ export class TooltipCom extends CCComp {
|
|||||||
case TooltipTypes.life: // 普通伤害
|
case TooltipTypes.life: // 普通伤害
|
||||||
this.node.setPosition(v3(this.node.position.x + offsetX, currentY));
|
this.node.setPosition(v3(this.node.position.x + offsetX, currentY));
|
||||||
this.node.setSiblingIndex(topSiblingIndex);
|
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;
|
scaleMax = 1.5;
|
||||||
break;
|
break;
|
||||||
case TooltipTypes.health: // 治疗
|
case TooltipTypes.health: // 治疗
|
||||||
|
|||||||
Reference in New Issue
Block a user