223 lines
7.2 KiB
JavaScript
223 lines
7.2 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'be85cnEG4hIWbPnVLCbpfs8', 'cmp.heaven.main');
|
||
|
|
// Scripts/mod/pve/heaven/cmp/cmp.heaven.main.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var _TipAward;
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var HEACT = require("heaven_controller");
|
||
|
|
var HeavenEvent = require("heaven_event");
|
||
|
|
var RankConstant = require("rank_constant");
|
||
|
|
var TipsController = require("tips_controller");
|
||
|
|
var ItemLay = require("cmp.common.itemlayout");
|
||
|
|
var TipAward = (_TipAward = {}, _TipAward[1] = "heaven.fight.ten", _TipAward[2] = "heaven.fight.twenty", _TipAward[3] = "heaven.fight.thirty", _TipAward);
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeWindow,
|
||
|
|
properties: {
|
||
|
|
chapter: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
starNum: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
scoreBar: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.ProgressBar
|
||
|
|
},
|
||
|
|
scoreGifts: {
|
||
|
|
"default": [],
|
||
|
|
type: [cc.Node]
|
||
|
|
},
|
||
|
|
// lines:{
|
||
|
|
// default:null,
|
||
|
|
// type:cc.Node
|
||
|
|
// },
|
||
|
|
stages: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
stageList: {
|
||
|
|
"default": null,
|
||
|
|
type: ItemLay
|
||
|
|
},
|
||
|
|
fabStage: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Prefab
|
||
|
|
},
|
||
|
|
challengeNum: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
buyNum: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this.ctrl = HEACT.getInstance();
|
||
|
|
this.model = this.ctrl.getModel();
|
||
|
|
// this.custom_stage = {};
|
||
|
|
// this.bindGEvent(HeavenEvent.Get_Chapter_Data_Event,this.updateCurInfos.bind(this));
|
||
|
|
this.bindGEvent(HeavenEvent.Add_Chapter_Data_Event, this.updateCurInfos.bind(this));
|
||
|
|
this.bindGEvent(HeavenEvent.Get_Chapter_Award_Event, this.updateGetAwardInfos.bind(this));
|
||
|
|
//更新關卡數據
|
||
|
|
this.bindGEvent(HeavenEvent.Update_Chapter_Basedata_Event, this.refreshStageItems.bind(this));
|
||
|
|
//刷新購買次數
|
||
|
|
this.bindGEvent(HeavenEvent.Update_Chapter_Count_Event, this.updateBuyCount.bind(this));
|
||
|
|
},
|
||
|
|
updateBuyCount: function updateBuyCount() {
|
||
|
|
//挑戰信息更新
|
||
|
|
var challengeStr = cc.js.formatStr("%s/%s", this.model.getLeftChallengeCount(), game.configs.dungeon_heaven_data.data_const.refresh_number.val);
|
||
|
|
nx.gui.setString(this.challengeNum, "", challengeStr);
|
||
|
|
//購買次數更新
|
||
|
|
nx.gui.setString(this.buyNum, "", this.model.getTodayLeftBuyCount());
|
||
|
|
},
|
||
|
|
updateGetAwardInfos: function updateGetAwardInfos(id) {
|
||
|
|
if (id != this.chapter_data.id) return;
|
||
|
|
this.refreshAwards(this.chapter_data.id, this.chapter_data.all_star, this.chapter_data.award_info);
|
||
|
|
},
|
||
|
|
//更新信息
|
||
|
|
updateCurInfos: function updateCurInfos(id) {
|
||
|
|
this.updateBuyCount();
|
||
|
|
//章節信息
|
||
|
|
if (!id) {
|
||
|
|
id = this.model.getOpenMaxChapterId();
|
||
|
|
}
|
||
|
|
this.chapter_data = this.model.getChapterDataById(id);
|
||
|
|
nx.gui.setString(this.chapter, "", cc.js.formatStr(nx.text.getKey("HeaChapter"), this.chapter_data.id));
|
||
|
|
this.refreshAwards(this.chapter_data.id, this.chapter_data.all_star, this.chapter_data.award_info);
|
||
|
|
|
||
|
|
//請求關卡數據
|
||
|
|
this.ctrl.sender25201(this.chapter_data.id);
|
||
|
|
|
||
|
|
//次级查找界面需要关闭
|
||
|
|
nx.bridge.closePanel("WndHeavenChapter");
|
||
|
|
},
|
||
|
|
refreshAwards: function refreshAwards(chapter_id, all_star, infos) {
|
||
|
|
var award_data = game.configs.dungeon_heaven_data.data_star_award[chapter_id];
|
||
|
|
var max_star = all_star; //每章的最大星級
|
||
|
|
infos.sort(function (a, b) {
|
||
|
|
return a.id - b.id;
|
||
|
|
});
|
||
|
|
for (var i = 0; i < this.scoreGifts.length; i++) {
|
||
|
|
var nd = this.scoreGifts[i];
|
||
|
|
var data = infos[i];
|
||
|
|
if (data) {
|
||
|
|
var cfg = null;
|
||
|
|
for (var a in award_data) {
|
||
|
|
if (award_data[a].award_id == data.id) {
|
||
|
|
cfg = award_data[a];
|
||
|
|
max_star = cfg.limit_star;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
nx.gui.setActive(nd, "lock", data.flag == 0);
|
||
|
|
nx.gui.setActive(nd, "get", data.flag == 2);
|
||
|
|
nx.gui.setString(nd, "score", cfg.limit_star || "");
|
||
|
|
var cmp = nx.gui.getComponent(nd, "show", "cmp.common.itemlayout");
|
||
|
|
if (cmp) {
|
||
|
|
cmp.rebuild(cfg.award);
|
||
|
|
}
|
||
|
|
nx.gui.setActive(nd, "show", false);
|
||
|
|
nx.gui.setActive(this, "main/hideall", false);
|
||
|
|
nx.mTip.openTip(TipAward[data.id], data.flag == 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
nx.gui.setString(this.starNum, "", cc.js.formatStr("%s/%s", all_star, max_star));
|
||
|
|
this.scoreBar.progress = all_star / max_star;
|
||
|
|
},
|
||
|
|
refreshStageItems: function refreshStageItems() {
|
||
|
|
var customs_data = game.configs.dungeon_heaven_data.data_customs[this.chapter_data.id];
|
||
|
|
if (!customs_data) return;
|
||
|
|
// this.lines.active = true;
|
||
|
|
var list = [];
|
||
|
|
for (var i in customs_data) {
|
||
|
|
list.push(customs_data[i]);
|
||
|
|
}
|
||
|
|
this.stageList.rebuild(list);
|
||
|
|
},
|
||
|
|
start: function start() {},
|
||
|
|
onOpenConfigs: function onOpenConfigs(params) {
|
||
|
|
var _this = this;
|
||
|
|
this.ctrl.sender25200(function (_data) {
|
||
|
|
if (_data) {
|
||
|
|
_this.updateCurInfos();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
onPreClosed: function onPreClosed() {
|
||
|
|
this.stageList.rebuild([]);
|
||
|
|
},
|
||
|
|
onTouchHideAll: function onTouchHideAll() {
|
||
|
|
for (var i = 0; i < this.scoreGifts.length; i++) {
|
||
|
|
var nod = this.scoreGifts[i];
|
||
|
|
nx.gui.setActive(nod, "show", false);
|
||
|
|
}
|
||
|
|
nx.gui.setActive(this, "main/hideall", false);
|
||
|
|
},
|
||
|
|
clickStarAward: function clickStarAward(_index) {
|
||
|
|
var index = Number(_index);
|
||
|
|
var award_info = this.chapter_data.award_info[index];
|
||
|
|
if (award_info.flag != 1) {
|
||
|
|
for (var i = 0; i < this.scoreGifts.length; i++) {
|
||
|
|
var nod = this.scoreGifts[i];
|
||
|
|
if (i != index) {
|
||
|
|
nx.gui.setActive(nod, "show", false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var show = nx.gui.find(this.scoreGifts[index], "show");
|
||
|
|
nx.gui.setActive(show, "", !show.active);
|
||
|
|
nx.gui.setActive(this, "main/hideall", show.active == true);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// if(award_info.flag == 0){
|
||
|
|
|
||
|
|
// }else if(award_info.flag == 1){
|
||
|
|
this.ctrl.sender25215(this.chapter_data.id, award_info.id);
|
||
|
|
// }
|
||
|
|
},
|
||
|
|
clickBuyChallengeNums: function clickBuyChallengeNums() {
|
||
|
|
var _this2 = this;
|
||
|
|
//購買挑戰次數
|
||
|
|
if (this.model.getTodayLeftBuyCount() > 0) {
|
||
|
|
var buy_num = this.model.getTodayBuyCount();
|
||
|
|
var buy_cfg = game.configs.dungeon_heaven_data.data_count_buy[buy_num + 1];
|
||
|
|
if (buy_cfg) {
|
||
|
|
var str = cc.js.formatStr(nx.text.getKey("lab_star_tower_main_window_tip7"), 3, buy_cfg.cost);
|
||
|
|
var fun = function fun() {
|
||
|
|
_this2.ctrl.sender25207();
|
||
|
|
};
|
||
|
|
nx.mbox(str, ["cancel", "confirm"], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == "confirm") {
|
||
|
|
fun();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
nx.tbox("MonoBuyNoTime");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
clickFindAllChapters: function clickFindAllChapters() {
|
||
|
|
nx.bridge.createPanel("WndHeavenChapter", {});
|
||
|
|
},
|
||
|
|
onClickRank: function onClickRank() {
|
||
|
|
nx.bridge.createPanel("WndPVERankAward", {
|
||
|
|
type: RankConstant.RankType.heaven,
|
||
|
|
ops: ["RankNow"],
|
||
|
|
show: "RankNow"
|
||
|
|
});
|
||
|
|
},
|
||
|
|
onTouchHelp: function onTouchHelp() {
|
||
|
|
var TC = TipsController.getInstance();
|
||
|
|
var explain = game.configs.dungeon_heaven_data.data_const;
|
||
|
|
TC.showTextPanel("tip", explain.dunheaven_rule.desc);
|
||
|
|
}
|
||
|
|
// update (dt) {},
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|