65 lines
1.5 KiB
TypeScript
65 lines
1.5 KiB
TypeScript
import { UIBase } from '../UIBase';
|
|
import { uimanger } from '../UIManger';
|
|
import { UIUpdateHero } from './UIUpdateHero';
|
|
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;
|
|
private boxIndex = 0;
|
|
|
|
init(data: any) {
|
|
|
|
this.boxIndex = data.boxIndex;
|
|
}
|
|
|
|
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, this.boxIndex, () => {
|
|
var node = cc
|
|
.find('Canvas')
|
|
.getComponentInChildren(UIUpdateHero).node;
|
|
node.emit('refreshUI');
|
|
this.node.destroy();
|
|
});
|
|
} else {
|
|
cc.uiHelper.showTips('Must Choose a hero');
|
|
}
|
|
}
|
|
}
|