219 lines
6.5 KiB
JavaScript
219 lines
6.5 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '4714bBpNPRDNLdVaacFGCKM', 'act.mysteryexplore.page');
|
|
// Scripts/mod/acts/nysteryexplore/act.mysteryexplore.page.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 迷窟探险
|
|
*
|
|
******************************************************************/
|
|
|
|
var ActPage = require("act.page.base");
|
|
var NxSpine = require("nx.fx.spine");
|
|
var ItemLay = require("cmp.common.itemlayout");
|
|
var PathTool = require("pathtool");
|
|
var BCT = require("battle_controller");
|
|
var BCS = require("battle_const");
|
|
var TipsController = require("tips_controller");
|
|
var MallCT = require("mall_controller");
|
|
var MallConst = require("mall_const");
|
|
cc.Class({
|
|
"extends": ActPage,
|
|
properties: {
|
|
spRole: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
awardList: {
|
|
"default": null,
|
|
type: ItemLay
|
|
},
|
|
rankList: {
|
|
"default": [],
|
|
type: [cc.Node]
|
|
},
|
|
totalDmg: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
cdTime: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
challengeNum: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
getBtn: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
titleName: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 初始化
|
|
build: function build(_data) {
|
|
this._super(_data);
|
|
this.happy_data = game.configs.happy_challenge_data;
|
|
// 活动监听
|
|
this.mod.vbind(this, [["MysteryExploreInfos", this.freshInfos.bind(this)], ["MysteryExploreRank", this.freshRanks.bind(this)]]);
|
|
},
|
|
onOpenScoreShop: function onOpenScoreShop() {
|
|
MallCT.getInstance().openMallPanel(true, [MallConst.MallType.LimitTimeChange]);
|
|
},
|
|
onClickRule: function onClickRule() {
|
|
var TC = TipsController.getInstance();
|
|
if (TC) {
|
|
var config = this.happy_data.data_explain[1];
|
|
TC.showTextPanel(null, config.desc);
|
|
}
|
|
},
|
|
onEnable: function onEnable() {
|
|
this.mod.reqLimitData(this.data.camp_id);
|
|
this.mod.reqRank(this.data.camp_id);
|
|
},
|
|
// 销毁
|
|
onDestroy: function onDestroy() {
|
|
// 活动监听解除
|
|
if (this.mod) {
|
|
this.mod.vunbind(this);
|
|
}
|
|
this._super();
|
|
},
|
|
// 任务刷新
|
|
freshInfos: function freshInfos(data) {
|
|
var _this = this;
|
|
if (nx.dt.objEmpty(data) || data.camp_id != this.data.camp_id) return;
|
|
nx.gui.setCdTxt(this.cdTime, "", data.end_time - client.socket.getTime());
|
|
nx.gui.setString(this.challengeNum, "", data.challenge_num);
|
|
nx.gui.setString(this.totalDmg, "", data.all_dps);
|
|
this.lastChallenge = data.challenge_num;
|
|
//今日剩余购买次数
|
|
this.challenge_buys = this.happy_data.data_const.daily_zs_times.val - data.challenge_buy_num;
|
|
var res_data = this.happy_data.data_info[this.data.camp_id];
|
|
if (res_data) {
|
|
nx.gui.setString(this.titleName, "", res_data.name);
|
|
var res_path = PathTool.getSpinePath(res_data.spine, "show", false);
|
|
this.spRole.load(res_path, function (_e) {
|
|
if (_e) {
|
|
_this.spRole.stop();
|
|
} else {
|
|
_this.spRole.action("action1", true);
|
|
}
|
|
});
|
|
}
|
|
|
|
//獎勵和積分
|
|
var is_allow_get = false; //有一個就能領取
|
|
for (var i in data.rewards) {
|
|
var g = data.rewards[i];
|
|
if (g && g.status == 1) {
|
|
is_allow_get = true;
|
|
}
|
|
}
|
|
this.awardList.rebuild(data.rewards);
|
|
nx.gui.setActive(this.getBtn, "", is_allow_get);
|
|
},
|
|
freshRanks: function freshRanks(data) {
|
|
if (nx.dt.objEmpty(data)) return;
|
|
//先設置簡單榜單
|
|
var info_data = this.happy_data.data_info[this.data.camp_id];
|
|
for (var i = 0; i < this.rankList.length; i++) {
|
|
var rank_data = data.rank_list[i];
|
|
var item = this.rankList[i];
|
|
if (rank_data) {
|
|
nx.gui.setString(item, "pname", rank_data.name);
|
|
nx.gui.setString(item, "value", rank_data.val1);
|
|
if (info_data) {
|
|
if (info_data.type == 1) {
|
|
nx.gui.setColor(item, "value", new cc.Color(239, 152, 38));
|
|
} else if (info_data.type == 2) {
|
|
nx.gui.setColor(item, "value", new cc.Color(80, 238, 2));
|
|
}
|
|
}
|
|
} else {
|
|
nx.gui.setString(item, "pname", "");
|
|
nx.gui.setString(item, "value", "");
|
|
}
|
|
}
|
|
},
|
|
onOpenRank: function onOpenRank() {
|
|
var data = this.mod.vget("MysteryExploreRank");
|
|
if (nx.dt.objEmpty(data)) return;
|
|
nx.bridge.createPanel("WndActLimitChalRank", {
|
|
list: data.rank_list,
|
|
camp_id: this.data.camp_id,
|
|
config: this.happy_data
|
|
});
|
|
},
|
|
onTryBat: function onTryBat() {
|
|
var _this2 = this;
|
|
if (this.lastChallenge > 0) {
|
|
BCT.getInstance().requestOpenBattleRelevanceWindow(BCS.Fight_Type.SingleBoss, null, function (_data) {
|
|
if (_data) {
|
|
_this2.mod.reqBat(_this2.data.camp_id, function (_data) {
|
|
if (_data) {
|
|
_this2.mod.reqLimitData(_this2.data.camp_id);
|
|
_this2.scheduleOnce(function () {
|
|
_this2.mod.reqRank(_this2.data.camp_id);
|
|
}, 3);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
//次数不足,判断是否可以购买
|
|
if (this.challenge_buys > 0) {
|
|
this.onCheckBuyChallenge();
|
|
} else {
|
|
return nx.tbox("lab_ladder_controller_tip3");
|
|
}
|
|
}
|
|
},
|
|
onTryClear: function onTryClear() {
|
|
var _this3 = this;
|
|
if (this.lastChallenge > 0) {
|
|
this.mod.reqBatClear(this.data.camp_id, function (_data) {
|
|
if (_data) {
|
|
_this3.mod.reqLimitData(_this3.data.camp_id);
|
|
_this3.mod.reqRank(_this3.data.camp_id);
|
|
}
|
|
});
|
|
} else {
|
|
//次数不足,判断是否可以购买
|
|
if (this.challenge_buys > 0) {
|
|
this.onCheckBuyChallenge();
|
|
} else {
|
|
return nx.tbox("lab_ladder_controller_tip3");
|
|
}
|
|
}
|
|
},
|
|
onCheckBuyChallenge: function onCheckBuyChallenge() {
|
|
var _this4 = this;
|
|
var cost_info = this.happy_data.data_const.zs_times_per;
|
|
nx.mbox(cc.js.formatStr(nx.text.getKey("PvpBuyRankTime"), 3, cost_info.val), ["cancel", "confirm"], function (_key, _box) {
|
|
_box.close();
|
|
if (_key == "confirm") {
|
|
_this4.mod.reqBuyChalNum(_this4.data.camp_id, function (_ret) {});
|
|
}
|
|
});
|
|
},
|
|
//一键领取
|
|
onGetAward: function onGetAward() {
|
|
var _this5 = this;
|
|
if (this.data.camp_id) {
|
|
this.mod.reqAward(this.data.camp_id, function (_data) {
|
|
if (_data) {
|
|
_this5.mod.reqLimitData(_this5.data.camp_id);
|
|
_this5.mod.reqRank(_this5.data.camp_id);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |