pubgv3/assets/scripts/UI/season/cellseason.js
zhuguoqing 53febf2dc4 update
2022-05-28 10:31:45 +08:00

134 lines
3.3 KiB
JavaScript

let viewCell = require("viewCell");
var gameConfig = require("gameConfig");
var Utils = require("Utils");
var NetManage = require("NetManage");
cc.Class({
extends: viewCell,
properties: {
lb_lv: {
default: null,
type: cc.Label,
},
sp_icon1: {
default: null,
type: cc.Sprite,
},
sp_pz1: {
default: null,
type: cc.Sprite,
},
lb_count1: {
default: null,
type: cc.Label,
},
sp_icon2: {
default: null,
type: cc.Sprite,
},
sp_pz2: {
default: null,
type: cc.Sprite,
},
lb_count2: {
default: null,
type: cc.Label,
},
nd_geted1: {
default: null,
type: cc.Node,
},
nd_notfinish1: {
default: null,
type: cc.Node,
},
nd_geted2: {
default: null,
type: cc.Node,
},
nd_notfinish2: {
default: null,
type: cc.Node,
},
nd_locked: {
default: null,
type: cc.Node,
},
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
init: function (index, data, reload, group) {
if (index >= data.array.length) {
this.node.active = false;
return;
}
this.node.active = true;
this.target = data.target;
var sdata = data.array[index];
this.initdata(sdata);
},
initdata(v) {
this.lv = v.lv;
// this.lb_lv.string = v.lv +
this.lb_lv.string = v.lv;
var basedata = v.base[0];
var avddata = v.advance[0];
Utils.setitem(this, basedata.id, this.sp_icon1, this.sp_pz1);
Utils.setitem(this, avddata.id, this.sp_icon2, this.sp_pz2);
this.lb_count1.string = basedata.num;
this.lb_count2.string = avddata.num;
this.basestate = v.basestate;
this.avdstate = v.avdstate;
this.refreshstate();
},
refreshstate() {
this.nd_locked.active =
this.nd_notfinish2.active =
this.nd_geted2.active =
this.nd_notfinish1.active =
this.nd_geted1.active =
false;
if (this.basestate == 1) {
this.nd_geted1.active = true;
} else if (this.basestate == 2) {
this.nd_notfinish1.active = true;
}
if (this.avdstate == 1) {
this.nd_geted2.active = true;
} else if (this.avdstate == 2) {
this.nd_notfinish2.active = true;
} else if (this.avdstate == 3) {
this.nd_locked.active = true;
}
},
onclick1() {
if (this.basestate != 0) {
return;
}
NetManage.seasonCardReward(1, this.lv, () => {
this.basestate = 1;
this.refreshstate();
});
},
onclick2() {
if (this.avdstate != 0) {
return;
}
NetManage.seasonCardReward(2, this.lv, () => {
this.avdstate = 1;
this.refreshstate();
});
},
// update (dt) {},
});