296 lines
9.2 KiB
JavaScript
296 lines
9.2 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'bbcedloE/FJ44mBsznXWodY', 'cmp.dungeon.wnd');
|
|
// Scripts/mod/pve/dungeon/cmp/cmp.dungeon.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 行星武器奖励弹窗
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var PathTool = require("pathtool");
|
|
var ItemExpand = require("nx.fx.sv.expand");
|
|
var StoneDungeonController = require("stone_dungeon_controller");
|
|
var StoneDungeonEvent = require("stone_dungeon_event");
|
|
var RoleController = require("role_controller");
|
|
var TipsController = require("tips_controller");
|
|
var NxSpine = require("nx.fx.spine");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
list: {
|
|
"default": null,
|
|
type: ItemExpand
|
|
},
|
|
tab_list: {
|
|
"default": null,
|
|
type: ItemExpand
|
|
},
|
|
textCount: {
|
|
"default": null,
|
|
type: cc.RichText
|
|
},
|
|
nodClear: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
roleSp: {
|
|
"default": null,
|
|
type: NxSpine
|
|
}
|
|
},
|
|
onLoad: function onLoad() {
|
|
this.ctrl = StoneDungeonController.getInstance();
|
|
this.model = this.ctrl.getModel();
|
|
this.role_vo = RoleController.getInstance().getRoleVo();
|
|
this.first_come_in = true;
|
|
this.cur_index = 1;
|
|
// this.tab_list = []
|
|
|
|
this.bindGEvent(StoneDungeonEvent.Update_StoneDungeon_Data, this.updateDungeonData.bind(this));
|
|
},
|
|
updateDungeonData: function updateDungeonData() {
|
|
this.changeDungeonData(this.cur_index, 1);
|
|
this.first_come_in = false;
|
|
this.redPointStatus();
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(params) {
|
|
var _this = this;
|
|
var tab_index = params.index || 0;
|
|
this.ctrl.send13030();
|
|
var list = game.configs.dungeon_stone_data.data_const.dungeon_type.val;
|
|
var tab = [];
|
|
for (var i = 0; i < list.length; i++) {
|
|
tab.push({
|
|
id: list[i]
|
|
});
|
|
}
|
|
this.tab_list.rebuild(tab);
|
|
this.tab_list.addFocus(tab_index);
|
|
this.setTipStatus();
|
|
var eff_path = PathTool.getSpinePath("H30051", "show", false);
|
|
this.roleSp.load(eff_path, function (e) {
|
|
if (!e) {
|
|
_this.roleSp.action("action1", true);
|
|
} else {
|
|
_this.roleSp.stop();
|
|
}
|
|
});
|
|
},
|
|
setTipStatus: function setTipStatus() {},
|
|
onPreClosed: function onPreClosed() {
|
|
this.list.rebuild([]);
|
|
this.tab_list.rebuild([]);
|
|
},
|
|
onFocusTabItem: function onFocusTabItem(_item) {
|
|
// 空
|
|
if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) {
|
|
return;
|
|
}
|
|
if (this.cur_index == _item.mdata.id) return;
|
|
|
|
// 聚焦
|
|
this.tab_list.cleanFocus();
|
|
this.tab_list.addFocus(_item.index);
|
|
|
|
// this.model.setCurChangeSweep( _item.mdata.id );
|
|
this.cur_index = _item.mdata.id;
|
|
this.changeDungeonData(_item.mdata.id);
|
|
},
|
|
// 红点
|
|
redPointStatus: function redPointStatus() {
|
|
for (var i = 1; i <= 5; i++) {
|
|
var index = i;
|
|
var change_count = this.model.getChangeSweepCount(index);
|
|
if (change_count >= 2) {
|
|
var key = cc.js.formatStr("pve.dungeon.%s", index);
|
|
nx.mTip.openTip(key, false);
|
|
} else {
|
|
var _key = cc.js.formatStr("pve.dungeon.%s", index);
|
|
nx.mTip.openTip(_key, true);
|
|
}
|
|
}
|
|
},
|
|
updateClearStatus: function updateClearStatus(data) {
|
|
var is_clear = false;
|
|
for (var i in data) {
|
|
var clearance = this.model.getPassClearanceID(data[i].id);
|
|
if (this.role_vo.max_power >= data[i].power) {
|
|
if (clearance && clearance.status == 1) {
|
|
is_clear = true;
|
|
}
|
|
}
|
|
}
|
|
nx.gui.setActive(this.nodClear, "on", is_clear);
|
|
nx.gui.setActive(this.nodClear, "off", !is_clear);
|
|
},
|
|
changeDungeonData: function changeDungeonData(index, flag) {
|
|
this.unscheduleAllCallbacks();
|
|
index = game.configs.dungeon_stone_data.data_type_open[index].id || 1;
|
|
var change_count = this.model.getChangeSweepCount(index);
|
|
var str = "";
|
|
var free_count = 1; //1:还有次数
|
|
|
|
if (change_count >= 2) {
|
|
free_count = 0;
|
|
if (change_count >= game.configs.dungeon_stone_data.data_buy[index].length) {
|
|
str = cc.js.formatStr(nx.text.getKey("lab_stone_dungeon_window_tip1"));
|
|
} else {
|
|
var vip_count = 1;
|
|
var cost = 0;
|
|
for (var i in game.configs.dungeon_stone_data.data_buy[index]) {
|
|
if (game.configs.dungeon_stone_data.data_buy[index][i].vip <= this.role_vo.vip_lev) {
|
|
vip_count = i;
|
|
cost = game.configs.dungeon_stone_data.data_buy[index][i].cost;
|
|
}
|
|
}
|
|
var remain_num = vip_count - change_count;
|
|
if (remain_num <= 0) {
|
|
remain_num = 0;
|
|
}
|
|
this.remian_num = remain_num;
|
|
str = cc.js.formatStr(nx.text.getKey("lab_stone_dungeon_window_tip2"), remain_num, cost);
|
|
}
|
|
var key = cc.js.formatStr("pve.dungeon.%s", index);
|
|
nx.mTip.openTip(key, false);
|
|
} else {
|
|
this.remian_num = game.configs.dungeon_stone_data.data_const.free_num.val - change_count;
|
|
str = cc.js.formatStr(nx.text.getKey("lab_stone_dungeon_window_tip3"), game.configs.dungeon_stone_data.data_const.free_num.val - change_count);
|
|
var _key2 = cc.js.formatStr("pve.dungeon.%s", index);
|
|
nx.mTip.openTip(_key2, true);
|
|
}
|
|
this.textCount.string = str;
|
|
var data_info = [];
|
|
for (var i in game.configs.dungeon_stone_data.data_award_list) {
|
|
for (var m in game.configs.dungeon_stone_data.data_award_list[i]) {
|
|
if (game.configs.dungeon_stone_data.data_award_list[i][m].dun_type == index) {
|
|
data_info.push(game.configs.dungeon_stone_data.data_award_list[i][m]);
|
|
}
|
|
}
|
|
}
|
|
data_info.sort(function (a, b) {
|
|
return a.id - b.id;
|
|
});
|
|
var title_pos = this.getPoerTitle(data_info);
|
|
change_count = change_count + 1;
|
|
var temp_arr = Object.keys(game.configs.dungeon_stone_data.data_buy[index]);
|
|
if (change_count >= temp_arr.length) {
|
|
change_count = temp_arr.length;
|
|
}
|
|
var tab = {
|
|
title_pos: title_pos,
|
|
//推荐位置
|
|
count: free_count,
|
|
//免费次数
|
|
expend: game.configs.dungeon_stone_data.data_buy[index][change_count].cost //消耗钻石
|
|
};
|
|
|
|
var go = 0;
|
|
var list = [];
|
|
for (var j in data_info) {
|
|
var data = {};
|
|
data.info = data_info[j];
|
|
data.tab = tab;
|
|
list.push(data);
|
|
if (data.info.difficulty == data.tab.title_pos) {
|
|
go = parseInt((data.info.id - 1) % 100);
|
|
}
|
|
}
|
|
this.list.freshRange(0, true);
|
|
this.list.rebuild(list);
|
|
this.updateClearStatus(data_info); //更新一下扫荡状态
|
|
|
|
var cmp = nx.gui.getComponent(this.list.node, "scoreView", cc.ScrollView);
|
|
if (cmp) {
|
|
cmp.scrollToTop(0.0001);
|
|
var posp = cc.v2(0, go * 150);
|
|
// cmp.setContentPosition( posp );
|
|
cmp.scrollToOffset(posp, 0.02);
|
|
} // scrollTo
|
|
// if( this.vip < 5 ){
|
|
// 引导辅助
|
|
if (nx.bridge.plot && nx.bridge.plot.isDoing()) {
|
|
this.positionPlotCells();
|
|
}
|
|
},
|
|
// 获取推荐角标
|
|
getPoerTitle: function getPoerTitle(data) {
|
|
var num = -1;
|
|
var totle = data.length;
|
|
for (var i in data) {
|
|
var clearance = this.model.getPassClearanceID(data[i].id);
|
|
if (this.role_vo.max_power >= data[i].power) {
|
|
if (clearance && clearance.status == 1) {
|
|
num = parseInt(i);
|
|
}
|
|
}
|
|
}
|
|
if (num + 1 >= totle) {
|
|
num = totle;
|
|
} else {
|
|
for (var i in data) {
|
|
if (this.role_vo.max_power >= data[i].power) {
|
|
num = parseInt(i) + 1;
|
|
}
|
|
}
|
|
// if( data[ num + 1 ] && this.role_vo.max_power >= data[ num + 1 ].power && this.role_vo.lev >= data[ num + 1 ].lev_limit ) {
|
|
// num = num + 2;
|
|
// } else {
|
|
// return num + 1;
|
|
// }
|
|
}
|
|
|
|
return num;
|
|
},
|
|
// 规则说明
|
|
onTouchTip: function onTouchTip() {
|
|
var TC = TipsController.getInstance();
|
|
if (TC) {
|
|
var txt = game.configs.dungeon_stone_data.data_const.desc_rule;
|
|
TC.showTextPanel("tip", txt.desc);
|
|
}
|
|
},
|
|
onClickAllClear: function onClickAllClear() {
|
|
if (this.model.getCurChangeSweep() == null) return;
|
|
if (this.remain_num < 1) {
|
|
return nx.tbox("lab_stone_dungeon_window_tip1");
|
|
}
|
|
this.ctrl.send13032(this.model.getCurChangeSweep(), this.remian_num);
|
|
},
|
|
// ============================================
|
|
// 引导辅助
|
|
// ============================================
|
|
|
|
// 定位副本輔助热区
|
|
positionPlotCells: function positionPlotCells() {
|
|
var children = this.list.bindSCV.content.children;
|
|
var node = children[0];
|
|
if (!node) {
|
|
nx.error("$Dispatch:定位第一个派遣订单失败!");
|
|
node = children[0];
|
|
if (!node) {
|
|
return;
|
|
}
|
|
}
|
|
var cell = nx.gui.find(this, "plotCell");
|
|
var btn = node.svItem.btnChange;
|
|
var pos = btn.convertToWorldSpaceAR(cc.Vec2.ZERO);
|
|
cell.position = cell.parent.convertToNodeSpaceAR(pos);
|
|
cell.width = btn.width;
|
|
cell.height = btn.height;
|
|
cell.svItem = node.svItem;
|
|
},
|
|
// 点击金币副本第一关挑战
|
|
onTouchFirstGolden: function onTouchFirstGolden() {
|
|
var cell = nx.gui.find(this, "plotCell");
|
|
if (cell && cell.svItem) {
|
|
cell.svItem.onClickChange();
|
|
}
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |