Files
pixelheros/assets/script/game/map/MissionGetsComp.ts
panw ce6b7bce1e feat(map): 新增可动态加载的收集物UI组件
- 添加 MGetComp 组件用于管理单个收集物的显示逻辑
- 创建 get.prefab 预制体作为收集物UI模板
- 重构 MissionGetsComp,移除硬编码节点引用,改为动态加载
- 支持通过 load_hui 方法按需加载收集物UI实例
2026-01-27 15:44:48 +08:00

50 lines
1.4 KiB
TypeScript

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('MissionGetsCompComp')
@ecs.register('MissionGetsComp', false)
export class MissionGetsCompComp extends CCComp {
start() {
}
onDestroy() {
}
load_hui(uuid:number, pos_index: number){
var path = "game/gui/get";
}
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) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}