3 Commits

Author SHA1 Message Date
panFD
d559fdbaa4 feat(config,skill): 新增通用文字飘字提示功能
1. 新增TooltipTypes.tip枚举类型,支持调用方自定义文字和颜色
2. 扩展Tooltip.load和hp_tip方法,增加tipColor参数传递自定义颜色
3. 新增setupTipLabel工具方法,处理通用文字飘字的UI设置
4. 优化现有tip类型的注释和默认颜色逻辑,修复对象池复用颜色残留问题
5. 修复heroSet.ts导入多余空格问题
2026-09-07 21:08:26 +08:00
panFD
95a8c0e1d6 refactor(skill tooltip): 移除技能提示的触发类型相关参数
1.  移除TooltipCom中triggerType相关属性和setupTriggerBg方法
2.  简化各层调用时的triggerType参数传递
3.  删除未使用的SkillTriggerType导入
2026-09-07 21:05:01 +08:00
panFD
aa488d55e7 feat: 新增闪避与命中属性系统,完善战斗判定逻辑
1.  新增全局默认闪避/命中率配置,为英雄和怪物提供缺省属性兜底
2.  扩展英雄属性组件,添加闪避、命中率属性与对应计算接口
3.  实现闪避判定逻辑,修正伤害流程,添加闪避提示效果
4.  新增闪避/命中相关buff、技能与光环配置
5.  完善属性值计算与 tooltip 显示逻辑
2026-09-07 20:41:49 +08:00
14 changed files with 524 additions and 1000 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -287,4 +287,20 @@ export const BuffList: Record<number, BuffConfig> = {
modifiers: [{ attr: Attrs.hp_max, op: ModOp.PercentAdd, value: 30 }],
info: "最大生命值提升 30%,并立即回复等量生命,持续 5 秒",
},
// ==================== 闪避 / 命中系 ====================
// 闪避爆发(限时提升闪避概率,百分点累加)
7030: {
id: 7030, name: "闪避爆发", icon: "98-Enchant-Wind",
category: BuffCategory.Buff, duration: 5, max_stack: 1,
modifiers: [{ attr: Attrs.dodge, op: ModOp.PercentAdd, value: 20 }],
info: "闪避概率提升 20%,持续 5 秒",
},
// 命中强化(限时提升命中概率,百分点累加)
7031: {
id: 7031, name: "命中强化", icon: "27-Hawkeye",
category: BuffCategory.Buff, duration: 5, max_stack: 1,
modifiers: [{ attr: Attrs.accuracy, op: ModOp.PercentAdd, value: 20 }],
info: "命中概率提升 20%,持续 5 秒",
},
};

View File

@@ -76,6 +76,10 @@ export enum FightSet {
INIT_REFRESH_STONE = 3, // 初始刷新石数量
/** 单次刷新消耗的刷新石数量 */
REFRESH_STONE_COST = 1,
/** 全局默认闪避率(百分点),heroSet 未配置时生效 */
DEFAULT_DODGE = 15,
/** 全局默认命中率(百分点),heroSet 未配置时生效 */
DEFAULT_ACCURACY = 10,
}
/**
@@ -143,6 +147,9 @@ export const TooltipTypes = {
hpup: 8,
addmp: 9,
shield: 10,
miss: 11,
/** 通用文字飘字(闪避/格挡/免疫等),文字与颜色由调用方传入 */
tip: 12,
}

View File

