import { _decorator,Button,EventHandler,EventTouch,instantiate,Label,NodeEventType,Prefab,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 { HeroList } from "../common/config/heroSet"; import { HeroCard } from "../hero/HeroCard"; import { smc } from "../common/SingletonModuleComp"; import { UIID } from "../common/config/GameUIConfig"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { Items } from "../common/config/Items"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('HeroHomeComp') @ecs.register('HeroHome', false) export class HeroHomeComp extends CCComp { h_uuid:number=0 protected onLoad(): void { } start() { // this.load_talents() console.log("hero_home start") this.h_uuid=9001 this.hero_show(this.h_uuid) this.loads() } loads(){ let heros:any=HeroList let hc:number =HeroList.length console.log("hero_home heros:",heros,hc) let parent= this.node.getChildByName("heros").getChildByName("view").getChildByName("content") parent.getComponent(UITransform).width=hc*150 console.log("parent:",parent) for (let i = 0; i < hc; i++) { let hcc =ecs.getEntity(HeroCard) hcc.load(HeroList[i],parent) } } hero_show(uuid:number) { console.log("hero_home hero_show:",uuid) let lv = smc.vmdata.heros[uuid].lv let slv = smc.vmdata.heros[uuid].slv let hero =smc.heros[uuid] this.h_uuid=uuid var icon_path = "game/heros/herois" resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { const sprite = this.node.getChildByName("hero").getChildByName("icon").getComponent(Sprite); sprite.spriteFrame = atlas.getSpriteFrame(hero.path); }); this.node.getChildByName("name").getChildByName("value").getComponent(Label).string=hero.name this.node.getChildByName("hero").getChildByName("lv").getComponent(Label).string = lv.toString()+"级"; let slv_node=this.node.getChildByName("hero").getChildByName("slv"); if(slv>=1) {slv_node.getChildByName("s1").active=true}else{slv_node.getChildByName("s1").active=false}; if(slv>=2) {slv_node.getChildByName("s2").active=true}else{slv_node.getChildByName("s2").active=false}; if(slv>=3) {slv_node.getChildByName("s3").active=true}else{slv_node.getChildByName("s3").active=false}; if(slv>=4) {slv_node.getChildByName("s4").active=true}else{slv_node.getChildByName("s4").active=false}; if(slv>=5) {slv_node.getChildByName("s5").active=true}else{slv_node.getChildByName("s5").active=false}; this.node.getChildByName("attr").getChildByName("ap").getChildByName("val").getComponent(Label).string = hero.ap+hero.ap_up*lv this.node.getChildByName("attr").getChildByName("hp").getChildByName("val").getComponent(Label).string = hero.hp+hero.hp_up*lv this.node.getChildByName("attr").getChildByName("def").getChildByName("val").getComponent(Label).string = hero.ap+hero.ap_up*lv this.node.getChildByName("attr").getChildByName("acd").getChildByName("val").getComponent(Label).string = hero.a_cd this.node.getChildByName("attr").getChildByName("speed").getChildByName("val").getComponent(Label).string = hero.speed this.node.getChildByName("attr").getChildByName("dis").getChildByName("val").getComponent(Label).string = hero.dis } lv_up(){ console.log("lvup h_uuid:",this.h_uuid) } slv_up(){ console.log("lvup slv_up:",this.h_uuid) } item_show(e:any,val:any){ oops.gui.open(UIID.ItemInfo, Items[val]); } reset() { this.node.destroy(); } }