feat(map): 新增可动态加载的收集物UI组件

- 添加 MGetComp 组件用于管理单个收集物的显示逻辑
- 创建 get.prefab 预制体作为收集物UI模板
- 重构 MissionGetsComp,移除硬编码节点引用,改为动态加载
- 支持通过 load_hui 方法按需加载收集物UI实例
This commit is contained in:
panw
2026-01-27 15:44:48 +08:00
parent b392ebe272
commit ce6b7bce1e
6 changed files with 2422 additions and 2954 deletions

View File

@@ -1,7 +1,7 @@
[
{
"__type__": "cc.Prefab",
"_name": "icon",
"_name": "get",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
@@ -13,7 +13,7 @@
},
{
"__type__": "cc.Node",
"_name": "icon",
"_name": "get",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
@@ -41,10 +41,13 @@
},
{
"__id__": 36
},
{
"__id__": 39
}
],
"_prefab": {
"__id__": 39
"__id__": 41
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -900,6 +903,24 @@
"handler": "",
"customEventData": ""
},
{
"__type__": "7ddd1IfGRhO7a2b66ov5bYG",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 40
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "c89eW5WlxFUokvJRFAfrSA"
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@@ -8,6 +8,6 @@
],
"subMetas": {},
"userData": {
"syncNodeName": "icon"
"syncNodeName": "get"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
import { _decorator, Node, Label } 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";
import { GameEvent } from "../common/config/GameEvent";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MGetsCompComp')
@ecs.register('MGetsComp', false)
export class MGetsCompComp extends CCComp {
get:any = {};
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() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "7ddd121f-1918-4eed-ad9b-ebaa2fe5b606",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -11,53 +11,19 @@ const { ccclass, property } = _decorator;
@ccclass('MissionGetsCompComp')
@ecs.register('MissionGetsComp', false)
export class MissionGetsCompComp extends CCComp {
@property(Node)
get0:Node = null!
@property(Node)
get1:Node = null!
@property(Node)
get2:Node = null!
@property(Node)
get3:Node = null!
@property(Node)
get4:Node = null!
@property(Node)
get5:Node = null!
start() {
oops.message.on(GameEvent.UpdateCollection, this.updateView, this);
this.updateView();
}
onDestroy() {
oops.message.off(GameEvent.UpdateCollection, this.updateView, this);
}
private updateView() {
if (!smc.vmdata || !smc.vmdata.collection) return;
const data = smc.vmdata.collection;
// Talents (get0 - get3)
const talentIds = Object.keys(data.talents);
const talentNodes = [this.get0, this.get1, this.get2, this.get3];
for (let i = 0; i < talentNodes.length; i++) {
const node = talentNodes[i];
if (i < talentIds.length) {
const id = Number(talentIds[i]); // Object.keys returns strings
const count = data.talents[id];
this.updateNodeNum(node, count);
} else {
this.updateNodeNum(node, 0);
}
}
// Skill (get4)
this.updateNodeNum(this.get4, data.skill.count);
// Friend (get5)
this.updateNodeNum(this.get5, data.friend.count);
}
load_hui(uuid:number, pos_index: number){
var path = "game/gui/get";
}
private updateNodeNum(node: Node, num: number) {
if (!node) return;