pubgv3/assets/scripts/UI/Academy/updatechoosejs.js
guoqing.zhu bfdc4f0212 update
2022-06-15 16:12:58 +08:00

92 lines
1.9 KiB
JavaScript

const { UIBase } = require('../UIBase');
cc.Class({
extends: UIBase,
properties: {
nd_heroContent: {
default: null,
type: cc.Node,
},
pb_hero: {
default: null,
type: cc.Node,
},
},
onLoad() {
this.currentChoose = {};
this.qualityIndex = 0;
},
init(data) {
this.qualityIndex = data.index; // quality 0 main 1 sec
this.nd_heroContent.destroyAllChildren();
NetManage.getHeroList((data) => {
var list = data.hero_list;
list.forEach((element) => {
const node = cc.instantiate(this.pb_hero);
var sc = node.getComponent('herochoseone');
sc.initdata(element);
if (window.qualityMainData) {
if (element.hero_id != window.qualityMainData.heroid) {
node.getComponent('wantedHero').showCover();
}
if (element.hero_uniid == window.qualityMainData.herouuid) {
node.getComponent('wantedHero').showCover();
}
}
if (window.qualitySecData) {
if (element.hero_id != window.qualitySecData.heroid) {
node.getComponent('wantedHero').showCover();
}
if (element.hero_uniid == window.qualitySecData.herouuid) {
node.getComponent('wantedHero').showCover();
}
}
//
if (
this.qualityIndex &&
this.qualityIndex == 1 &&
element.quality > 1
) {
node.getComponent('wantedHero').showCover();
}
//
node.on('click', () => {
this.nd_heroContent.children.forEach((element) => {
element.scale = 1;
});
node.scale = 1.1;
this.currentChoose = element;
});
this.nd_heroContent.addChild(node);
if (element.lock_type != 0) {
node.getComponent('wantedHero').showCover();
}
});
});
},
onClose() {
this.node.destroy();
},
onOk() {
if (this.currentChoose) {
this.node.destroy();
var data = {
index: this.qualityIndex,
heroInfo: this.currentChoose,
};
cc.Notifier.emit('academyCHOOSE', data);
} else {
cc.uiHelper.showTips('Must Choose a hero');
}
},
});