54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { _decorator, 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 { Talents } from "../common/config/TalentSet";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/** 视图层对象 */
|
|
@ccclass('TalentComp')
|
|
@ecs.register('TalentView', false)
|
|
export class TalentComp extends CCComp {
|
|
t_uuid:number = 0;
|
|
/** 视图层逻辑代码分离演示 */
|
|
start() {
|
|
let name =this.node.getChildByName("name")
|
|
let info =this.node.getChildByName("info")
|
|
let icon =this.node.getChildByName("icon")
|
|
let cost =this.node.getChildByName("cost")
|
|
let lv =this.node.getChildByName("lv")
|
|
let talent= Talents[this.t_uuid]
|
|
let role_talents = smc.vmdata.talent[talent.uuid]
|
|
cost.getComponent(Label).string = (talent.cost*(1+role_talents.lv)).toString()
|
|
name.getComponent(Label).string = talent.name
|
|
info.getComponent(Label).string = talent.info
|
|
lv.getComponent(Label).string = role_talents.lv.toString()
|
|
if (talent.type == 1){
|
|
this.node.getChildByName("role").active=true
|
|
}
|
|
|
|
if (talent.type == 2){
|
|
this.node.getChildByName("hero").active=true
|
|
}
|
|
|
|
if (talent.type == 3){
|
|
this.node.getChildByName("mission").active=true
|
|
}
|
|
}
|
|
to_update_t(){
|
|
console.log("to_update_t",this.t_uuid)
|
|
}
|
|
/** 全局消息逻辑处理 */
|
|
// private onHandler(event: string, args: any) {
|
|
// switch (event) {
|
|
// case ModuleEvent.Cmd:
|
|
// break;
|
|
// }
|
|
// }
|
|
|
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
this.node.destroy();
|
|
}
|
|
} |