303 lines
8.0 KiB
JavaScript
303 lines
8.0 KiB
JavaScript
var gameConfig = require("gameConfig");
|
|
var NetManage = require("NetManage");
|
|
var Utils = require("Utils");
|
|
cc.seasonmaxlv = 50;
|
|
cc.seasonbuy_level_price = 200;
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
lb_seasonname: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
lb_lv: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
lb_exp: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
lb_time: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
|
|
tableView_item: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
tableViewtask: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
nd_page1: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
nd_page2: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
pb_buy: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
pb_shouce: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
btn_buy: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
lb_lvshow: {
|
|
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,
|
|
},
|
|
pb_lvup: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
|
|
nd_buycard: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
nd_buycard2: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
cc.Notifier.on(
|
|
"onSeasonCardInfo",
|
|
this,
|
|
this.onSeasonCardInfo.bind(this)
|
|
);
|
|
},
|
|
onDestroy() {
|
|
cc.Notifier.off("onSeasonCardInfo", this);
|
|
},
|
|
onSeasonCardInfo(v) {
|
|
var oldlv = this.lv;
|
|
this.refreshreward(v.info);
|
|
if (oldlv != this.lv) {
|
|
var nd = cc.instantiate(this.pb_lvup);
|
|
nd.getComponent("seasonlvup").initdata(this.lv);
|
|
this.node.addChild(nd);
|
|
}
|
|
},
|
|
|
|
initdata(v) {
|
|
this.tableViewscp = this.tableView_item.getComponent("tableView");
|
|
this.refreshreward(v.info);
|
|
this.shownormal();
|
|
this.gettask();
|
|
},
|
|
onclickbylv() {
|
|
var nd = cc.instantiate(this.pb_buy);
|
|
nd.getComponent("sbuylv").initdata(this.lv);
|
|
this.node.addChild(nd);
|
|
},
|
|
onclickpreview() {},
|
|
onclose() {
|
|
this.node.destroy();
|
|
},
|
|
gettask() {
|
|
NetManage.missionList(2, (data) => {
|
|
this.refreshtask(data);
|
|
});
|
|
},
|
|
shownormal() {
|
|
this.nd_page1.active = true;
|
|
this.nd_page2.active = false;
|
|
},
|
|
showtask() {
|
|
this.nd_page1.active = false;
|
|
this.nd_page2.active = true;
|
|
},
|
|
refreshreward(v) {
|
|
cc.seasonbuy_level_price = v.buy_level_price;
|
|
|
|
this.lb_seasonname.string = "S" + v.season_id;
|
|
this.lb_lv.string = v.card_lv;
|
|
this.lv = Number(v.card_lv);
|
|
|
|
this.lb_exp.string = v.card_exp + "/" + v.card_max_exp;
|
|
var data1 = new Date(v.season_begin_time * 1000);
|
|
var data2 = new Date(v.season_end_time * 1000);
|
|
|
|
|
|
this.lb_time.string =
|
|
"S" +
|
|
v.season_id +
|
|
" : " +
|
|
data1.getFullYear() +
|
|
"." +
|
|
(data1.getMonth() + 1) +
|
|
"." +
|
|
data1.getDate() +
|
|
" - " +
|
|
data2.getFullYear() +
|
|
"." +
|
|
(data2.getMonth() + 1) +
|
|
"." +
|
|
data2.getDate() +
|
|
"";
|
|
|
|
var jiesuo = v.gift_packages[0].state == 1;
|
|
var seasonCardarr = [];
|
|
for (var k in gameConfig.seasonCard) {
|
|
var onedata = gameConfig.seasonCard[k];
|
|
|
|
var basestate = onedata.lv <= v.card_lv ? 0 : 2;
|
|
if (basestate == 0) {
|
|
for (var i = 0; i < v.received_level_rewards1.length; i++) {
|
|
if (v.received_level_rewards1[i] == onedata.lv) {
|
|
basestate = 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
var avdstate = 3;
|
|
if (jiesuo) {
|
|
var avdstate = onedata.lv <= v.card_lv ? 0 : 2;
|
|
if (avdstate == 0) {
|
|
for (var i = 0; i < v.received_level_rewards2.length; i++) {
|
|
if (v.received_level_rewards2[i] == onedata.lv) {
|
|
avdstate = 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
this.nd_buycard.active = false;
|
|
} else {
|
|
this.nd_buycard.active = true;
|
|
}
|
|
|
|
this.nd_buycard2.active = this.nd_buycard.active;
|
|
|
|
seasonCardarr.push({
|
|
base: cc.playerData.getDrop(onedata.reward),
|
|
advance: cc.playerData.getDrop(onedata.advanced_reward),
|
|
lv: onedata.lv,
|
|
basestate: basestate,
|
|
avdstate: avdstate,
|
|
});
|
|
}
|
|
seasonCardarr.sort((a, b) => {
|
|
return a.lv - b.lv;
|
|
});
|
|
cc.seasonmaxlv = seasonCardarr.length;
|
|
|
|
if (this.lv >= cc.seasonmaxlv) {
|
|
this.btn_buy.active = false;
|
|
} else {
|
|
this.btn_buy.active = true;
|
|
}
|
|
|
|
this.tableView_item
|
|
.getComponent("tableView")
|
|
.initTableView(seasonCardarr.length, {
|
|
array: seasonCardarr,
|
|
target: this,
|
|
width: this.tableView_item.width,
|
|
});
|
|
},
|
|
|
|
refreshtask(v) {
|
|
v.mission_list1.sort((a, b) => {
|
|
var aa = 0;
|
|
if (a.state == 1) {
|
|
aa = 2;
|
|
}
|
|
if (a.state == 2) {
|
|
aa = 1;
|
|
}
|
|
var bb = 0;
|
|
if (b.state == 1) {
|
|
bb = 2;
|
|
}
|
|
if (b.state == 2) {
|
|
bb = 1;
|
|
}
|
|
return aa - bb;
|
|
});
|
|
|
|
this.tableViewtask
|
|
.getComponent("tableView")
|
|
.initTableView(v.mission_list1.length, {
|
|
array: v.mission_list1,
|
|
target: this,
|
|
});
|
|
},
|
|
|
|
allget() {
|
|
NetManage.getSeasonAllReward();
|
|
},
|
|
buyshouce() {
|
|
if (!this.nd_buycard.active) {
|
|
return;
|
|
}
|
|
var nd = cc.instantiate(this.pb_shouce);
|
|
this.node.addChild(nd);
|
|
},
|
|
refresh(lv) {
|
|
var cfg = gameConfig.seasonCard[lv];
|
|
|
|
this.lb_lvshow.string = cfg.lv;
|
|
var data1 = cc.playerData.getDrop(cfg.reward)[0];
|
|
var data2 = cc.playerData.getDrop(cfg.advanced_reward)[0];
|
|
Utils.setitem(this, data1.id, this.sp_icon1, this.sp_pz1);
|
|
Utils.setitem(this, data2.id, this.sp_icon2, this.sp_pz2);
|
|
this.lb_count1.string = data1.num;
|
|
this.lb_count2.string = data2.num;
|
|
},
|
|
update(dt) {
|
|
var num = Math.floor(this.tableViewscp.getScrollOffset().x / 80 / 5);
|
|
if (num > 0) {
|
|
num = 0;
|
|
}
|
|
num = Math.abs(num);
|
|
if (num > 9) {
|
|
num = 9;
|
|
}
|
|
if (this.idx != num) {
|
|
this.idx = num;
|
|
this.refresh((num + 1) * 5);
|
|
}
|
|
},
|
|
});
|