450 lines
14 KiB
JavaScript
450 lines
14 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'da0a1aYbppICbeR4lVnVrzB', 'cmp.partner.holy.select.wnd');
|
|
// Scripts/mod/partner/cmps/artifact/cmp.partner.holy.select.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 礼包选择界面
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var FxSVC = require("nx.fx.sv.expand");
|
|
var BackPackConst = require("backpack_const");
|
|
var BackPackController = require("backpack_controller");
|
|
var FxTogs = require("nx.fx.togs");
|
|
var HeroConst = require("hero_const");
|
|
var HeroEvent = require("hero_event");
|
|
var HeroControl = require("hero_controller");
|
|
var HEHY = HeroConst.HolyequipmentPosList;
|
|
var HolyTitle = HeroConst.HolyTitle;
|
|
var BBC = BackPackConst.Bag_Code;
|
|
var BIT = BackPackConst.item_type;
|
|
var BITT = BackPackConst.item_sub_type;
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
svcList: {
|
|
"default": null,
|
|
type: FxSVC
|
|
},
|
|
nodPartner: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodHoly: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodSortStar: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodSortSet: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodSuitDes: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
onLoad: function onLoad() {
|
|
var tmp = nx.gui.getComponent(this.nodSortStar, "lst/view/content", FxTogs);
|
|
var tmp1 = nx.gui.getComponent(this.nodSortSet, "lst/view/content", FxTogs);
|
|
this.set = 0;
|
|
this.star = 0;
|
|
tmp.posTog = this.onTogMenu.bind(this);
|
|
tmp1.posTog = this.onTogMenu1.bind(this);
|
|
this.bindGEvent(HeroEvent.Holy_Equipment_Update_Event, this.onHolyUpdate.bind(this));
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
|
this.holyLst = _params.holyLst;
|
|
nx.gui.setActive(this.nodSortStar, "lst", false);
|
|
nx.gui.setActive(this.nodSortSet, "lst", false);
|
|
this.etype = _params.etype;
|
|
this.partner = _params.partner;
|
|
this.cb = _params.cb;
|
|
this.cboff = _params.cboff;
|
|
this.planid = _params.planid || 0;
|
|
// console.log( this.etype + "当前的类型—神装数据" + JSON.stringify( this.holyLst ) );
|
|
var cmp = this.nodPartner.getComponent("cmp.item.base");
|
|
if (cmp) {
|
|
cmp.setData(this.partner);
|
|
}
|
|
var count = Object.keys(HolyTitle).length;
|
|
var cfgss = nx.dt.objClone(game.configs.partner_holy_eqm_data.data_suit_res_prefix);
|
|
cfgss[0] = {
|
|
"id": 0,
|
|
"name": "AllSets",
|
|
"prefix": "AllSets"
|
|
};
|
|
var count_set = game.configs.partner_holy_eqm_data.data_suit_res_prefix_length;
|
|
nx.gui.gocChildren(this.nodSortStar, "lst/view/content", count);
|
|
nx.gui.gocChildren(this.nodSortSet, "lst/view/content", count_set + 1);
|
|
var nods = nx.gui.find(this.nodSortStar, "lst/view/content").children;
|
|
var nodset = nx.gui.find(this.nodSortSet, "lst/view/content").children;
|
|
for (var i in HolyTitle) {
|
|
var item = HolyTitle[i];
|
|
var node = nods[i];
|
|
nx.gui.setString(node, "on/txt", nx.text.getKey(item));
|
|
nx.gui.setString(node, "off/txt", nx.text.getKey(item));
|
|
}
|
|
for (var d in cfgss) {
|
|
var _item2 = cfgss[d];
|
|
var _node = nodset[d];
|
|
nx.gui.setString(_node, "on/txt", nx.text.getKey(_item2.prefix));
|
|
nx.gui.setString(_node, "off/txt", nx.text.getKey(_item2.prefix));
|
|
}
|
|
this.onTouchSlot(this.etype);
|
|
},
|
|
onTouchSortStar: function onTouchSortStar() {
|
|
nx.gui.setActive(this.nodSortStar, "lst", !nx.gui.find(this.nodSortStar, "lst").active);
|
|
nx.gui.setActive(this.nodSortSet, "lst", false);
|
|
var dpath = cc.path.join("prefab/partner/holy/ui", "partner_94");
|
|
var upath = cc.path.join("prefab/partner/holy/ui", "partner_95");
|
|
nx.gui.setSpriteFrame(this.nodSortStar, "bg/op/bg", nx.gui.find(this.nodSortStar, "lst").active ? upath : dpath);
|
|
},
|
|
onTouchSortSet: function onTouchSortSet() {
|
|
nx.gui.setActive(this.nodSortStar, "lst", false);
|
|
nx.gui.setActive(this.nodSortSet, "lst", !nx.gui.find(this.nodSortSet, "lst").active);
|
|
var dpath = cc.path.join("prefab/partner/holy/ui", "partner_94");
|
|
var upath = cc.path.join("prefab/partner/holy/ui", "partner_95");
|
|
nx.gui.setSpriteFrame(this.nodSortSet, "bg/op/bg", nx.gui.find(this.nodSortSet, "lst").active ? upath : dpath);
|
|
},
|
|
onTouchSlot: function onTouchSlot(_index) {
|
|
this.nowSelect = _index;
|
|
var num = parseInt(_index);
|
|
// 空处理
|
|
var slots = this.nodHoly;
|
|
this.onHolyUpdate();
|
|
for (var pos in HEHY) {
|
|
// 当前装备
|
|
var slot = nx.gui.find(slots, "slot" + pos);
|
|
var cmp = nx.gui.getComponent(slot, "", "cmp.item.base");
|
|
if (pos == num) {
|
|
if (cmp) {
|
|
cmp.onFocus();
|
|
// console.log( "当前的数据ssss" + JSON.stringify( cmp.mdata ) );
|
|
if (cmp.mdata && !nx.dt.objEmpty(cmp.mdata)) {
|
|
nx.gui.setActive(slot, "off", true);
|
|
} else {
|
|
nx.gui.setActive(slot, "off", false);
|
|
}
|
|
}
|
|
} else {
|
|
if (cmp) {
|
|
cmp.outFocus();
|
|
}
|
|
}
|
|
}
|
|
this.freshLst(num);
|
|
},
|
|
freshLst: function freshLst(_type) {
|
|
var BC = BackPackController.getInstance();
|
|
var model = BC.getModel();
|
|
// 统计该类型装备列表
|
|
var eqms = [];
|
|
var list = {};
|
|
if (_type == BIT.GOD_EARRING || _type == BIT.GOD_RING || _type == BIT.GOD_NECKLACE || _type == BIT.GOD_BANGLE) {
|
|
list = model.getAllBackPackArray(BITT.HOLYEQUIPMENT) || {};
|
|
}
|
|
|
|
// 统计匹配项
|
|
for (var i in list) {
|
|
var eqm = list[i];
|
|
if (eqm && eqm.config && eqm.config.type == _type) {
|
|
eqms.push(eqm);
|
|
}
|
|
}
|
|
// console.log( "当前的holy数据" + JSON.stringify( eqms ) );
|
|
var empty = nx.dt.arrEmpty(eqms);
|
|
// 刷新
|
|
nx.gui.setActive(this.svcList, "empty", empty);
|
|
// this.svcList.rebuild( eqms );
|
|
this.svcList.binder = this;
|
|
var tmp2 = nx.gui.getComponent(this.nodSortSet, "lst/view/content", FxTogs);
|
|
tmp2.rebuildTogs();
|
|
tmp2._freshTogShow();
|
|
tmp2.togTo(this.set || 0);
|
|
this.onTogMenu1(this.set || 0);
|
|
var tmp = nx.gui.getComponent(this.nodSortStar, "lst/view/content", FxTogs);
|
|
tmp.rebuildTogs();
|
|
tmp._freshTogShow();
|
|
tmp.togTo(this.star || 0);
|
|
this.onTogMenu(this.star || 0);
|
|
// if( this.set >= 0 || this.star >= 0 ){
|
|
// console.log( this.star + "套裝" + this.set );
|
|
// this.dealShow( this.star, this.set );
|
|
// }
|
|
// 引导辅助
|
|
if (nx.bridge.plot && nx.bridge.plot.isDoing()) {
|
|
this.positionWear();
|
|
}
|
|
},
|
|
onHolyUpdate: function onHolyUpdate() {
|
|
var HC = HeroControl.getInstance();
|
|
var slots = this.nodHoly;
|
|
var holy_eqm_list = {};
|
|
if (this.planid.id > 0) {
|
|
var allPlan = HC.getModel().getHolyEquipmentPlanData();
|
|
var pland = [];
|
|
for (var i in allPlan) {
|
|
var plan = allPlan[i];
|
|
if (plan.id == this.planid.id) {
|
|
pland = plan.list;
|
|
}
|
|
}
|
|
this.holyLst = pland;
|
|
// console.log( JSON.stringify( pland ) + "更换后的数据显示为" );
|
|
} else {
|
|
var holyLst = [];
|
|
var eqms = HC.getModel().getHeroHolyEquipList(this.partner.partner_id);
|
|
for (var _i in eqms) {
|
|
var eqm = eqms[_i];
|
|
holyLst.push({
|
|
partner_id: this.partner.partner_id,
|
|
item_id: eqm.id
|
|
});
|
|
}
|
|
this.holyLst = holyLst;
|
|
}
|
|
holy_eqm_list = this.getAllHolyLst(this.holyLst);
|
|
// console.log( "当前的装备数据----->>>>>" + JSON.stringify( holy_eqm_list ) );
|
|
var empty = function empty(_sc) {
|
|
if (_sc === void 0) {
|
|
_sc = false;
|
|
}
|
|
// 卡槽置空
|
|
slots.children.forEach(function (_c) {
|
|
nx.gui.setActive(_c, "empty", true);
|
|
nx.gui.setActive(_c, "focus", false);
|
|
nx.gui.setActive(_c, "off", false);
|
|
});
|
|
};
|
|
|
|
// 判空
|
|
if (nx.dt.objEmpty(this.partner) && this.partner != 0) {
|
|
empty(true);
|
|
return;
|
|
}
|
|
for (var pos in HEHY) {
|
|
var _eqm2 = holy_eqm_list[pos];
|
|
|
|
// 当前装备
|
|
var emt = nx.dt.objEmpty(_eqm2);
|
|
var slot = nx.gui.find(slots, "slot" + pos);
|
|
nx.gui.setActive(slot, "off", !emt);
|
|
nx.gui.setActive(slot, "empty", emt);
|
|
var cmp = nx.gui.getComponent(slot, "", "cmp.item.base");
|
|
if (!emt) {
|
|
if (cmp) {
|
|
cmp.setData(_eqm2);
|
|
}
|
|
} else {
|
|
cmp.setData(null);
|
|
}
|
|
}
|
|
var lst = HeroControl.getInstance().getModel().getHolyEquipSuitDes(holy_eqm_list);
|
|
nx.gui.setActive(this.nodSuitDes, "", !nx.dt.arrEmpty(lst));
|
|
if (!nx.dt.arrEmpty(lst)) {
|
|
var nod = this.nodSuitDes;
|
|
for (var _i2 = 0; _i2 < nod.children.length; _i2++) {
|
|
var des = lst[_i2];
|
|
if (des) {
|
|
nx.gui.setString(nod.children[_i2], "", des.name);
|
|
} else {
|
|
nx.gui.setString(nod.children[_i2], "", "");
|
|
}
|
|
}
|
|
}
|
|
},
|
|
getAllHolyLst: function getAllHolyLst(_list) {
|
|
if (!_list) {
|
|
return;
|
|
}
|
|
;
|
|
if (_list.length == 0) {
|
|
return {};
|
|
}
|
|
;
|
|
var holy_list = {}; //神装数据
|
|
for (var k in _list) {
|
|
var v = _list[k];
|
|
if (v.item_id) {
|
|
var item_vo = {};
|
|
if (v.partner_id == 0) {
|
|
//在装备背包中
|
|
item_vo = BackPackController.getInstance().getModel().getBagItemById(BackPackConst.Bag_Code.EQUIPS, v.item_id);
|
|
} else {
|
|
//英雄已穿戴
|
|
item_vo = HeroControl.getInstance().getModel().getHolyEquipById(v.item_id);
|
|
}
|
|
if (item_vo && item_vo.config) {
|
|
holy_list[item_vo.config.type] = item_vo;
|
|
}
|
|
}
|
|
}
|
|
return holy_list;
|
|
},
|
|
// 选中装备
|
|
onEquip: function onEquip(_item) {
|
|
var _this = this;
|
|
var HC = HeroControl.getInstance();
|
|
if (_item && nx.dt.numPositive(_item.id, false)) {
|
|
if (this.planid != 0) {
|
|
data = {
|
|
eqm: _item.id,
|
|
partner: this.partner,
|
|
mdata: this.planid,
|
|
type: this.etype
|
|
};
|
|
nx.dt.fnInvoke(this.cb, data, this);
|
|
} else {
|
|
nx.dt.fnInvoke(this.cb, _item.id, this);
|
|
}
|
|
this.scheduleOnce(function () {
|
|
_this.onTouchSlot(_this.nowSelect);
|
|
}, 0.3);
|
|
}
|
|
},
|
|
// 选中装备
|
|
onEquipOff: function onEquipOff(_index) {
|
|
var _this2 = this;
|
|
var slots = this.nodHoly;
|
|
var eqm = {};
|
|
var HC = HeroControl.getInstance();
|
|
for (var pos in HEHY) {
|
|
// 当前装备
|
|
var slot = nx.gui.find(slots, "slot" + pos);
|
|
var cmp = nx.gui.getComponent(slot, "", "cmp.item.base");
|
|
if (pos == _index) {
|
|
if (cmp) {
|
|
eqm = cmp.mdata;
|
|
}
|
|
}
|
|
}
|
|
var data = {};
|
|
if (this.planid != 0) {
|
|
data = {
|
|
eqm: eqm.id,
|
|
partner: this.partner,
|
|
mdata: this.planid
|
|
};
|
|
} else {
|
|
data = {
|
|
eqm: eqm.id,
|
|
partner: this.partner
|
|
};
|
|
}
|
|
nx.dt.fnInvoke(this.cboff, data, this);
|
|
this.scheduleOnce(function () {
|
|
_this2.onTouchSlot(_this2.nowSelect);
|
|
}, 0.3);
|
|
},
|
|
onTogMenu: function onTogMenu(_index) {
|
|
this.unscheduleAllCallbacks();
|
|
this.star = _index;
|
|
// console.log( "当前选择相关" + _index );
|
|
var nods = nx.gui.find(this.nodSortStar, "lst/view/content").children;
|
|
var nod = nods[_index];
|
|
var txt = nx.gui.getComponent(nod, "on/txt", cc.Label);
|
|
if (txt) {
|
|
nx.gui.setString(this.nodSortStar, "bg/txt", txt.string);
|
|
}
|
|
this.dealShow(this.star, this.set);
|
|
},
|
|
onTogMenu1: function onTogMenu1(_index) {
|
|
// console.log( "当前选择相关2" + _index );
|
|
this.set = _index;
|
|
var nods = nx.gui.find(this.nodSortSet, "lst/view/content").children;
|
|
var nod = nods[_index];
|
|
var txt = nx.gui.getComponent(nod, "on/txt", cc.Label);
|
|
if (txt) {
|
|
nx.gui.setString(this.nodSortSet, "bg/txt", txt.string);
|
|
}
|
|
this.dealShow(this.star, this.set);
|
|
},
|
|
dealShow: function dealShow(_star, _set) {
|
|
var _this3 = this;
|
|
var BC = BackPackController.getInstance();
|
|
var model = BC.getModel();
|
|
var list = {};
|
|
if (this.nowSelect == BIT.GOD_EARRING || this.nowSelect == BIT.GOD_RING || this.nowSelect == BIT.GOD_NECKLACE || this.nowSelect == BIT.GOD_BANGLE) {
|
|
list = model.getAllBackPackArray(BITT.HOLYEQUIPMENT) || {};
|
|
}
|
|
var show = [];
|
|
var eqms = [];
|
|
// 统计匹配项
|
|
for (var i in list) {
|
|
var eqm = list[i];
|
|
if (eqm && eqm.config && eqm.config.type == this.nowSelect) {
|
|
eqms.push(eqm);
|
|
}
|
|
}
|
|
eqms.forEach(function (_eqm) {
|
|
if (_star != 0) {
|
|
if (_set != 0) {
|
|
if (_eqm.config.eqm_star == _star && parseInt(_eqm.config.eqm_set / 100) == _this3.set) {
|
|
show.push(_eqm);
|
|
}
|
|
// nx.gui.setActive( item, "", cmp.mdata.config.eqm_star == _star && parseInt( cmp.mdata.config.eqm_set / 100 ) == ( this.set ) );
|
|
} else {
|
|
if (_eqm.config.eqm_star == _star) {
|
|
show.push(_eqm);
|
|
}
|
|
}
|
|
} else {
|
|
if (_set != 0) {
|
|
if (parseInt(Math.floor(_eqm.config.eqm_set / 100)) == _this3.set) {
|
|
show.push(_eqm);
|
|
}
|
|
} else {
|
|
show.push(_eqm);
|
|
}
|
|
}
|
|
});
|
|
show.sort(Utils.tableUpperSorter(["all_score"]));
|
|
this.svcList.rebuild(show);
|
|
},
|
|
/****
|
|
* 引导 -------
|
|
*/
|
|
|
|
// 定位最弱的一个
|
|
positionWear: function positionWear() {
|
|
var node = null;
|
|
var chd = nx.gui.find(this.svcList.bindSCV, "view/content");
|
|
if (chd) {
|
|
var nodes = chd.children;
|
|
node = nodes[0];
|
|
if (!node) {
|
|
nx.error("$ParterPage:定位特定英雄失败!");
|
|
node = chd[0];
|
|
if (!node) {
|
|
return;
|
|
}
|
|
}
|
|
var cell = nx.gui.find(this, "plotd");
|
|
var pos = node.convertToWorldSpaceAR(cc.Vec2.ZERO);
|
|
cell.position = cell.parent.convertToNodeSpaceAR(pos);
|
|
cell.width = node.width;
|
|
cell.height = node.height;
|
|
cell.svItem = node.svItem;
|
|
cell.mdata = node.svItem.mdata;
|
|
cell.index = node.svItem.index;
|
|
nx.gui.setActive(this, "plotd", true);
|
|
}
|
|
},
|
|
onTouchSelf: function onTouchSelf(_nod) {
|
|
var nod = nx.gui.find(this, "plotd");
|
|
if (nod) {
|
|
nod.svItem.onTouchEquip();
|
|
}
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |