pubgv3/assets/scripts/UI/Academy/ChooseHeroUpdate.ts
2022-06-10 19:40:58 +08:00

56 lines
1.3 KiB
TypeScript

import { UIBase } from '../UIBase';
import { uimanger } from '../UIManger';
import { UpdateChoose } from './updatechoose';
const NetManage = require('../../manages/NetManage');
const { ccclass, property } = cc._decorator;
@ccclass
export class ChooseHeroUpdate extends UIBase {
public static prefabPath = 'prefabs/UIPrefab/pb_upgrade';
@property(cc.Label) currentLv: cc.Label = null;
@property(cc.Label) nextlv: cc.Label = null;
@property(cc.Label) costLabel: cc.Label = null;
@property(cc.Label) timeLabel: cc.Label = null;
@property(cc.Node) heroNode: cc.Node = null;
@property(cc.Node) chooseNode: cc.Node = null;
private hero_uuid = null;
init(data: any) {}
onLoad(): void {
cc.Notifier.on('academyCHOOSE', this, this.hasGetOne.bind(this));
}
onDestroy(): void {
cc.Notifier.off('academyCHOOSE', this);
}
hasGetOne(data) {
this.chooseNode.active = false;
this.heroNode.getComponent('herochoseone').initdata(data.heroInfo);
this.heroNode.active = true;
this.hero_uuid = data.heroInfo.hero_uniid;
}
onClickChooseHero() {
uimanger.showUI(UpdateChoose.prefabPath, {});
}
onClose() {
this.node.destroy();
}
onComform() {
if (this.hero_uuid) {
NetManage.heroUpgradeLevel(this.hero_uuid, 0, () => {
this.node.destroy();
});
} else {
cc.uiHelper.showTips('Must Choose a hero');
}
}
}