46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources } from 'cc';
|
|
import { oops } from 'db://oops-framework/core/Oops';
|
|
import { UIID } from '../common/config/GameUIConfig';
|
|
import { getHeroStatsByLevel, HeroInfo } from '../common/config/heroSet';
|
|
import { smc } from '../common/SingletonModuleComp';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('HInfoComp')
|
|
export class HInfoComp extends Component {
|
|
h_uuid:number=0
|
|
start() {
|
|
|
|
}
|
|
|
|
onAdded(args: any) {
|
|
console.log("[HInfoComp]:onAdded",args)
|
|
this.update_data(args)
|
|
}
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
update_data(uuid:number){
|
|
console.log("[HInfoComp]:update_data",uuid)
|
|
console.log("[HCardUICom]:update_data",uuid)
|
|
this.h_uuid=uuid
|
|
let hero_data = HeroInfo[uuid]
|
|
let hero= this.node.getChildByName("hero")
|
|
let anm_path=hero_data.path
|
|
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
|
|
hero.getComponent(Animation).addClip(clip);
|
|
hero.getComponent(Animation).play("idle");
|
|
});
|
|
this.node.getChildByName("name").getComponent(Label).string=hero_data.name
|
|
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[uuid].lv.toString()
|
|
let {hp,ap,def}=getHeroStatsByLevel(uuid,smc.heros[uuid].lv)
|
|
this.node.getChildByName("info").getChildByName("hp").getChildByName("num").getComponent(Label).string=hp.toString()
|
|
this.node.getChildByName("info").getChildByName("ap").getChildByName("num").getComponent(Label).string=ap.toString()
|
|
this.node.getChildByName("info").getChildByName("def").getChildByName("num").getComponent(Label).string=def.toString()
|
|
}
|
|
close(){
|
|
oops.gui.removeByNode(this.node)
|
|
}
|
|
}
|
|
|
|
|