68 lines
3.3 KiB
TypeScript
68 lines
3.3 KiB
TypeScript
import { _decorator,Button,Color,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";
|
|
import { HeroInfo } from "../common/config/heroSet";
|
|
import { ColorSet } from "../common/config/BoxSet";
|
|
|
|
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=[]
|
|
pw:any=[]
|
|
is_dead:boolean=false
|
|
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.pw=this.node.getChildByName("pow").getComponent(ProgressBar)!
|
|
this.hc_name.string= this.heros[this.hi].HeroView.hero_name
|
|
// this.node.getChildByName("lv").getComponent(Label).string=this.heros[this.hi].HeroView.lv.toString()+"级";
|
|
// // console.log("hcard start",this.heros[this.hi].HeroView.hero_uuid)
|
|
// this.node.getChildByName("g1").active=HeroInfo[this.heros[this.hi].HeroView.hero_uuid].quality==1
|
|
// this.node.getChildByName("g2").active=HeroInfo[this.heros[this.hi].HeroView.hero_uuid].quality==2
|
|
// this.node.getChildByName("g3").active=HeroInfo[this.heros[this.hi].HeroView.hero_uuid].quality==3
|
|
}
|
|
protected update(dt: number): void {
|
|
if(this.is_dead) return
|
|
if(this.heros[this.hi].HeroView.is_dead){
|
|
this.node.getChildByName("dead").active=true
|
|
this.node.getChildByName("bg").getComponent(Sprite).grayscale=true
|
|
this.is_dead=true
|
|
}else{
|
|
this.node.getChildByName("dead").active=false
|
|
this.node.getChildByName("bg").getComponent(Sprite).grayscale=false
|
|
this.is_dead=false
|
|
}
|
|
this.hp.string=(this.heros[this.hi].HeroView.rhp_max).toFixed(0)
|
|
this.ap.string=(this.heros[this.hi].HeroView.ap*(smc.vmdata.mission.ap+100)/100).toFixed(0)
|
|
this.life.progress=this.heros[this.hi].HeroView.hp/this.heros[this.hi].HeroView.rhp_max
|
|
this.pw.progress=this.heros[this.hi].HeroView.pw/this.heros[this.hi].HeroView.pwm
|
|
|
|
|
|
}
|
|
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
console.log("hcard reset");
|
|
this.node.destroy();
|
|
}
|
|
} |