fix(map): 修复任务奖励图标加载问题并重构组件逻辑
- 移除 MGetsComp 中未使用的属性和方法,简化组件结构 - 在 MissionGetsComp 中实现动态加载奖励图标功能,支持从 gui/uicons 图集获取 - 调整 get.prefab 结构,分离图标和数字显示节点 - 解决资源加载机制限制,确保动态加载资源正常工作
This commit is contained in:
@@ -11,24 +11,17 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('MGetsCompComp')
|
||||
@ecs.register('MGetsComp', false)
|
||||
export class MGetsCompComp extends CCComp {
|
||||
get:any = {};
|
||||
get_uuid:number=0;
|
||||
get_num:number=0;
|
||||
start() {
|
||||
oops.message.on(GameEvent.UpdateCollection, this.updateView, this);
|
||||
this.updateView();
|
||||
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
oops.message.off(GameEvent.UpdateCollection, this.updateView, this);
|
||||
}
|
||||
|
||||
private updateView() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
private updateNodeNum(node: Node, num: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Node, Label } from "cc";
|
||||
import { _decorator, Node, Label, PrefabLink, instantiate, Prefab, SpriteAtlas, Sprite, 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";
|
||||
@@ -11,7 +11,10 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('MissionGetsCompComp')
|
||||
@ecs.register('MissionGetsComp', false)
|
||||
export class MissionGetsCompComp extends CCComp {
|
||||
|
||||
get_datas:any={};
|
||||
get_nodes:Node[]=[];
|
||||
// 图标图集缓存
|
||||
private uiconsAtlas: SpriteAtlas | null = null;
|
||||
start() {
|
||||
|
||||
}
|
||||
@@ -19,27 +22,39 @@ export class MissionGetsCompComp extends CCComp {
|
||||
onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
load_hui(uuid:number, pos_index: number){
|
||||
var path = "game/gui/get";
|
||||
|
||||
}
|
||||
load_hui(uuid:string){
|
||||
var path = "game/gui/get";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
// 将节点添加到父节点下
|
||||
this.node.addChild(node);
|
||||
node.getChildByName("num").getComponent(Label).string = "1";
|
||||
const sprite = node.getChildByName("icon").getComponent(Sprite);
|
||||
if (!sprite) return;
|
||||
|
||||
if (this.uiconsAtlas) {
|
||||
const frame = this.uiconsAtlas.getSpriteFrame(uuid);
|
||||
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(uuid);
|
||||
if (frame) {
|
||||
sprite.spriteFrame = frame;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private updateNodeNum(node: Node, num: number) {
|
||||
if (!node) return;
|
||||
// Try to find Label on the node itself
|
||||
let label = node.getComponent(Label);
|
||||
// If not found, try to find a child named "num" with Label
|
||||
if (!label) {
|
||||
const numNode = node.getChildByName("num");
|
||||
if (numNode) {
|
||||
label = numNode.getComponent(Label);
|
||||
}
|
||||
}
|
||||
|
||||
if (label) {
|
||||
label.string = num > 0 ? num.toString() : "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
@@ -100,6 +100,16 @@
|
||||
- 现状:resetCD 里按 AS/SS 计算了 cd,但随后又把 cd 覆盖回 cd_max。
|
||||
- 风险:攻速/技速体系失效,强化与天赋相关数值无法体现。
|
||||
|
||||
14. [问题] 资源加载机制限制:gui 目录资源无法直接获取
|
||||
|
||||
- 位置:assets/script/game/map/HInfoComp.ts 及资源目录
|
||||
- 现状:`oops.res.get` 仅能获取已预加载的资源。当前初始化流程(LoadingViewComp)仅预加载了 `game` 目录,导致 `gui` 目录下的资源无法通过代码动态获取。
|
||||
- 影响:设计师无法随意引用 `gui` 下的资源,限制了界面开发的灵活性。
|
||||
- 建议方案:
|
||||
1. 规范:将所有动态加载的资源统一放入 `assets/resources/game` 目录下(推荐)。
|
||||
2. 扩展:在 LoadingViewComp 中增加 `gui` 目录的预加载(需评估内存和启动时间)。
|
||||
- 风险:攻速/技速体系失效,强化与天赋相关数值无法体现。
|
||||
|
||||
14. [严重问题] 计数型天赋 key 与属性枚举不一致,导致天赋效果读取失败
|
||||
|
||||
- 位置:assets/script/game/hero/TalComp.ts + assets/script/game/hero/HeroAtkSystem.ts
|
||||
|
||||
Reference in New Issue
Block a user