feat(map): 新增任务卡片组件及UI布局
添加 MissionCardComp.ts 组件用于处理任务卡片逻辑 在 card.prefab 中新增名称标签及相关UI组件 组件支持卡片数据更新和显示控制
This commit is contained in:
76
assets/script/game/map/MissionCardComp.ts
Normal file
76
assets/script/game/map/MissionCardComp.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { _decorator, Label, Node } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('ModuleViewComp')
|
||||
@ecs.register('ModuleView', false)
|
||||
export class ModuleViewComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
@property(Node)
|
||||
card1:Node = null
|
||||
@property(Node)
|
||||
card2:Node = null
|
||||
@property(Node)
|
||||
card3:Node = null
|
||||
@property(Node)
|
||||
card4:Node = null
|
||||
|
||||
card1_data:any = {}
|
||||
card2_data:any = {}
|
||||
card3_data:any = {}
|
||||
card4_data:any = {}
|
||||
start() {
|
||||
this.card1.active=true
|
||||
this.card2.active=true
|
||||
this.card3.active=true
|
||||
this.card4.active=true
|
||||
}
|
||||
refCards(){
|
||||
|
||||
}
|
||||
updateCardInfo(card:Node,data:any){
|
||||
if(!card) return
|
||||
let name = card.getChildByName("name")
|
||||
if(name){
|
||||
name.getComponent(Label).string = data.name
|
||||
}
|
||||
let info = card.getChildByName("info").getChildByName("Label")
|
||||
if(info){
|
||||
info.getComponent(Label).string = data.info
|
||||
}
|
||||
}
|
||||
updateCardData(index:number,data:any){
|
||||
switch (index) {
|
||||
case 1:
|
||||
this.card1_data = data
|
||||
break;
|
||||
case 2:
|
||||
this.card2_data = data
|
||||
break;
|
||||
case 3:
|
||||
this.card3_data = data
|
||||
break;
|
||||
case 4:
|
||||
this.card4_data = data
|
||||
break;
|
||||
}
|
||||
}
|
||||
selectCard(index:number){
|
||||
|
||||
}
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/map/MissionCardComp.ts.meta
Normal file
9
assets/script/game/map/MissionCardComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b3d6e490-f2e9-4f3f-bf64-3e93c8cada94",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user