refactor(SSkillBoxComp): 新增英雄配置语境下的技能名称解析
新增resolveHeroSkillName方法,实现英雄图鉴模式下的技能名称智能解析,优先从英雄配置中获取技能展示名,未命中时回退原有逻辑。
This commit is contained in:
@@ -4,7 +4,10 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { CardTriggerType } from "../common/config/CardSet";
|
||||
import { SkillSet, FieldSkillSet } from "../common/config/SkillSet";
|
||||
import { FieldEntry } from "../common/config/heroSet";
|
||||
import {
|
||||
FieldEntry, HeroInfo, TriggerGrouped, SkillTriggerType,
|
||||
getGroupedTriggerName, getFieldSkillName, getReviveSkillName,
|
||||
} from "../common/config/heroSet";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -149,10 +152,17 @@ export class SSkillBoxComp extends CCComp {
|
||||
|
||||
/**
|
||||
* 解析技能名称:
|
||||
* 优先取显式设置的卡牌名;否则按图标来源从 SkillSet / FieldSkillSet 取技能名。
|
||||
* 1. 显式设置的卡牌名(最高优先级);
|
||||
* 2. 英雄图鉴模式(hero_uuid>0):从 heroSet 英雄配置解析英雄语境名
|
||||
* (普攻/大招 HSkillInfo.name、trigger 组名、光环 FieldEntry.name、复活 LvReviveEntry.name);
|
||||
* 3. 回退 SkillSet / FieldSkillSet 底座名。
|
||||
*/
|
||||
private resolveSkillName(): string {
|
||||
if (this.skill_name) return this.skill_name;
|
||||
if (this.hero_uuid > 0) {
|
||||
const heroName = this.resolveHeroSkillName();
|
||||
if (heroName) return heroName;
|
||||
}
|
||||
if (this.hero_icon_source === "field") {
|
||||
return this.s_uuid ? (FieldSkillSet[this.s_uuid]?.name ?? "") : "";
|
||||
}
|
||||
@@ -169,6 +179,33 @@ export class SSkillBoxComp extends CCComp {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 英雄图鉴模式:按技能 uuid 在英雄配置中定位,取英雄语境展示名。
|
||||
* 覆盖普攻/大招(skills)、5 类触发技能、驻场光环(field)、复活(revive)。
|
||||
* 未命中返回空串,由调用方回退底座名。
|
||||
*/
|
||||
private resolveHeroSkillName(): string {
|
||||
const hero = HeroInfo[this.hero_uuid];
|
||||
if (!hero) return "";
|
||||
// 普攻/大招
|
||||
const hSkill = hero.skills?.[this.s_uuid];
|
||||
if (hSkill?.name) return hSkill.name;
|
||||
// 触发技能组(call/dead/fstart/atking/atked)
|
||||
for (const type of [SkillTriggerType.Call, SkillTriggerType.Dead, SkillTriggerType.FStart, SkillTriggerType.Atking, SkillTriggerType.Atked]) {
|
||||
const grouped = hero[type] as TriggerGrouped | undefined;
|
||||
if (grouped?.[this.s_uuid]?.length) return getGroupedTriggerName(grouped, this.s_uuid);
|
||||
}
|
||||
// 驻场光环词条
|
||||
if (hero.field?.some(e => e.uuids.some(u => u.uuid === this.s_uuid))) {
|
||||
return getFieldSkillName(hero, this.s_uuid);
|
||||
}
|
||||
// 复活技能
|
||||
if (hero.revive?.some(e => e.s_uuid === this.s_uuid)) {
|
||||
return getReviveSkillName(hero, this.s_uuid);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 UI:
|
||||
* - 背景:根据技能等级切换对应颜色子节点显示
|
||||
|
||||
Reference in New Issue
Block a user