802 lines
26 KiB
JavaScript
802 lines
26 KiB
JavaScript
"use strict";
|
||
cc._RF.push(module, 'e26b5Tf/KFCB7PsGLrdU8fn', 'cmp.hallows.page');
|
||
// Scripts/mod/partner/cmps/bag/cmp.hallows.page.js
|
||
|
||
"use strict";
|
||
|
||
/******************************************************************
|
||
*
|
||
* 僚机背包页
|
||
*
|
||
******************************************************************/
|
||
|
||
var MenuPage = require("cmp.com.menu.page");
|
||
var ItemExpand = require("nx.fx.sv.expand");
|
||
var ItemLayout = require("cmp.common.itemlayout");
|
||
var PathTool = require("pathtool");
|
||
var HallowsConst = require("hallows_const");
|
||
var HallowsEvent = require("hallows_event");
|
||
var HallowsController = require("hallows_controller");
|
||
var BackpackEvent = require("backpack_event");
|
||
var BackPackConst = require("backpack_const");
|
||
var PartnerCalculate = require("partner_calculate");
|
||
var FxTogs = require("nx.fx.togs");
|
||
var TipsController = require("tips_controller");
|
||
var NxSpine = require("nx.fx.spine");
|
||
cc.Class({
|
||
"extends": MenuPage,
|
||
properties: {
|
||
hallow_sp: {
|
||
"default": null,
|
||
type: NxSpine
|
||
},
|
||
tag_ico: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
hallow_empty: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
hallow_items: {
|
||
"default": null,
|
||
type: ItemExpand
|
||
},
|
||
info_list: {
|
||
"default": null,
|
||
type: ItemLayout
|
||
},
|
||
detail_list: {
|
||
"default": null,
|
||
type: ItemLayout
|
||
},
|
||
//任务界面相关
|
||
task_node: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
task_item_node: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
task_list: {
|
||
"default": null,
|
||
type: ItemLayout
|
||
},
|
||
task_attr_node: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
attr_skill_pre: {
|
||
"default": null,
|
||
type: cc.Prefab
|
||
},
|
||
skill_name: {
|
||
"default": null,
|
||
type: cc.RichText
|
||
},
|
||
skill_desc: {
|
||
"default": null,
|
||
type: cc.RichText
|
||
},
|
||
attr_labels: {
|
||
"default": [],
|
||
type: [cc.RichText]
|
||
},
|
||
task_complete_num: {
|
||
"default": null,
|
||
type: cc.RichText
|
||
},
|
||
//技能升级
|
||
use_node: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
use_togs: {
|
||
"default": null,
|
||
type: FxTogs
|
||
},
|
||
use_panel: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
pre_panels: {
|
||
"default": [],
|
||
type: [cc.Prefab]
|
||
},
|
||
//重铸
|
||
reset_btn: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
btn_gofight: {
|
||
"default": null,
|
||
type: cc.Node
|
||
},
|
||
no_task_tip: {
|
||
"default": null,
|
||
type: cc.Node
|
||
}
|
||
},
|
||
onLoad: function onLoad() {
|
||
this._super();
|
||
this.ctrl = HallowsController.getInstance();
|
||
this.model = this.ctrl.getModel();
|
||
|
||
// Tog监听
|
||
this.use_togs.posTog = this.onTogPanel.bind(this);
|
||
|
||
// 事件监听
|
||
//任务变化
|
||
this.bindGEvent(HallowsEvent.UpdateHallowsTaskEvent, this.updateHallowsTaskInfo.bind(this));
|
||
//数据更新
|
||
this.bindGEvent(HallowsEvent.HallowsUpdateEvent, this.updateHallow.bind(this));
|
||
//激活行星武器
|
||
this.bindGEvent(HallowsEvent.HallowsActivityEvent, this.actiHallows.bind(this));
|
||
this.bindGEvent(HallowsEvent.UpdateHallowsGet, this.refreshHallowsList.bind(this));
|
||
this.bindGEvent(HallowsEvent.UpdateHallowsDetailInfoList, this.updateHallowsItem.bind(this));
|
||
this.bindGEvent(BackpackEvent.ADD_GOODS, this.checkNeedUpdateItemNum.bind(this));
|
||
this.bindGEvent(BackpackEvent.MODIFY_GOODS_NUM, this.checkNeedUpdateItemNum.bind(this));
|
||
this.bindGEvent(BackpackEvent.DELETE_GOODS, this.checkNeedUpdateItemNum.bind(this));
|
||
},
|
||
//任务相关----------------------------
|
||
updateHallowsItem: function updateHallowsItem(hallows_id) {
|
||
this.updateHallowsList();
|
||
//初始化下部列表
|
||
this.hallow_items.rebuild(this.hallows_list);
|
||
this.hallow_items.addFocus(hallows_id - 1);
|
||
this.setMain(this.hallows_id);
|
||
},
|
||
updateHallow: function updateHallow(id, is_refine) {
|
||
if (this.is_in_use) {
|
||
this.handleUpdateEvent(id, is_refine);
|
||
} else {
|
||
if (id == this.hallows_id) {
|
||
this.refreshView();
|
||
}
|
||
}
|
||
},
|
||
actiHallows: function actiHallows() {
|
||
var hallows_id = this.model.getCurActivityHallowsId();
|
||
if (hallows_id) {
|
||
if (hallows_id <= 5) {
|
||
this.hallows_id = hallows_id;
|
||
} else {
|
||
this.refreshHallowsList();
|
||
}
|
||
this.ctrl.requestHallowsInfo();
|
||
this.refreshView();
|
||
this.handleEffect();
|
||
}
|
||
},
|
||
//任务相关----------------------------
|
||
updateHallowsList: function updateHallowsList() {
|
||
// 根据激活数和id重新排序,
|
||
var config_list = game.configs.hallows_data.data_base;
|
||
this.hallows_list = [];
|
||
this.hallows_sum = game.configs.hallows_data.data_base_length;
|
||
for (var i in config_list) {
|
||
var object = {};
|
||
object.id = config_list[i].id;
|
||
object.name = config_list[i].name;
|
||
object.effect = config_list[i].effect;
|
||
object.item_id = config_list[i].item_id;
|
||
object.open_desc = config_list[i].open_desc;
|
||
var vo = this.model.getHallowsById(config_list[i].id);
|
||
object.vo = vo;
|
||
this.hallows_list.push(object);
|
||
}
|
||
// 显示列表重新排序
|
||
if (Utils.next(this.hallows_list)) {
|
||
this.hallows_list.sort(function (a, b) {
|
||
return a.id - b.id;
|
||
});
|
||
}
|
||
},
|
||
refreshHallowsList: function refreshHallowsList() {
|
||
this.updateHallowsList();
|
||
|
||
//初始化下部列表
|
||
this.hallow_items.rebuild(this.hallows_list);
|
||
if (this.hallows_id != null) {
|
||
if (!this.model.checkIsHaveAllHallows()) {
|
||
this.is_in_use = false;
|
||
this.hallows_id = this.model.getCurActivityHallowsId();
|
||
this.use_node.active = false;
|
||
this.task_node.active = true;
|
||
} else {
|
||
var select_index = this.getDefaultHallowsIndex(this.hallows_id);
|
||
this.selectHallowsIndex(select_index);
|
||
this.is_in_use = true;
|
||
// this.hallows_id = 1;
|
||
this.use_node.active = true;
|
||
this.task_node.active = false;
|
||
this.use_togs.togTo(0);
|
||
this.use_togs.posTog(0);
|
||
}
|
||
this.hallow_items.addFocus(this.hallows_id - 1);
|
||
this.setMain(this.hallows_id);
|
||
}
|
||
},
|
||
onDisable: function onDisable() {
|
||
// 监听事件释放
|
||
this.unbindGEvents();
|
||
},
|
||
onEnable: function onEnable() {
|
||
this.refreshHallowsList();
|
||
//检查是否解锁所有行星武器
|
||
if (this.model.checkIsHaveAllHallows()) {
|
||
this.is_in_use = true;
|
||
var select_index = this.getDefaultHallowsIndex(null);
|
||
this.selectHallowsIndex(select_index);
|
||
this.hallows_id = this.hallows_list[select_index].id;
|
||
this.use_node.active = true;
|
||
this.use_togs.togTo(0);
|
||
this.use_togs.posTog(0);
|
||
} else {
|
||
this.is_in_use = false;
|
||
this.task_node.active = true;
|
||
this.hallows_id = this.model.getCurActivityHallowsId();
|
||
this.refreshView();
|
||
}
|
||
this.hallow_items.addFocus(this.hallows_id - 1);
|
||
this.setMain(this.hallows_id);
|
||
},
|
||
onTogPanel: function onTogPanel(_index) {
|
||
if (_index == HallowsConst.Tab_Index.uplv - 1) {
|
||
if (!this.step_panel) {
|
||
this.step_panel = cc.instantiate(this.pre_panels[_index]);
|
||
this.step_panel.parent = this.use_panel;
|
||
}
|
||
if (this.select_hallows) {
|
||
var cmp = this.step_panel.getComponent("cmp.hallows.main.lvup");
|
||
cmp.setData(this.select_hallows);
|
||
}
|
||
} else if (_index == HallowsConst.Tab_Index.skill - 1) {
|
||
if (!this.skill_panel) {
|
||
this.skill_panel = cc.instantiate(this.pre_panels[_index]);
|
||
this.skill_panel.parent = this.use_panel;
|
||
}
|
||
if (this.select_hallows) {
|
||
var _cmp = this.skill_panel.getComponent("cmp.hallows.main.skill");
|
||
_cmp.setData(this.select_hallows);
|
||
}
|
||
} else if (_index == HallowsConst.Tab_Index.refine - 1) {
|
||
if (!this.refine_panel) {
|
||
this.refine_panel = cc.instantiate(this.pre_panels[_index]);
|
||
this.refine_panel.parent = this.use_panel;
|
||
}
|
||
if (this.select_hallows) {
|
||
var _cmp2 = this.refine_panel.getComponent("cmp.hallows.main.refine");
|
||
_cmp2.setData(this.select_hallows);
|
||
}
|
||
}
|
||
if (this.step_panel) {
|
||
this.step_panel.active = _index == HallowsConst.Tab_Index.uplv - 1;
|
||
}
|
||
if (this.skill_panel) {
|
||
this.skill_panel.active = _index == HallowsConst.Tab_Index.skill - 1;
|
||
}
|
||
if (this.refine_panel) {
|
||
this.refine_panel.active = _index == HallowsConst.Tab_Index.refine - 1;
|
||
}
|
||
},
|
||
handleEffect: function handleEffect() {
|
||
var _this = this;
|
||
var cfg = null;
|
||
for (var i in this.hallows_list) {
|
||
if (this.hallows_list[i].id == this.hallows_id) {
|
||
cfg = this.hallows_list[i];
|
||
}
|
||
}
|
||
if (cfg == null) return;
|
||
this.hallow_sp.stop();
|
||
if (this.model.getHallowsById(this.hallows_id)) {
|
||
nx.gui.setActive(this.hallow_empty, "", false);
|
||
var effect_res = cfg.effect;
|
||
var effect_path = PathTool.getSpinePath(effect_res, "action", false);
|
||
this.hallow_sp.load(effect_path, function (_e) {
|
||
if (!_e) {
|
||
_this.hallow_sp.action("action", true);
|
||
} else {
|
||
_this.hallow_sp.stop();
|
||
}
|
||
});
|
||
nx.gui.setActive(this.tag_ico, "", true);
|
||
nx.gui.setSpriteFrame(this.tag_ico, "", cc.js.formatStr("prefab/partner/hallows/ui/%s", this.hallows_id));
|
||
} else {
|
||
//没有激活
|
||
nx.gui.setActive(this.hallow_empty, "", true);
|
||
nx.gui.setSpriteFrame(this.hallow_empty, "", cc.js.formatStr('resDB/empty/xj%s', this.hallows_id));
|
||
nx.gui.setActive(this.tag_ico, "", false);
|
||
}
|
||
},
|
||
setMain: function setMain(id) {
|
||
var cfg = null;
|
||
for (var i in this.hallows_list) {
|
||
if (this.hallows_list[i].id == id) {
|
||
cfg = this.hallows_list[i];
|
||
}
|
||
}
|
||
if (cfg == null) return;
|
||
this.handleEffect();
|
||
|
||
//初始化部分详细信息
|
||
var info_items = [];
|
||
var vo = cfg.vo;
|
||
if (vo) {
|
||
info_items.push(vo.step);
|
||
info_items.push(vo.skill_lev);
|
||
info_items.push(vo.refine_lev);
|
||
} else {
|
||
info_items = [0, 0, 0];
|
||
}
|
||
this.info_list.rebuild(info_items);
|
||
var detail_items = [];
|
||
for (var _i = 0; _i <= 2; _i++) {
|
||
detail_items.push(cfg);
|
||
}
|
||
this.detail_list.rebuild(detail_items);
|
||
},
|
||
onFocusHallowsItem: function onFocusHallowsItem(_item) {
|
||
// 空
|
||
if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) {
|
||
return;
|
||
}
|
||
|
||
// 聚焦
|
||
this.hallow_items.cleanFocus();
|
||
this.hallow_items.addFocus(_item.index);
|
||
this.hallows_id = this.hallows_list[_item.index].id || 1;
|
||
//检查是否解锁所有行星武器
|
||
if (this.model.checkIsHaveAllHallows()) {
|
||
this.is_in_use = true;
|
||
var select_index = this.getDefaultHallowsIndex(this.hallows_id);
|
||
this.selectHallowsIndex(select_index);
|
||
this.use_node.active = true;
|
||
this.task_node.active = false;
|
||
this.setPanel();
|
||
} else {
|
||
this.is_in_use = false;
|
||
this.use_node.active = false;
|
||
this.task_node.active = true;
|
||
this.refreshView();
|
||
}
|
||
this.setMain(this.hallows_id);
|
||
},
|
||
setPanel: function setPanel() {
|
||
if (this.use_togs.togIndex == 0) {
|
||
if (this.select_hallows) {
|
||
var cmp = this.step_panel.getComponent("cmp.hallows.main.lvup");
|
||
cmp.setData(this.select_hallows);
|
||
}
|
||
} else if (this.use_togs.togIndex == 1) {
|
||
if (this.select_hallows) {
|
||
var _cmp3 = this.skill_panel.getComponent("cmp.hallows.main.skill");
|
||
_cmp3.setData(this.select_hallows);
|
||
}
|
||
} else if (this.use_togs.togIndex == 2) {
|
||
if (this.select_hallows) {
|
||
var _cmp4 = this.refine_panel.getComponent("cmp.hallows.main.refine");
|
||
_cmp4.setData(this.select_hallows);
|
||
}
|
||
}
|
||
},
|
||
// 选中某一神器
|
||
selectHallowsIndex: function selectHallowsIndex(index, force, is_refine) {
|
||
// if(this.select_index == index && !force)return;
|
||
|
||
this.select_index = index;
|
||
this.select_hallows = this.hallows_list[index];
|
||
if (this.select_hallows == null) return;
|
||
this.reset_btn.active = this.checkIsShowResetBtn();
|
||
},
|
||
// 重载:关闭前
|
||
onPreClosed: function onPreClosed() {
|
||
this.hallow_items.rebuild([]);
|
||
this.info_list.rebuild([]);
|
||
this.detail_list.rebuild([]);
|
||
this.task_list.rebuild([]);
|
||
},
|
||
// 规则说明
|
||
onTouchTip: function onTouchTip() {
|
||
var TC = TipsController.getInstance();
|
||
if (TC) {
|
||
var txt = game.configs.hallows_data.data_const.game_rule;
|
||
TC.showTextPanel("tip", txt.desc);
|
||
}
|
||
},
|
||
// 取出进入界面时默认选中的神器index
|
||
getDefaultHallowsIndex: function getDefaultHallowsIndex(hallows_id) {
|
||
var temp_hallows_list = nx.dt.objClone(this.hallows_list);
|
||
var select_index = 0;
|
||
if (hallows_id) {
|
||
select_index = this.getHallowsIndexById(hallows_id);
|
||
} else {
|
||
//等级最高>进度最高>id越高
|
||
var temp_hallows = [];
|
||
temp_hallows_list.sort(function (a, b) {
|
||
return b.vo.step - a.vo.step;
|
||
});
|
||
var max_step = 0;
|
||
for (var i in temp_hallows_list) {
|
||
if (max_step <= temp_hallows_list[i].vo.step) {
|
||
max_step = temp_hallows_list[i].vo.step;
|
||
temp_hallows.push(temp_hallows_list[i]);
|
||
}
|
||
}
|
||
if (temp_hallows.length == 1) {
|
||
select_index = this.getHallowsIndexById(temp_hallows[0].id);
|
||
} else {
|
||
var max_lucky = 0;
|
||
temp_hallows.sort(function (a, b) {
|
||
return b.vo.lucky - a.vo.lucky;
|
||
});
|
||
var temp_hallows_2 = [];
|
||
for (var j in temp_hallows) {
|
||
var hallows = temp_hallows[j];
|
||
if (hallows.vo.lucky >= max_lucky) {
|
||
max_lucky = hallows.vo.lucky;
|
||
temp_hallows_2.push(hallows);
|
||
}
|
||
}
|
||
if (temp_hallows_2.length == 1) {
|
||
select_index = this.getHallowsIndexById(temp_hallows_2[0].id);
|
||
} else {
|
||
temp_hallows_2.sort(function (a, b) {
|
||
return b.id - a.id;
|
||
});
|
||
select_index = this.getHallowsIndexById(temp_hallows_2[0].id);
|
||
}
|
||
}
|
||
}
|
||
return select_index;
|
||
},
|
||
// 根据神器id获取对应的index
|
||
getHallowsIndexById: function getHallowsIndexById(id) {
|
||
var index = 1;
|
||
for (var i in this.hallows_list) {
|
||
if (this.hallows_list[i].id && this.hallows_list[i].id == id) {
|
||
index = i;
|
||
}
|
||
}
|
||
return index;
|
||
},
|
||
//---------------------任务界面
|
||
// 刷新界面
|
||
refreshView: function refreshView() {
|
||
this.updateHallowsTaskInfo();
|
||
this.updateHallowsSkillInfo();
|
||
},
|
||
//设置已解锁和正在进行的神器数据
|
||
// initUnlockHallowsData:function(hallows_id){
|
||
// this.all_hallows_id = [];
|
||
// var activity_id = this.model.getCurActivityHallowsId() // 正在进行中的神器id
|
||
// for (var i in game.configs.hallows_data.data_base) {
|
||
// var tempCfg = game.configs.hallows_data.data_base[i];
|
||
// if(this.model.getHallowsById(tempCfg.id) || tempCfg.id == activity_id){
|
||
// this.all_hallows_id.push(tempCfg.id);
|
||
// if(hallows_id && tempCfg.id == hallows_id){
|
||
// this.cur_index = this.all_hallows_id.length-1;
|
||
// }
|
||
// }
|
||
// }
|
||
// // this.left_btn.active = this.all_hallows_id.length>1;
|
||
// // this.right_btn.active = this.all_hallows_id.length>1;
|
||
// },
|
||
|
||
updateHallowsTaskInfo: function updateHallowsTaskInfo() {
|
||
var _this2 = this;
|
||
if (!this.hallows_id) return;
|
||
//判断是否已获得
|
||
if (this.model.getHallowsById(this.hallows_id)) {
|
||
this.task_attr_node.active = true;
|
||
this.task_item_node.active = false;
|
||
this.btn_gofight.active = true;
|
||
this.no_task_tip.active = false;
|
||
for (var i in this.base_attr_list) {
|
||
this.base_attr_list[i].active = false;
|
||
}
|
||
this.task_complete_num.string = nx.text.getKey("HallowTaskComplete");
|
||
var hallows_base = gdata("hallows_data", "data_info", Utils.getNorKey(this.hallows_id, 1));
|
||
if (hallows_base) {
|
||
for (var j in hallows_base.attr) {
|
||
if (j > 2) break; //UI只支持显示两个技能
|
||
var attr_key = hallows_base.attr[j][0];
|
||
var attr_val = hallows_base.attr[j][1] || 0;
|
||
var attr_name = game.configs.attr_data.data_key_to_name[attr_key];
|
||
if (attr_name) {
|
||
var icon = cc.js.formatStr("coms/images/ico_%s", attr_key);
|
||
var is_per = PartnerCalculate.isShowPerByStr(attr_key);
|
||
if (is_per) {
|
||
attr_val = attr_val / 10 + "%";
|
||
}
|
||
this.attr_labels[j].string = nx.text.getKey("lab_hallows_task_windoiw_tip2") + attr_name + ":" + attr_val.toString();
|
||
// cc.loader.loadRes( icon, cc.SpriteFrame, ( err, resObject ) => {
|
||
// if( err ) {
|
||
// return false;
|
||
// }
|
||
// this.attr_labels[ j ].addSpriteFrame( resObject );
|
||
// } );
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
this.task_attr_node.active = false;
|
||
this.task_item_node.active = true;
|
||
this.btn_gofight.active = false;
|
||
this.no_task_tip.active = true;
|
||
var task_list = this.model.getHallowsTaskList(this.hallows_id);
|
||
task_list.sort(function (a, b) {
|
||
return b.sort - a.sort;
|
||
});
|
||
if (task_list) {
|
||
var max_num = task_list.length;
|
||
var cur_num = 0;
|
||
for (var k in task_list) {
|
||
if (task_list[k].finish == 2) {
|
||
cur_num = cur_num + 1;
|
||
}
|
||
}
|
||
this.task_complete_num.string = nx.text.getKey("HallowTaskProg") + cur_num + "/" + max_num;
|
||
}
|
||
this.task_list.rebuild(task_list);
|
||
|
||
// 引导辅助
|
||
if (nx.bridge.plot && nx.bridge.plot.isDoing()) {
|
||
this.scheduleOnce(function () {
|
||
_this2.positionGet();
|
||
}, 0.1);
|
||
}
|
||
}
|
||
},
|
||
updateHallowsSkillInfo: function updateHallowsSkillInfo() {
|
||
if (!this.hallows_id) return;
|
||
var hallows_skill = gdata("hallows_data", "data_skill_up", Utils.getNorKey(this.hallows_id, 1)); // 显示1级时的技能
|
||
if (hallows_skill && hallows_skill.skill_bid != 0) {
|
||
var config = gskilldata("data_get_skill", hallows_skill.skill_bid) || {};
|
||
if (!this.skill_icon) {
|
||
this.skill_icon = cc.instantiate(this.attr_skill_pre);
|
||
this.skill_icon.parent = this.task_attr_node;
|
||
this.skill_icon.position = cc.v2(-175, 60);
|
||
}
|
||
var cmp = this.skill_icon.getComponent("cmp.skill.base");
|
||
cmp.rebind(0, config.bid, "");
|
||
this.skill_name.string = cc.js.formatStr("%s <color=#27ae10>[Lv.%s]</color>", config.name, hallows_skill.lev_limit);
|
||
this.skill_desc.string = cc.js.formatStr(config.des, config.hallows_atk, 0);
|
||
}
|
||
},
|
||
//---------------------任务界面
|
||
checkNeedUpdateItemNum: function checkNeedUpdateItemNum(bag_code, item_list) {
|
||
if (bag_code != BackPackConst.Bag_Code.BACKPACK) return;
|
||
if (item_list == null) return;
|
||
for (var i in item_list) {
|
||
var vo = item_list[i];
|
||
if (vo.config) {
|
||
var bid = vo.config.id;
|
||
this.updateCostItemNumByBid(bid);
|
||
}
|
||
}
|
||
},
|
||
updateCostItemNumByBid: function updateCostItemNumByBid(bid) {
|
||
if (!bid) {
|
||
return;
|
||
}
|
||
var cmp = null;
|
||
if (this.step_panel) {
|
||
cmp = this.step_panel.getComponent("cmp.hallows.main.lvup");
|
||
} else if (this.skill_panel) {
|
||
cmp = this.skill_panel.getComponent("cmp.hallows.main.skill");
|
||
} else if (this.refine_panel) {
|
||
cmp = this.refine_panel.getComponent("cmp.hallows.main.refine");
|
||
}
|
||
if (cmp == null) return;
|
||
cmp.getCostObj(bid);
|
||
// if (bid == this.hallows_uplv_cost_bid_1) {
|
||
// this.setCostDataToNode(this.lvup_cost_res_1, this.lvup_cost_label_1, bid, this.hallows_uplv_cost_num_1)
|
||
// } else if (bid == this.hallows_uplv_cost_bid_2) {
|
||
// this.setCostDataToNode(this.lvup_cost_res_2, this.lvup_cost_label_2, bid, this.hallows_uplv_cost_num_2)
|
||
// } else if (bid == this.skill_lvup_cost_bid_1) {
|
||
// this.setCostDataToNode(this.skill_res_icon_1, this.skill_cost_label_1, bid, this.skill_lvup_cost_num_1)
|
||
// } else if (bid == this.skill_lvup_cost_bid_2) {
|
||
// this.setCostDataToNode(this.skill_res_icon_2, this.skill_cost_label_2, bid, this.skill_lvup_cost_num_2)
|
||
// }
|
||
// if (bid == this.refine_cost_bid_1) {
|
||
// let is_full = this.setCostDataToNode(this.refine_res_icon_1, this.refine_cost_label_1, bid, this.refine_cost_num_1)
|
||
// if (is_full) {
|
||
// this.is_can_refine_2 = true
|
||
// } else {
|
||
// this.is_can_refine_2 = false
|
||
// }
|
||
// }
|
||
// if (bid == this.refine_cost_bid_2) {
|
||
// let is_full = this.setCostDataToNode(this.refine_res_icon_2, this.refine_cost_label_2, bid, this.refine_cost_num_2)
|
||
// if (is_full) {
|
||
// this.is_can_refine_3 = true
|
||
// } else {
|
||
// this.is_can_refine_3 = false
|
||
// }
|
||
// }
|
||
},
|
||
|
||
// 是否显示重铸按钮
|
||
checkIsShowResetBtn: function checkIsShowResetBtn() {
|
||
var is_show = false;
|
||
if (this.select_hallows == null) {
|
||
return is_show;
|
||
}
|
||
var vo = this.select_hallows.vo;
|
||
if (vo == null) {
|
||
return is_show;
|
||
}
|
||
if (vo.step > 1 || vo.seal > 0 || vo.skill_lev > 1 || vo.refine_lev > 0) {
|
||
is_show = true;
|
||
}
|
||
return is_show;
|
||
},
|
||
//圣器更新处理
|
||
handleUpdateEvent: function handleUpdateEvent(id, is_refine) {
|
||
if (id && this.select_hallows && id == this.select_hallows.id) {
|
||
this.selectHallowsIndex(this.select_index, true, is_refine);
|
||
this.updateHallowStatusInfo();
|
||
}
|
||
},
|
||
//设置神器升级与技能状态显示
|
||
updateHallowStatusInfo: function updateHallowStatusInfo() {
|
||
if (this.select_hallows == null) return;
|
||
var vo = this.select_hallows.vo;
|
||
if (vo == null) {
|
||
return;
|
||
} else {
|
||
//神器是否达到最大等级
|
||
var max_lev = game.configs.hallows_data.data_max_lev[vo.id] || 100;
|
||
if (vo.step >= max_lev) {
|
||
this.is_max_hallows_lv = true;
|
||
// this.uplv_layout.active = false;
|
||
} else {
|
||
this.is_max_hallows_lv = false;
|
||
// this.uplv_layout.active = true;
|
||
}
|
||
//技能是否达到最大等级
|
||
var max_skill_lv = game.configs.hallows_data.data_skill_max_lev[vo.id] || 10;
|
||
var skill_lv = vo.skill_lev;
|
||
if (skill_lv >= max_skill_lv) {
|
||
this.is_max_skill_lv = true;
|
||
// this.skill_layout.active = false;
|
||
} else {
|
||
this.is_max_skill_lv = false;
|
||
// this.skill_layout.active = true;
|
||
}
|
||
//精炼是否达到最大等级
|
||
var max_refine_lv = game.configs.hallows_refine_data.data_max_lev[vo.id] || 9;
|
||
if (vo.refine_lev >= max_refine_lv) {
|
||
this.is_max_refine_lv = true;
|
||
// this.refine_layout.active = false;
|
||
// nx.gui.setActive(this.refine_max_lv,"",true);
|
||
} else {
|
||
this.is_max_refine_lv = false;
|
||
// this.refine_layout.active = true;
|
||
// nx.gui.setActive(this.refine_max_lv,"",false);
|
||
}
|
||
|
||
//更新神器升级与技能显示
|
||
if (!this.is_max_hallows_lv) {
|
||
if (this.step_panel) {
|
||
var cmp = this.step_panel.getComponent("cmp.hallows.main.lvup");
|
||
cmp.setData(this.select_hallows);
|
||
}
|
||
}
|
||
if (!this.is_max_skill_lv) {
|
||
if (this.skill_panel) {
|
||
var _cmp5 = this.skill_panel.getComponent("cmp.hallows.main.skill");
|
||
_cmp5.setData(this.select_hallows);
|
||
}
|
||
}
|
||
if (!this.is_max_refine_lv) {
|
||
if (this.refine_panel) {
|
||
var _cmp6 = this.refine_panel.getComponent("cmp.hallows.main.refine");
|
||
_cmp6.setData(this.select_hallows);
|
||
}
|
||
}
|
||
var info_items = [];
|
||
if (vo) {
|
||
info_items.push(vo.step);
|
||
info_items.push(vo.skill_lev);
|
||
info_items.push(vo.refine_lev);
|
||
} else {
|
||
info_items = [0, 0, 0];
|
||
}
|
||
this.info_list.rebuild(info_items);
|
||
var detail_items = [];
|
||
for (var i = 0; i <= 2; i++) {
|
||
detail_items.push(this.select_hallows);
|
||
}
|
||
this.detail_list.rebuild(detail_items);
|
||
// this.info_list.rebuild(this.hallows_list);
|
||
// this.detail_list.rebuild(this.hallows_list);
|
||
}
|
||
},
|
||
clickHallowsDetail: function clickHallowsDetail() {
|
||
this.ctrl.send24140(this.hallows_id || this.select_hallows.id);
|
||
// this.ctrl.openHallowsTips(true,this.hallows_id||this.select_hallows);
|
||
},
|
||
|
||
// 点击重铸
|
||
onClickResetBtn: function onClickResetBtn() {
|
||
var _this3 = this;
|
||
if (this.step_panel) {
|
||
var cmp = this.step_panel.getComponent("cmp.hallows.main.lvup");
|
||
var status = cmp.getLvupStatus();
|
||
if (status) {
|
||
return;
|
||
}
|
||
}
|
||
var str = nx.text.getKey("lab_hallows_main_window_tip13");
|
||
nx.mbox(str, ["cancel", "confirm"], function (_key, _box) {
|
||
_box.close();
|
||
if (_key == "confirm") {
|
||
if (_this3.select_hallows) {
|
||
_this3.ctrl.requestHallowsReset(_this3.select_hallows.id);
|
||
}
|
||
}
|
||
});
|
||
},
|
||
onClickTraceBtn: function onClickTraceBtn() {
|
||
if (this.select_hallows) {
|
||
if (!this.select_hallows.vo) {
|
||
nx.tbox("lab_hallows_main_window_tip12");
|
||
} else {
|
||
var cost_config = game.configs.hallows_data.data_const.imprint_lowest;
|
||
if (cost_config) {
|
||
if (this.select_hallows.vo.step < cost_config.val) {
|
||
nx.tbox(cost_config.desc);
|
||
} else {
|
||
this.ctrl.openHallowsTraceWindow(true, this.select_hallows);
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
nx.tbox("lab_hallows_main_window_tip12");
|
||
}
|
||
},
|
||
// ============================================
|
||
// 引导辅助
|
||
// ============================================
|
||
|
||
// 首次领奖定位
|
||
positionGet: function positionGet() {
|
||
// 查找第一个能领取的任务
|
||
var node = null;
|
||
var children = this.task_list.node.children;
|
||
for (var i = 0; i < children.length; ++i) {
|
||
var temp = children[i];
|
||
if (temp && nx.gui.isActive(temp, "btn_get")) {
|
||
node = temp;
|
||
break;
|
||
}
|
||
}
|
||
if (!node) {
|
||
nx.error("$HallowsPage:定位首次领奖失败!");
|
||
node = children[0];
|
||
if (!node) {
|
||
return;
|
||
}
|
||
}
|
||
var btn = nx.gui.find(node, "btn_get");
|
||
var cell = nx.gui.find(this, "panel/plotCell");
|
||
var pos = btn.convertToWorldSpaceAR(cc.Vec2.ZERO);
|
||
cell.position = cell.parent.convertToNodeSpaceAR(pos);
|
||
cell.width = btn.width;
|
||
cell.height = btn.height;
|
||
cell.cmp = nx.gui.getComponent(node, "", "cmp.hallows.item.task");
|
||
},
|
||
// 点击首次领奖处理
|
||
onTouchFirstGet: function onTouchFirstGet() {
|
||
var cell = nx.gui.find(this, "panel/plotCell");
|
||
if (cell && cell.cmp) {
|
||
cell.cmp.clickGetItem();
|
||
}
|
||
}
|
||
});
|
||
|
||
cc._RF.pop(); |