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

94 lines
2.4 KiB
TypeScript

const NetManage = require('../../manages/NetManage');
import { UIBase } from '../UIBase';
import { uimanger } from '../UIManger';
import { UpdateChoose } from './updatechoose';
const { ccclass, property } = cc._decorator;
@ccclass
export class ChooseHeroUpQuality extends UIBase {
public static prefabPath: string = 'prefabs/UIPrefab/pb_advenced';
@property(cc.Node) mainHeroChoose: cc.Node = null;
@property(cc.Node) secHeroChoose: cc.Node = null;
@property(cc.Node) mainHero: cc.Node = null;
@property(cc.Node) secHero: cc.Node = null;
@property(cc.Node) finalHero: cc.Node = null;
@property(cc.Label) costLabel: cc.Label = null;
@property(cc.Label) timeLabel: cc.Label = null;
@property(cc.Label) rateLabel: cc.Label = null;
@property(cc.Node) beforeStar: cc.Node = null;
@property(cc.Node) afterStar: cc.Node = null;
@property(cc.Label) oldHp: cc.Label = null;
@property(cc.Label) oldAtk: cc.Label = null;
@property(cc.Label) oldDef: cc.Label = null;
@property(cc.Label) newHp: cc.Label = null;
@property(cc.Label) newAtk: cc.Label = null;
@property(cc.Label) newDef: cc.Label = null;
private mainHeroData: any;
private secHeroData: any;
init(data: any) {}
onLoad(): void {
this.oldAtk.string = '0';
this.oldDef.string = '0';
this.oldHp.string = '0';
this.newAtk.string = '0';
this.newDef.string = '0';
this.newHp.string = '0';
cc.Notifier.on('academyCHOOSE', this, this.hasGetOne.bind(this));
}
hasGetOne(data) {
if (data.index == 0) {
this.mainHeroChoose.active = false;
this.mainHero.getComponent('herochoseone').initdata(data.heroInfo);
this.finalHero.getComponent('herochoseone').initdata(data.heroInfo);
this.mainHero.active = true;
this.mainHeroData = data.heroInfo.hero_uniid;
} else if (data.index == 1) {
this.secHeroChoose.active = false;
this.secHero.getComponent('herochoseone').initdata(data.heroInfo);
this.secHero.active = true;
this.secHeroData = data.heroInfo.hero_uniid;
}
}
onDestroy(): void {
cc.Notifier.off('academyCHOOSE', this);
}
onChooseHero(event, param) {
var data = {
index: param,
};
uimanger.showUI(UpdateChoose.prefabPath, data);
}
onClose() {
this.node.destroy();
}
onOk() {
if (this.mainHeroData && this.secHeroData) {
NetManage.heroUpgradeQuality(
this.mainHeroData,
this.secHeroData,
0,
() => {
this.node.destroy();
}
);
} else {
cc.uiHelper.showTips('Must Choose two hero');
}
}
}