import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,ProgressBar,resources,Sprite,SpriteAtlas,UITransform,v3 } 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 { smc } from "../common/SingletonModuleComp"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager"; import { HeroModelComp } from "../hero/HeroModelComp"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('HCardComp') @ecs.register('HCardComp', false) export class HCardComp extends CCComp { hi: number = 0; heros:any = [] icon:any=[] hc_name:any=[] ap:any=[] hp:any=[] life:any=[] protected onLoad(): void { } start() { this.heros= ecs.query(ecs.allOf(HeroModelComp)); this.hc_name=this.node.getChildByName("name").getComponent(Label)! this.icon=this.node.getChildByName("icon").getComponent(Sprite)! this.hp=this.node.getChildByName("hp").getChildByName("num").getComponent(Label)! this.ap=this.node.getChildByName("ap").getChildByName("num").getComponent(Label)! this.life=this.node.getChildByName("life").getComponent(ProgressBar)! this.hc_name.string= this.heros[this.hi].HeroView.hero_name console.log("hcard start") } protected update(dt: number): void { this.hp.string=this.heros[this.hi].HeroView.hp_max this.ap.string=this.heros[this.hi].HeroView.ap this.life.progress=this.heros[this.hi].HeroView.hp/this.heros[this.hi].HeroView.hp_max } /** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { console.log("hcard reset"); this.node.destroy(); } }