refactor(skill tooltip): 移除技能提示的触发类型相关参数
1. 移除TooltipCom中triggerType相关属性和setupTriggerBg方法 2. 简化各层调用时的triggerType参数传递 3. 删除未使用的SkillTriggerType导入
This commit is contained in:
@@ -348,7 +348,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
|||||||
// 触发复活动画
|
// 触发复活动画
|
||||||
if (targetView && reviveSkillConf) {
|
if (targetView && reviveSkillConf) {
|
||||||
targetView.playReady(reviveSkillConf.readyAnm);
|
targetView.playReady(reviveSkillConf.readyAnm);
|
||||||
targetView.skill_name('', reviveSkillConf.uuid, SkillTriggerType.Revive);
|
targetView.skill_name('', reviveSkillConf.uuid);
|
||||||
// 延迟 0.5 秒后恢复状态,让特效有时间播放,同时也能体现“正在复活”的过程
|
// 延迟 0.5 秒后恢复状态,让特效有时间播放,同时也能体现“正在复活”的过程
|
||||||
targetView.scheduleOnce(() => {
|
targetView.scheduleOnce(() => {
|
||||||
if (targetView.node && targetView.node.isValid) {
|
if (targetView.node && targetView.node.isValid) {
|
||||||
|
|||||||
@@ -216,10 +216,10 @@ export class HeroViewComp extends CCComp {
|
|||||||
Tooltip.load(pos, type, value, s_uuid, this.node);
|
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);
|
let pos = v3(0, 60);
|
||||||
pos.y = pos.y + y;
|
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 = "") {
|
||||||
@@ -234,7 +234,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
// 起点设为怪物中心偏下位置,使其在血条下方
|
// 起点设为怪物中心偏下位置,使其在血条下方
|
||||||
let ny = this.node.position.y + halfHeight - 15;
|
let ny = this.node.position.y + halfHeight - 15;
|
||||||
let pos = v3(x, ny, 0);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 护盾减免提示 */
|
/** 护盾减免提示 */
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
if (castTimes > 1) {
|
if (castTimes > 1) {
|
||||||
val = "*" + castTimes.toString
|
val = "*" + castTimes.toString
|
||||||
}
|
}
|
||||||
heroView.skill_name(val, s_uuid, triggerType)
|
heroView.skill_name(val, s_uuid)
|
||||||
for (let i = 0; i < castTimes; i++) {
|
for (let i = 0; i < castTimes; i++) {
|
||||||
if (!heroView.node || !heroView.node.isValid) return;
|
if (!heroView.node || !heroView.node.isValid) return;
|
||||||
// 多发/召唤按间隔错峰执行:i=0 立即,其余延迟 i*SUMMON_INTERVAL
|
// 多发/召唤按间隔错峰执行:i=0 立即,其余延迟 i*SUMMON_INTERVAL
|
||||||
|
|||||||
@@ -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,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="") {
|
||||||
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, fac, triggerType, debuffIcon);
|
sv.init(type, vaule, s_uuid, fac, debuffIcon);
|
||||||
|
|
||||||
// this.add(sv); // 不要添加到单例实体上,否则会覆盖或导致单例被销毁
|
// this.add(sv); // 不要添加到单例实体上,否则会覆盖或导致单例被销毁
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { SkillSet } from "../common/config/SkillSet";
|
import { SkillSet } from "../common/config/SkillSet";
|
||||||
import { FacSet, TooltipTypes } from "../common/config/GameSet";
|
import { FacSet, TooltipTypes } from "../common/config/GameSet";
|
||||||
import { SkillTriggerType } from "../common/config/heroSet";
|
|
||||||
import { Tooltip } from "./Tooltip";
|
import { Tooltip } from "./Tooltip";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
@@ -12,23 +11,10 @@ const { ccclass, property } = _decorator;
|
|||||||
@ccclass('TooltipCom')
|
@ccclass('TooltipCom')
|
||||||
@ecs.register('TooltipView', false)
|
@ecs.register('TooltipView', false)
|
||||||
export class TooltipCom extends CCComp {
|
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:技能图标
|
stype: number = 1; // 1:减少生命值,2:增加生命值,3:技能图标
|
||||||
value: string = "";
|
value: string = "";
|
||||||
s_uuid: number = 1001;
|
s_uuid: number = 1001;
|
||||||
fac: number = FacSet.MON;
|
fac: number = FacSet.MON;
|
||||||
/** 当前技能喊话对应的触发类型(空字符串表示普通主动技能) */
|
|
||||||
triggerType: string = "";
|
|
||||||
/** DoT 飘字需激活的 debuff 图标节点名(loss_life/hp/debuff 下的子节点,如 FireDamage);空串=普通伤害 */
|
/** DoT 飘字需激活的 debuff 图标节点名(loss_life/hp/debuff 下的子节点,如 FireDamage);空串=普通伤害 */
|
||||||
debuffIcon: string = "";
|
debuffIcon: string = "";
|
||||||
|
|
||||||
@@ -45,12 +31,11 @@ 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 = "") {
|
||||||
this.stype = type;
|
this.stype = type;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.s_uuid = uuid;
|
this.s_uuid = uuid;
|
||||||
this.fac = fac;
|
this.fac = fac;
|
||||||
this.triggerType = triggerType;
|
|
||||||
this.debuffIcon = debuffIcon;
|
this.debuffIcon = debuffIcon;
|
||||||
|
|
||||||
// 初始化或获取 UIOpacity 组件
|
// 初始化或获取 UIOpacity 组件
|
||||||
@@ -126,8 +111,6 @@ export class TooltipCom extends CCComp {
|
|||||||
// 技能喊话基于 load 传入位置再抬高 50,避免遮挡角色
|
// 技能喊话基于 load 传入位置再抬高 50,避免遮挡角色
|
||||||
this.node.setPosition(v3(this.node.position.x, this.node.position.y + 50));
|
this.node.setPosition(v3(this.node.position.x, this.node.position.y + 50));
|
||||||
this.node.setSiblingIndex(topSiblingIndex);
|
this.node.setSiblingIndex(topSiblingIndex);
|
||||||
// 根据触发类型激活对应的背景标识(追击/反击/起手/生息/亡语/复活)
|
|
||||||
this.setupTriggerBg(this.triggerType);
|
|
||||||
break;
|
break;
|
||||||
case TooltipTypes.uskill:
|
case TooltipTypes.uskill:
|
||||||
this.setupLabel("uskill", "name", this.value);
|
this.setupLabel("uskill", "name", this.value);
|
||||||
@@ -189,32 +172,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) {
|
playAnimation(scaleMax: number, isCrit: boolean, isHeal: boolean, sx: number = 1) {
|
||||||
// 随机 X 轴偏移 (防止重叠)
|
// 随机 X 轴偏移 (防止重叠)
|
||||||
const randomX = (Math.random() - 0.5) * 60;
|
const randomX = (Math.random() - 0.5) * 60;
|
||||||
|
|||||||
Reference in New Issue
Block a user