import { _decorator,Button,color,EventHandler,EventTouch,instantiate,Label,NodeEventType,Prefab,ProgressBar,resources,Sprite,SpriteAtlas,tween,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 { HeroInfo, HeroList } from "../common/config/heroSet"; import { smc } from "../common/SingletonModuleComp"; import { UIID } from "../common/config/GameUIConfig"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { SkillSet } from "../common/config/SkillSet"; import { getUpChipByLv, getUpGoldByRange, LvUp, SlvUp, UpGold } from "../common/config/RoleSet"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('HeroHomeComp') @ecs.register('HeroHome', false) export class HeroHomeComp extends CCComp { h_uuid:number=0 role:any=null hero:any=null gold_need:number=9999 chip_need:number=9999 slv:number=0 protected onLoad(): void { } start() { // this.load_talents() console.log("hero_home start") // this.h_uuid=5001 // this.hero_show(this.h_uuid) this.loads() this.node.getChildByName("show").active=false } loads(){ let hc:number =HeroList.length let parent= this.node.getChildByName("heros").getChildByName("view").getChildByName("content") parent.getComponent(UITransform).setContentSize(hc*185,230) // console.log("hc",hc,parent.getComponent(UITransform)) console.log("parent",parent) } hero_show(uuid:number) { this.node.getChildByName("show").active=true this.h_uuid=uuid this.hero=HeroInfo[uuid] console.log("hero_show",uuid) // let skill1 = SkillSet[this.hero.skill[0]] // let skill2 = SkillSet[this.hero.skill[1]] // var sk_path = "game/skills/skill_icon" // var icon_path = "game/heros/herois" let content=this.node.getChildByName("show").getChildByName("content") content.getChildByName("name").getChildByName("value").getComponent(Label).string=this.hero.name content.getChildByName("name").getChildByName("g1").active=HeroInfo[uuid].quality==1 content.getChildByName("name").getChildByName("g2").active=HeroInfo[uuid].quality==2 content.getChildByName("name").getChildByName("g3").active=HeroInfo[uuid].quality==3 this.clear_hero() this.call_hero(uuid) // resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { // const sprite = content.getChildByName("hero").getChildByName("icon").getComponent(Sprite); // sprite.spriteFrame = atlas.getSpriteFrame(this.hero.path); // }); // resources.load(sk_path, SpriteAtlas, (err: any, atlas) => { // const sprite = content.getChildByName("bottom").getChildByName("sk").getChildByName("skicon").getChildByName("Mask").getChildByName("icon").getComponent(Sprite); // sprite.spriteFrame = atlas.getSpriteFrame(skill1.path); // }); // content.getChildByName("bottom").getChildByName("sk").getChildByName("name").getComponent(Label).string = skill1.name; // content.getChildByName("bottom").getChildByName("sk").getChildByName("info").getComponent(Label).string = skill1.info; // resources.load(sk_path, SpriteAtlas, (err: any, atlas) => { // const sprite = content.getChildByName("bottom").getChildByName("sk2").getChildByName("skicon").getChildByName("Mask").getChildByName("icon").getComponent(Sprite); // sprite.spriteFrame = atlas.getSpriteFrame(skill2.path); // }); // content.getChildByName("bottom").getChildByName("sk2").getChildByName("name").getComponent(Label).string = skill2.name; // content.getChildByName("bottom").getChildByName("sk2").getChildByName("info").getComponent(Label).string = skill2.info; // tal.getChildByName("slv1").getChildByName("val").getComponent(Label).string = this.hero.tals[0] // tal.getChildByName("slv2").getChildByName("val").getComponent(Label).string = this.hero.tals[1] // tal.getChildByName("slv3").getChildByName("val").getComponent(Label).string = this.hero.tals[2] // tal.getChildByName("slv4").getChildByName("val").getComponent(Label).string = this.hero.tals[3] // tal.getChildByName("slv5").getChildByName("val").getComponent(Label).string = this.hero.tals[4] this.update_data() } update_data(){ let content=this.node.getChildByName("show").getChildByName("content") // let slv_node=content.getChildByName("name").getChildByName("slv"); // let slvup=content.getChildByName("slvup"); let attr = content.getChildByName("attr"); // slv_node.getChildByName("slv").getComponent(Label).string = smc.heros[uuid].slv.toString(); // content.getChildByName("name").getChildByName("quality").getChildByName("q1").active = this.hero.quality == 1; // content.getChildByName("name").getChildByName("quality").getChildByName("q2").active = this.hero.quality == 2; // content.getChildByName("name").getChildByName("quality").getChildByName("q3").active = this.hero.quality == 3; // content.getChildByName("name").getChildByName("quality").getChildByName("k1").active = this.hero.kind == 1; // content.getChildByName("name").getChildByName("quality").getChildByName("k2").active = this.hero.kind == 2; // content.getChildByName("name").getChildByName("quality").getChildByName("k3").active = this.hero.kind == 3; // lvup.getChildByName("gold").getChildByName("need").getComponent(Label).string = (UpGold.LvUp*smc.heros[uuid].lv).toString() attr.getChildByName("ap").getChildByName("val").getComponent(Label).string = this.hero.ap.toFixed(0).toString() attr.getChildByName("hp").getChildByName("val").getComponent(Label).string = this.hero.hp.toFixed(0).toString() attr.getChildByName("acd").getChildByName("val").getComponent(Label).string = this.hero.a_cd attr.getChildByName("speed").getChildByName("val").getComponent(Label).string = this.hero.speed attr.getChildByName("dis").getChildByName("val").getComponent(Label).string = this.hero.dis oops.message.dispatchEvent("hero_card_update_info",{uuid:this.h_uuid}) } lv_selcet(e:any,val:any){ } call_hero(uuid:number){ var path = "game/heros/uiheros/"+HeroInfo[uuid].path; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); node.parent = this.node.getChildByName("show").getChildByName("content").getChildByName("hero").getChildByName("node") } clear_hero(){ this.node.getChildByName("show").getChildByName("content").getChildByName("hero").getChildByName("node").destroyAllChildren() } pre_hero(){ let hi= HeroList.indexOf(this.h_uuid) if(hi==0){ oops.gui.toast("已经是第一个英雄"); return } this.h_uuid=HeroList[hi-1] this.hero_show(this.h_uuid) } next_hero(){ let hi= HeroList.indexOf(this.h_uuid) if(hi==HeroList.length-1){ oops.gui.toast("已经是最后一个英雄"); return } this.h_uuid=HeroList[hi+1] this.hero_show(this.h_uuid) } item_show(e:any,val:any){ oops.gui.open(UIID.ItemInfo, {uuid:val,type:0}); } close_show(){ this.node.getChildByName("show").active=false } close(){ this.node.active=false } reset() { this.node.destroy(); } }