feat(ui): 添加任务卡片图标支持并更新配置图标引用

添加任务卡片组件图标显示功能,支持动态加载图集资源
更新属性卡和英雄配置中的图标引用为新的资源ID
This commit is contained in:
panw
2026-01-16 11:05:14 +08:00
parent 5bb3acf385
commit 5af936d9b3
3 changed files with 76 additions and 31 deletions

View File

@@ -11,20 +11,20 @@ import { Attrs } from "./HeroAttrs";
note?: string;// 属性备注
}
export const AttrCards: Record<number, AttrInfo> = {
2001:{uuid:2001, icon:"2001", attr: Attrs.AP, value: 16.5, showValue: 16.5, desc: "攻击力 +16.5", isSpecial: false, note: "常规强化" },
2002:{uuid:2002, icon:"2001", attr: Attrs.HP_MAX, value: 110, showValue: 110, desc: "生命上限 +110", isSpecial: false, note: "常规强化" },
2003:{uuid:2003, icon:"2001", attr: Attrs.DEF, value: 5.5, showValue: 5.5, desc: "防御力 +5.5", isSpecial: false, note: "常规强化" },
2004:{uuid:2004, icon:"2001", attr: Attrs.AS, value: 5.25, showValue: 5.25, desc: "攻击速度 +5.25%", isSpecial: false, note: "常规强化" },
2005:{uuid:2005, icon:"2001", attr: Attrs.PUNCTURE, value: 1, showValue: 1, desc: "穿透数量 +1", isSpecial: true, note: "上限5层" },
2006:{uuid:2006, icon:"2001", attr: Attrs.CRITICAL, value: 14, showValue: 14, desc: "暴击率 +14%", isSpecial: true, note: "上限70%" },
2007:{uuid:2007, icon:"2001", attr: Attrs.CRITICAL_DMG, value: 40, showValue: 40, desc: "暴击伤害 +40%", isSpecial: true, note: "上限200%" },
2008:{uuid:2008, icon:"2001", attr: Attrs.STUN_CHANCE, value: 10, showValue: 10, desc: "眩晕概率 +10%", isSpecial: true, note: "上限50%" },
2009:{uuid:2009, icon:"2001", attr: Attrs.FREEZE_CHANCE, value: 10, showValue: 10, desc: "冰冻概率 +10%", isSpecial: true, note: "上限50%" },
2010:{uuid:2010, icon:"2001", attr: Attrs.BURN_CHANCE, value: 10, showValue: 10, desc: "燃烧概率 +10%", isSpecial: true, note: "上限50%" },
2011:{uuid:2011, icon:"2001", attr: Attrs.BACK_CHANCE, value: 10, showValue: 10, desc: "击退概率 +10%", isSpecial: true, note: "上限50%" },
2012:{uuid:2012, icon:"2001", attr: Attrs.SLOW_CHANCE, value: 10, showValue: 10, desc: "减速概率 +10%", isSpecial: true, note: "上限50%" },
2013:{uuid:2013, icon:"2001", attr: Attrs.LIFESTEAL, value: 10, showValue: 10, desc: "吸血比例 +10%", isSpecial: true, note: "上限50%" },
2014:{uuid:2014, icon:"2001", attr: Attrs.MANASTEAL, value: 10, showValue: 10, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
2001:{uuid:2001, icon:"1020", attr: Attrs.AP, value: 16.5, showValue: 16.5, desc: "攻击力 +16.5", isSpecial: false, note: "常规强化" },
2002:{uuid:2002, icon:"1020", attr: Attrs.HP_MAX, value: 110, showValue: 110, desc: "生命上限 +110", isSpecial: false, note: "常规强化" },
2003:{uuid:2003, icon:"1020", attr: Attrs.DEF, value: 5.5, showValue: 5.5, desc: "防御力 +5.5", isSpecial: false, note: "常规强化" },
2004:{uuid:2004, icon:"1020", attr: Attrs.AS, value: 5.25, showValue: 5.25, desc: "攻击速度 +5.25%", isSpecial: false, note: "常规强化" },
2005:{uuid:2005, icon:"1020", attr: Attrs.PUNCTURE, value: 1, showValue: 1, desc: "穿透数量 +1", isSpecial: true, note: "上限5层" },
2006:{uuid:2006, icon:"1020", attr: Attrs.CRITICAL, value: 14, showValue: 14, desc: "暴击率 +14%", isSpecial: true, note: "上限70%" },
2007:{uuid:2007, icon:"1020", attr: Attrs.CRITICAL_DMG, value: 40, showValue: 40, desc: "暴击伤害 +40%", isSpecial: true, note: "上限200%" },
2008:{uuid:2008, icon:"1020", attr: Attrs.STUN_CHANCE, value: 10, showValue: 10, desc: "眩晕概率 +10%", isSpecial: true, note: "上限50%" },
2009:{uuid:2009, icon:"1020", attr: Attrs.FREEZE_CHANCE, value: 10, showValue: 10, desc: "冰冻概率 +10%", isSpecial: true, note: "上限50%" },
2010:{uuid:2010, icon:"1020", attr: Attrs.BURN_CHANCE, value: 10, showValue: 10, desc: "燃烧概率 +10%", isSpecial: true, note: "上限50%" },
2011:{uuid:2011, icon:"1020", attr: Attrs.BACK_CHANCE, value: 10, showValue: 10, desc: "击退概率 +10%", isSpecial: true, note: "上限50%" },
2012:{uuid:2012, icon:"1020", attr: Attrs.SLOW_CHANCE, value: 10, showValue: 10, desc: "减速概率 +10%", isSpecial: true, note: "上限50%" },
2013:{uuid:2013, icon:"1020", attr: Attrs.LIFESTEAL, value: 10, showValue: 10, desc: "吸血比例 +10%", isSpecial: true, note: "上限50%" },
2014:{uuid:2014, icon:"1020", attr: Attrs.MANASTEAL, value: 10, showValue: 10, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
}
export const CanSelectAttrs: Record<number, number[]> = {

View File

@@ -137,37 +137,37 @@ export const CanSelectHeros: Record<number, number[]> = {
export const HeroInfo: Record<number, heroInfo> = {
// ========== 英雄角色 ==========
5001:{uuid:5001,name:"盾战士",icon:"4001",path:"hk1", fac:FacSet.HERO, kind:1,as:1.5,
5001:{uuid:5001,name:"盾战士",icon:"1001",path:"hk1", fac:FacSet.HERO, kind:1,as:1.5,
type:HType.warrior,lv:1,hp:200,mp:200,def:0,ap:15,speed:120,skills:[6001,6004],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"盾战士"},
5002:{uuid:5002,name:"奥术法师",icon:"4001",path:"hm2", fac:FacSet.HERO, kind:2,as:1.5,
5002:{uuid:5002,name:"奥术法师",icon:"1001",path:"hm2", fac:FacSet.HERO, kind:2,as:1.5,
type:HType.mage,lv:1,hp:92,mp:135,def:0,ap:14,speed:95,skills:[6003,6101],
rangeType: SkillRange.Long,
buff:[],tal:[],info:"奥术法师"},
5003:{uuid:5003,name:"射手",icon:"4001",path:"ha1", fac:FacSet.HERO, kind:2,as:1.5,
5003:{uuid:5003,name:"射手",icon:"1001",path:"ha1", fac:FacSet.HERO, kind:2,as:1.5,
type:HType.remote,lv:1,hp:100,mp:80,def:0,ap:18,speed:140,skills:[6002,6100],
rangeType: SkillRange.Long,
buff:[],tal:[],info:"射手"},
5005:{uuid:5005,name:"牧师",icon:"4001",path:"hh1", fac:FacSet.HERO, kind:2,as:1.5,
5005:{uuid:5005,name:"牧师",icon:"1001",path:"hh1", fac:FacSet.HERO, kind:2,as:1.5,
type:HType.mage,lv:1,hp:88,mp:135,def:0,ap:15,speed:100,skills:[6003,6100],
rangeType: SkillRange.Mid,
buff:[],tal:[],info:"牧师"},
5004:{uuid:5004,name:"火焰法师",icon:"4001",path:"hm1", fac:FacSet.HERO, kind:2,as:1.5,
5004:{uuid:5004,name:"火焰法师",icon:"1001",path:"hm1", fac:FacSet.HERO, kind:2,as:1.5,
type:HType.mage,lv:1,hp:85,mp:140,def:0,ap:16,speed:90,skills:[6003,6101],
rangeType: SkillRange.Mid,
buff:[],tal:[],info:"火焰法师"},
5006:{uuid:5006,name:"召唤法师",icon:"4001",path:"hz1", fac:FacSet.HERO, kind:2,as:1.5,
5006:{uuid:5006,name:"召唤法师",icon:"1001",path:"hz1", fac:FacSet.HERO, kind:2,as:1.5,
type:HType.support,lv:1,hp:115,mp:145,def:0,ap:8,speed:105,skills:[6003,6101],
rangeType: SkillRange.Mid,
buff:[],tal:[],info:"召唤法师"},
5007:{uuid:5007,name:"刺客",icon:"4001",path:"hc1", fac:FacSet.HERO, kind:1,as:1.5,
5007:{uuid:5007,name:"刺客",icon:"1001",path:"hc1", fac:FacSet.HERO, kind:1,as:1.5,
type:HType.assassin,lv:1,hp:80,mp:60,def:0,ap:22,speed:180,skills:[6001,6004],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"刺客"},
@@ -176,50 +176,50 @@ export const HeroInfo: Record<number, heroInfo> = {
// 1. 基础近战型
5201:{uuid:5201,name:"兽人战士",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
5201:{uuid:5201,name:"兽人战士",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
type:HType.warrior,lv:1,hp:40,mp:100,def:0,ap:5,speed:180,skills:[6001],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"标准炮灰确保英雄能完成3次普攻积累天赋计数"},
// 2. 快速突击型
5301:{uuid:5301,name:"兽人斥候",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:1.2,
5301:{uuid:5301,name:"兽人斥候",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:1.2,
type:HType.assassin,lv:1,hp:30,mp:100,def:0,ap:12,speed:400,skills:[6001],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"快速突击:极高移速贴脸,检测护盾(7102)刷新率"},
// 3. 重型坦克型
5401:{uuid:5401,name:"兽人卫士",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:5.0,
5401:{uuid:5401,name:"兽人卫士",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:5.0,
type:HType.warrior,lv:1,hp:400,mp:100,def:5,ap:25,speed:60,skills:[6001],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"重型坦克:数值墙,检测玩家破甲(7008)与持续输出"},
// 4. 远程骚扰型
5501:{uuid:5501,name:"兽人射手",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
5501:{uuid:5501,name:"兽人射手",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
type:HType.remote,lv:1,hp:50,mp:100,def:0,ap:15,speed:90,skills:[6203],
rangeType: SkillRange.Long,
buff:[],tal:[],info:"远程骚扰:跨屏打击,迫使阵地分散或移动英雄"},
// 5. 特殊机制型
5601:{uuid:5601,name:"兽人自爆兵",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
5601:{uuid:5601,name:"兽人自爆兵",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
type:HType.assassin,lv:1,hp:60,mp:100,def:0,ap:250,speed:220,skills:[6001],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"特殊机制:极端伤害,漏怪即秒杀,检测减伤(7103)"},
// 召唤师:持续召唤小怪(后续可在技能系统中实现 SType.zhaohuan
5602:{uuid:5602,name:"兽人召唤师",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
5602:{uuid:5602,name:"兽人召唤师",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
type:HType.mage,lv:1,hp:120,mp:300,def:5,ap:8,speed:100,skills:[6001],
rangeType: SkillRange.Mid,
buff:[],tal:[],info:"战术目标:持续召唤小怪,检测英雄大招清场频率"},
// 治疗者:为周围怪物回血(此处以提升治疗效果和生命回复为基础被动)
5603:{uuid:5603,name:"兽人祭司",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
5603:{uuid:5603,name:"兽人祭司",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
type:HType.support,lv:1,hp:120,mp:300,def:5,ap:6,speed:105,skills:[6001],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"战术目标:为怪群回血,检测玩家沉默(7006)覆盖率"},
// 光环怪为周围怪物提供增益此处以Buff效果提升与移动速度提升为基础被动
// Attrs.BUFF_UP=60 (RATIO=1)Attrs.SPEED=63 (RATIO=1)
5604:{uuid:5604,name:"兽人图腾师",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
5604:{uuid:5604,name:"兽人图腾师",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
type:HType.support,lv:1,hp:100,mp:250,def:5,ap:7,speed:110,skills:[6001],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"战术目标:提供加速光环,改变怪群推进节奏"},
// 6. 精英/BOSS型
5701:{uuid:5701,name:"兽人首领(BOSS)",icon:"4001",path:"mo1", fac:FacSet.MON, kind:1,as:2.5,
5701:{uuid:5701,name:"兽人首领(BOSS)",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:2.5,
type:HType.warrior,lv:3,hp:25000,mp:500,def:20,ap:80,speed:120,skills:[6001],
rangeType: SkillRange.Melee,
buff:[],tal:[],info:"终极考验极高HP检测大招重置与辐射协同输出"},

View File

@@ -1,4 +1,4 @@
import { _decorator, Label, Node, tween, Vec3, Color, Sprite, Tween } from "cc";
import { _decorator, Label, Node, tween, Vec3, Color, Sprite, Tween, SpriteAtlas, resources } 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
@@ -50,6 +50,9 @@ export class MissionCardComp extends CCComp {
private isLocked: boolean = true;
// 是否永久解锁(本局)
private isAdUnlocked: boolean = false;
// 图标图集缓存
private uiconsAtlas: SpriteAtlas | null = null;
onLoad() {
if (this.btnClose) {
@@ -360,6 +363,48 @@ export class MissionCardComp extends CCComp {
if (activeTypeNode) activeTypeNode.active = true;
}
}
// 更新图标 (如果存在 icon 节点)
// 注意:根据 Prefab 分析icon 可能在 card/Mask/icon 路径下,也可能在各个分类节点下
// 这里尝试统一查找 icon 节点
let iconNode: Node | null = null;
// 1. 尝试查找通用的 mask/icon (根据之前 card.prefab 分析,有个 Mask/icon 节点)
const maskNode = card.getChildByName("Mask");
if (maskNode) {
iconNode = maskNode.getChildByName("icon");
}
if (iconNode && data.icon) {
this.updateIcon(iconNode, data.icon);
}
}
private updateIcon(node: Node, iconId: string) {
if (!node || !iconId) return;
const sprite = node.getComponent(Sprite);
if (!sprite) return;
if (this.uiconsAtlas) {
const frame = this.uiconsAtlas.getSpriteFrame(iconId);
if (frame) {
sprite.spriteFrame = frame;
}
} else {
// 加载图集
resources.load("gui/uicons", SpriteAtlas, (err, atlas) => {
if (err) {
console.error("[MissionCardComp] Failed to load uicons atlas", err);
return;
}
this.uiconsAtlas = atlas;
const frame = atlas.getSpriteFrame(iconId);
if (frame) {
sprite.spriteFrame = frame;
}
});
}
}
updateCardData(index: number, data: ICardInfo) {