@@ -455,6 +455,16 @@ export const SkillSet: Record<number, SkillConfig> = {
DTType: DTType.single, kind: SkillKind.Support, ap: 10, hit_count: 1, hitcd: 0.2, speed: 720, with: 0, ready: 0.2, EAnm: 0, DAnm: "", IType: IType.support,
RType: RType.fixed, EType: EType.animationEnd, buff_type: Attrs.thorns_rate, info: "全体友方比例反伤提升10%, 永久生效",
},
6415: {
uuid: 6415, name: "闪避强化", sp_name: "buff_wind", icon: "98-Enchant-Wind", TGroup: TGroup.Team, readyAnm: "up_blue", endAnm: "", act: "atk",
DTType: DTType.single, kind: SkillKind.Support, ap: 5, hit_count: 1, hitcd: 0.2, speed: 720, with: 0, ready: 0.2, EAnm: 0, DAnm: "", IType: IType.support,
RType: RType.fixed, EType: EType.animationEnd, buff_type: Attrs.dodge, info: "全体友方闪避概率提升5%, 永久生效",
},
6416: {
uuid: 6416, name: "命中强化", sp_name: "buff_wind", icon: "27-Hawkeye", TGroup: TGroup.Team, readyAnm: "up_blue", endAnm: "", act: "atk",
DTType: DTType.single, kind: SkillKind.Support, ap: 5, hit_count: 1, hitcd: 0.2, speed: 720, with: 0, ready: 0.2, EAnm: 0, DAnm: "", IType: IType.support,
RType: RType.fixed, EType: EType.animationEnd, buff_type: Attrs.accuracy, info: "全体友方命中概率提升5%, 永久生效",
},
6501: {
uuid: 6501, name: "复活", sp_name: "buff_wind", icon: "40-Holy", TGroup: TGroup.Self, readyAnm: "up_ap", endAnm: "", act: "atk",
DTType: DTType.single, kind: SkillKind.Support, ap: 50, hit_count: 3, hitcd: 0.2, speed: 720, with: 0, ready: 0.2, EAnm: 0, DAnm: "", IType: IType.support,
@@ -546,6 +556,16 @@ export const SkillSet: Record<number, SkillConfig> = {
uuid: 6517, name: "生命爆发", sp_name: "buff_wind", icon: "29-Endure", TGroup: TGroup.Team, readyAnm: "up_green", endAnm: "", act: "atk",
DTType: DTType.single, kind: SkillKind.Support, ap: 0, hit_count: 3, hitcd: 0.2, speed: 720, with: 0, ready: 0.2, EAnm: 0, DAnm: "", IType: IType.support,
RType: RType.fixed, EType: EType.animationEnd, buff_type: Attrs.hp_max, timed_buff_id: 7029, info: "全体友方最大生命值提升30%, 持续5秒",
},
6518: {
uuid: 6518, name: "闪避爆发", sp_name: "buff_wind", icon: "98-Enchant-Wind", TGroup: TGroup.Team, readyAnm: "up_blue", endAnm: "", act: "atk",
DTType: DTType.single, kind: SkillKind.Support, ap: 0, hit_count: 3, hitcd: 0.2, speed: 720, with: 0, ready: 0.2, EAnm: 0, DAnm: "", IType: IType.support,
RType: RType.fixed, EType: EType.animationEnd, buff_type: Attrs.dodge, timed_buff_id: 7030, info: "全体友方闪避概率提升20%, 持续5秒",
},
6519: {
uuid: 6519, name: "命中强化", sp_name: "buff_wind", icon: "27-Hawkeye", TGroup: TGroup.Team, readyAnm: "up_blue", endAnm: "", act: "atk",
DTType: DTType.single, kind: SkillKind.Support, ap: 0, hit_count: 3, hitcd: 0.2, speed: 720, with: 0, ready: 0.2, EAnm: 0, DAnm: "", IType: IType.support,
RType: RType.fixed, EType: EType.animationEnd, buff_type: Attrs.accuracy, timed_buff_id: 7031, info: "全体友方命中概率提升20%, 持续5秒",
}
};
//***************驻场技能配置***************
@@ -569,6 +589,8 @@ export enum FieldSkillType {
HeroPunctureDmg = 21, // 英雄穿透后伤害加成(百分点;乘算:PUNCTURE_DMG_RATIO * (1 + bonus/100))
HeroThornsDmg = 22, // 英雄固定反伤加成
HeroThornsRate = 23, // 英雄比例反伤加成(百分点)
HeroDodge = 24, // 英雄闪避率加成(百分点)
HeroHit = 25, // 英雄命中率加成(百分点)
}
export interface FieldSkillConfig {
@@ -607,4 +629,6 @@ export const FieldSkillSet: Record<number, FieldSkillConfig> = {
7016: { uuid: 7016, name: "鼓舞光环", icon: "64-Prominance", type: FieldSkillType.StartCount, info: "战斗开始触发技能次数提升" },
7018: { uuid: 7018, name: "连击光环", icon: "74-Satisfaction", type: FieldSkillType.AtkCount, info: "攻击触发技能次数提升" },
7019: { uuid: 7019, name: "受击光环", icon: "84-Termor", type: FieldSkillType.BeAtkCount, info: "被攻击触发技能次数提升" },
7023: { uuid: 7023, name: "闪避光环", icon: "98-Enchant-Wind", type: FieldSkillType.HeroDodge, info: "英雄闪避概率提升" },
7024: { uuid: 7024, name: "命中光环", icon: "27-Hawkeye", type: FieldSkillType.HeroHit, info: "英雄命中概率提升" },
};

View File

@@ -1,4 +1,4 @@
import { v3 } from "cc"
import { v3 } from "cc"
import { BoxSet, FacSet, FightSet } from "./GameSet"
import { SkillOverrides, TGroup, SkillSet, FieldSkillSet, SkillConfig, SkillKind, FieldSkillConfig, FieldSkillType, mergeSkillParams } from "./SkillSet"
import { BuffList, BuffConfig, ModOp } from "./BuffSet"
@@ -414,6 +414,8 @@ export interface heroInfo {
[SkillTriggerType.Atked]?: TriggerGrouped; // 受击后触发的技能配置,s_uuid: 技能id, t_num: 触发所需的受击次数
dis?: number; // 攻击距离(像素)
speed?: number; // 移动速度(像素/秒)
dodge?: number; // 闪避率(百分点,缺省由初始化处兜底为全局默认值)
accuracy?: number; // 命中率(百分点,缺省由初始化处兜底为全局默认值)
skills: Record<number, HSkillInfo>; // 携带技能ID列表
ap_bonus?: LvBonusEntry[]; // 额外攻击加成(按 lv 升序,运行时累加 ≤英雄等级 的所有档)
hp_bonus?: LvBonusEntry[]; // 额外生命加成(按 lv 升序,运行时累加 ≤英雄等级 的所有档)
@@ -1257,6 +1259,10 @@ function calcBuffPermanentEquivalent(buff: BuffConfig, apEff: number, cd: number
case Attrs.speed:
value += (modValue / 100) * dps * weights.W_DPS_PER_SEC * seconds;
break;
case Attrs.dodge:
case Attrs.accuracy:
value += modValue * weights.W_control;
break;
}
}
}
@@ -1298,6 +1304,8 @@ function calcSupportEffectValue(config: SkillConfig, hpEff: number, apEff: numbe
return (value / 100) * (apEff / cd) * 0.05 * weights.W_DPS_PER_SEC * seconds;
case Attrs.stun_chance:
case Attrs.freeze_chance:
case Attrs.dodge:
case Attrs.accuracy:
return value * weights.W_control;
case Attrs.knockback_chance:
// 击退强化已改为击退距离增量,按距离价值折算

View File

@@ -162,6 +162,9 @@ export class Hero extends ecs.Entity {
}
model.speed = hero.speed ?? 200;
// 闪避/命中:配置优先,缺省取全局默认值(百分点)
model.dodge = hero.dodge ?? FightSet.DEFAULT_DODGE;
model.accuracy = hero.accuracy ?? FightSet.DEFAULT_ACCURACY;
// 构建技能表并注入运行时冷却字段 ccd;overrides 按英雄等级 resolve 分档(下游无感知)
model.skills = {};

View File

@@ -134,6 +134,14 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
// 触发被攻击事件
this.onAttacked(target);
// 闪避判定(DoT 不参与):闪避率 = 目标闪避 − 施法者命中
if (!isDot && this.checkDodge(damageEvent, TAttrsComp)) {
smc.vmdata.scores.dod_count++;
targetView?.showMiss?.();
// 预留:闪避后触发技能(SkillTriggerType.Dodged)在此接入
return reDate;
}
// 暴击判定
// 使用施法者的暴击率属性(damageEvent.Attrs 快照)- 被攻击者的暴击抗性 + 目标出血层数附加的被暴击率
const criticalChance = (damageEvent.Attrs[Attrs.critical] || 0) - TAttrsComp.getFinalCriticalRes() + this.getBleedCritBonus(target);
@@ -340,7 +348,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
// 触发复活动画
if (targetView && reviveSkillConf) {
targetView.playReady(reviveSkillConf.readyAnm);
targetView.skill_name('', reviveSkillConf.uuid, SkillTriggerType.Revive);
targetView.skill_name('', reviveSkillConf.uuid);
// 延迟 0.5 秒后恢复状态,让特效有时间播放,同时也能体现“正在复活”的过程
targetView.scheduleOnce(() => {
if (targetView.node && targetView.node.isValid) {
@@ -528,6 +536,19 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
return (layers?.length ?? 0) * BLEED_CRIT_PER_STACK;
}
/**
* 闪避判定:闪避率 = 目标闪避 − 施法者命中,再按该值判定是否闪避。
* 命中未配置时(accuracy=0)闪避率 = 目标闪避,即无命中加成时闪避全额生效。
* @param damageEvent 伤害事件(含施法者属性快照)
* @param TAttrsComp 目标属性组件
* @returns true=闪避成功,false=命中
*/
private checkDodge(damageEvent: DamageEvent, TAttrsComp: HeroAttrsComp): boolean {
const dodgeChance = TAttrsComp.getFinalDodge() - (damageEvent.Attrs[Attrs.accuracy] || 0);
if (dodgeChance <= 0) return false;
return this.checkChance(dodgeChance);
}
/**
* 计算易伤附加伤害:汇总目标每层易伤 buff 的数值(value_override 优先),再被易伤抗性百分比减免。
* @returns 附加伤害值(向下取整,非负)

View File

@@ -75,6 +75,8 @@ export class HeroAttrsComp extends ecs.Comp {
// ==================== 特殊属性 ====================
critical: number = 0; // 暴击率
critical_res: number = 0; // 暴击抗性
dodge: number = 0; // 闪避率(被攻击时闪避概率,百分点)
accuracy: number = 0; // 命中率(攻击时命中概率,百分点;削减目标闪避)
freeze_chance: number = 0; // 冰冻概率
freeze_res: number = 0; // 冰冻抗性
stun_chance: number = 0; // 击晕概率
@@ -350,6 +352,18 @@ export class HeroAttrsComp extends ecs.Comp {
return this.critical + HeroAttrsComp.getFieldPercentValue(FieldSkillType.HeroCrit);
}
/** 英雄实时闪避率 = 基础闪避率 + 驻场闪避率。 */
public getRuntimeDodge(): number {
if (this.fac !== FacSet.HERO) return this.dodge;
return this.dodge + HeroAttrsComp.getFieldPercentValue(FieldSkillType.HeroDodge);
}
/** 英雄实时命中率 = 基础命中率 + 驻场命中率。 */
public getRuntimeAccuracy(): number {
if (this.fac !== FacSet.HERO) return this.accuracy;
return this.accuracy + HeroAttrsComp.getFieldPercentValue(FieldSkillType.HeroHit);
}
/** 英雄实时冰冻率 = 基础冰冻率 + 驻场冰冻率。 */
public getRuntimeFreezeChance(): number {
if (this.fac !== FacSet.HERO) return this.freeze_chance;
@@ -541,6 +555,20 @@ export class HeroAttrsComp extends ecs.Comp {
return this.critical_res + mods.flatSum + mods.pctSum;
}
/** 最终闪避率 = 驻场实时闪避率 + 限时修饰(加法模型) */
public getFinalDodge(): number {
const base = this.getRuntimeDodge();
const mods = this.aggregateTimedMods(Attrs.dodge);
return base + mods.flatSum + mods.pctSum;
}
/** 最终命中率 = 驻场实时命中率 + 限时修饰(加法模型) */
public getFinalAccuracy(): number {
const base = this.getRuntimeAccuracy();
const mods = this.aggregateTimedMods(Attrs.accuracy);
return base + mods.flatSum + mods.pctSum;
}
/** 最终冰冻抗性 = 基础 + 限时修饰(加法模型) */
public getFinalFreezeRes(): number {
const mods = this.aggregateTimedMods(Attrs.freeze_res);
@@ -687,6 +715,8 @@ export class HeroAttrsComp extends ecs.Comp {
this.runtime_field = undefined;
this.critical = 0;
this.critical_res = 0;
this.dodge = 0;
this.accuracy = 0;
this.freeze_chance = 0;
this.freeze_res = 0;
this.stun_chance = 0;

View File

@@ -1,4 +1,4 @@
import { Vec3, _decorator, v3, Collider2D, Contact2DType, Node, Prefab, instantiate, tween, Tween, BoxCollider2D, UITransform } from "cc";
import { Vec3, _decorator, v3, Collider2D, Contact2DType, Node, Prefab, instantiate, tween, Tween, BoxCollider2D, UITransform, Color } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { mLogger } from "../common/Logger";
@@ -216,13 +216,13 @@ export class HeroViewComp extends CCComp {
Tooltip.load(pos, type, value, s_uuid, this.node);
}
/** 技能提示 */
public skill_name(value: string = "", s_uuid: number = 1001, triggerType: string = "", y: number = 50) {
public skill_name(value: string = "", s_uuid: number = 1001, y: number = 50) {
let pos = v3(0, 60);
pos.y = pos.y + y;
Tooltip.load(pos, TooltipTypes.skill, value, s_uuid, this.node, 1, this.model?.fac ?? FacSet.MON, triggerType);
Tooltip.load(pos, TooltipTypes.skill, value, s_uuid, this.node, 1, this.model?.fac ?? FacSet.MON);
}
/** 血量提示(伤害数字) */
private hp_tip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 0, debuffIcon: string = "") {
private hp_tip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 0, debuffIcon: string = "", tipColor: Color | null = null) {
let x = this.node.position.x;
// 获取怪物高度的一半,定位到中心点
let halfHeight = 0;
@@ -234,13 +234,18 @@ export class HeroViewComp extends CCComp {
// 起点设为怪物中心偏下位置,使其在血条下方
let ny = this.node.position.y + halfHeight - 15;
let pos = v3(x, ny, 0);
Tooltip.load(pos, type, value, s_uuid, this.node.parent, 1, this.model?.fac ?? FacSet.MON, "", debuffIcon);
Tooltip.load(pos, type, value, s_uuid, this.node.parent, 1, this.model?.fac ?? FacSet.MON, debuffIcon, tipColor);
}
/** 护盾减免提示 */
/** 护盾吸收提示:蓝色 "吸收 N" */
shield_tip(absorbed: number) {
this.hp_tip(TooltipTypes.shield, NumberFormatter.formatNumber(Math.max(0, Math.floor(absorbed))));
}
/** 闪避提示:白色 "闪避" */
showMiss() {
this.hp_tip(TooltipTypes.miss, "闪避");
}
public playBuff(anm: string = "") {
if (anm === "") return;
var path = "game/skill/buff/" + anm;

View File

@@ -176,6 +176,9 @@ export class Monster extends ecs.Entity {
// TODO: 局外升级机制落地后,此处基础值将与存档强化累加重算
model.defense = Math.round(hero.def * coef);
model.speed = hero.speed ?? 800;
// 闪避/命中:配置优先,缺省取全局默认值(百分点)
model.dodge = hero.dodge ?? FightSet.DEFAULT_DODGE;
model.accuracy = hero.accuracy ?? FightSet.DEFAULT_ACCURACY;
model.type = hero.type;
model.fac = FacSet.MON;
// lv12 职业属性专项:按 11 级当前有效值追加 50%(怪物无局内升级,初始超档直接补齐)

View File

@@ -324,7 +324,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
if (castTimes > 1) {
val = "*" + castTimes.toString
}
heroView.skill_name(val, s_uuid, triggerType)
heroView.skill_name(val, s_uuid)
for (let i = 0; i < castTimes; i++) {
if (!heroView.node || !heroView.node.isValid) return;
// 多发/召唤按间隔错峰执行:i=0 立即,其余延迟 i*SUMMON_INTERVAL

View File

@@ -236,6 +236,7 @@ export class Skill extends ecs.Entity {
sDataCom.Attrs[Attrs.knockback_skill_chance] = config.bck_chance ?? 0;
sDataCom.Attrs[Attrs.puncture_chance] = cAttrsComp.getFinalPunctureChance(); // 初始化携带施法者的穿透概率
sDataCom.Attrs[Attrs.puncture_dmg_bonus] = cAttrsComp.getFinalPunctureDmgBonus(); // 初始化携带施法者的穿透伤害加成
sDataCom.Attrs[Attrs.accuracy] = cAttrsComp.getFinalAccuracy(); // 初始化携带施法者的命中率(含驻场光环与计时 buff)
sDataCom.s_uuid = s_uuid
sDataCom.skill_lv = Math.max(0, skill_lv);
sDataCom.fac = cAttrsComp.fac

View File

@@ -4,7 +4,7 @@ import { BoxSet, FacSet } from "../common/config/GameSet";
import { SkillSet } from "../common/config/SkillSet";
import { smc } from "../common/SingletonModuleComp";
import { TooltipCom } from "./TooltipCom";
import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite, NodePool} from "cc";
import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite, NodePool, Color} from "cc";
/** Skill 模块 */
@ecs.register(`Tooltip`)
@@ -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="",debuffIcon: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,debuffIcon:string="",tipColor:Color|null=null) {
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, debuffIcon);
sv.init(type, vaule, s_uuid, fac, debuffIcon, tipColor);
// this.add(sv); // 不要添加到单例实体上,否则会覆盖或导致单例被销毁
}

View File

@@ -3,7 +3,6 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { SkillSet } from "../common/config/SkillSet";
import { FacSet, TooltipTypes } from "../common/config/GameSet";
import { SkillTriggerType } from "../common/config/heroSet";
import { Tooltip } from "./Tooltip";
const { ccclass, property } = _decorator;
@@ -12,25 +11,14 @@ const { ccclass, property } = _decorator;
@ccclass('TooltipCom')
@ecs.register('TooltipView', false)
export class TooltipCom extends CCComp {
@property(Node)
atking_bg: Node = null;
@property(Node)
atked_bg: Node = null;
@property(Node)
fstart_bg: Node = null;
@property(Node)
dead_bg: Node = null;
@property(Node)
revive_bg: Node = null;
stype: number = 1; // 1:减少生命值,2:增加生命值,3:技能图标
value: string = "";
s_uuid: number = 1001;
fac: number = FacSet.MON;
/** 当前技能喊话对应的触发类型(空字符串表示普通主动技能) */
triggerType: string = "";
/** DoT 飘字需激活的 debuff 图标节点名(loss_life/hp/debuff 下的子节点,如 FireDamage);空串=普通伤害 */
debuffIcon: string = "";
/** 通用文字飘字(TooltipTypes.tip)的自定义颜色,null 表示使用预制体默认色 */
tipColor: Color | null = null;
// 动画参数配置
private readonly popDuration = 0.15;
@@ -45,13 +33,13 @@ export class TooltipCom extends CCComp {
}
/** 初始化并播放动画 */
init(type: number, value: string, uuid: number, fac: number = FacSet.MON, triggerType: string = "", 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.triggerType = triggerType;
this.debuffIcon = debuffIcon;
this.tipColor = tipColor;
// 初始化或获取 UIOpacity 组件
this._uiOpacity = this.node.getComponent(UIOpacity);
@@ -126,8 +114,6 @@ export class TooltipCom extends CCComp {
// 技能喊话基于 load 传入位置再抬高 50,避免遮挡角色
this.node.setPosition(v3(this.node.position.x, this.node.position.y + 50));
this.node.setSiblingIndex(topSiblingIndex);
// 根据触发类型激活对应的背景标识(追击/反击/起手/生息/亡语/复活)
this.setupTriggerBg(this.triggerType);
break;
case TooltipTypes.uskill:
this.setupLabel("uskill", "name", this.value);
@@ -149,10 +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");
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.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;
}
@@ -169,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 为空或未找到节点时静默跳过。
@@ -183,32 +197,6 @@ export class TooltipCom extends CCComp {
}
}
/**
* 根据技能触发类型激活对应的背景标识节点
* 仅 TooltipTypes.skill 走此分支,其他飘字类型不受影响
* 对象池复用场景下先统一关闭所有 _bg,避免上一次的状态残留
*/
private setupTriggerBg(triggerType: string) {
// 先关闭所有触发类型背景,防止节点池复用时残留
this.atking_bg && (this.atking_bg.active = false);
this.atked_bg && (this.atked_bg.active = false);
this.fstart_bg && (this.fstart_bg.active = false);
this.dead_bg && (this.dead_bg.active = false);
this.revive_bg && (this.revive_bg.active = false);
if (!triggerType) return;
const bgMap: Record<string, Node | null> = {
[SkillTriggerType.Atking]: this.atking_bg,
[SkillTriggerType.Atked]: this.atked_bg,
[SkillTriggerType.FStart]: this.fstart_bg,
[SkillTriggerType.Dead]: this.dead_bg,
[SkillTriggerType.Revive]: this.revive_bg,
};
const bg = bgMap[triggerType];
if (bg) bg.active = true;
}
playAnimation(scaleMax: number, isCrit: boolean, isHeal: boolean, sx: number = 1) {
// 随机 X 轴偏移 (防止重叠)
const randomX = (Math.random() - 0.5) * 60;