Files
heros/assets/script/game/map/HeroHomeComp.ts

61 lines
2.3 KiB
TypeScript

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>(HeroCard)
hcc.load(HeroList[i],parent)
}
}
hero_show(uuid:number) {
console.log("hero_home hero_show:",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(smc.heros[uuid].path);
});
this.node.getChildByName("name").getChildByName("value").getComponent(Label).string=smc.heros[uuid].name
}
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();
}
}