216 lines
6.2 KiB
JavaScript
216 lines
6.2 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'f0b82ORo1RA/JSIR23WzDNd', 'cmp.partner.page');
|
|
// Scripts/mod/partner/cmps/bag/cmp.partner.page.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 伙伴背包页
|
|
*
|
|
******************************************************************/
|
|
|
|
var FxTogs = require("nx.fx.togs");
|
|
var FxSVC = require("nx.fx.sv.expand");
|
|
var MenuPage = require("cmp.com.menu.page");
|
|
var HeroConst = require("hero_const");
|
|
var HeroEvent = require("hero_event");
|
|
var HeroControl = require("hero_controller");
|
|
var HCT = HeroConst.CampType;
|
|
cc.Class({
|
|
"extends": MenuPage,
|
|
properties: {
|
|
togCamp: {
|
|
"default": null,
|
|
type: FxTogs
|
|
},
|
|
svcList: {
|
|
"default": null,
|
|
type: FxSVC
|
|
}
|
|
},
|
|
// 载入
|
|
onLoad: function onLoad() {
|
|
var _this = this;
|
|
this._super();
|
|
|
|
// 事件监听
|
|
this.bindGEvent(HeroEvent.Buy_Hero_Max_Count_Event, this.onBuyMaxHeroCount.bind(this));
|
|
this.bindGEvent(HeroEvent.Del_Hero_Event, this.onADHeros.bind(this));
|
|
this.bindGEvent(HeroEvent.Hero_Data_Add, this.onADHeros.bind(this));
|
|
this.bindGEvent(HeroEvent.All_Hero_Base_Info_Event, this.onHeroInfoFresh.bind(this));
|
|
this.bindGEvent(HeroEvent.Hero_Data_Update, this.onHeroInfoFreshSingle.bind(this));
|
|
this.bindGEvent(HeroEvent.Equip_Update_Event, this.onHeroInfoFreshSingle.bind(this));
|
|
this.curCamp = -1;
|
|
|
|
// Tog监听
|
|
this.togCamp.posTog = this.onTogCamp.bind(this);
|
|
this.togCamp.togTo(0);
|
|
nx.bridge.vset("ShowPartner", {});
|
|
this.scheduleOnce(function () {
|
|
_this.onTogCamp(HCT.eNone);
|
|
}, 0.02);
|
|
},
|
|
// 重载:关闭前
|
|
onPreClosed: function onPreClosed() {
|
|
this.unscheduleAllCallbacks();
|
|
this.svcList.rebuild([]);
|
|
},
|
|
// 购买伙伴上限返回
|
|
onBuyMaxHeroCount: function onBuyMaxHeroCount() {},
|
|
// 伙伴增删
|
|
onADHeros: function onADHeros(_lst) {
|
|
var upd = false;
|
|
for (var i in _lst) {
|
|
var ho = _lst[i];
|
|
if (ho && (ho.camp_type == this.curCamp || this.curCamp == 0)) {
|
|
upd = true;
|
|
break;
|
|
}
|
|
}
|
|
if (upd) {
|
|
this.freshList();
|
|
}
|
|
},
|
|
// 所有英雄基础信息获取事件
|
|
onHeroInfoFresh: function onHeroInfoFresh() {
|
|
// 整体刷新
|
|
this.freshList();
|
|
},
|
|
onHeroInfoFreshSingle: function onHeroInfoFreshSingle(_data) {
|
|
var nodes = nx.gui.find(this.svcList.bindSCV, "view/content").children;
|
|
nodes.forEach(function (_nod) {
|
|
if (_nod) {
|
|
var cmp = _nod.svItem;
|
|
if (cmp) {
|
|
if (cmp.mdata.partner_id == _data.partner_id) {
|
|
cmp.rebind(cmp.index, _data, cmp.key);
|
|
}
|
|
if (cmp.mdata.is_in_form > 0) {
|
|
cmp.checkTip();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// 整体刷新
|
|
freshList: function freshList() {
|
|
var HC = HeroControl.getInstance();
|
|
var mod = HC.getModel();
|
|
this.partners = mod.getHeroListByCamp(this.curCamp);
|
|
this.partners.sort(Utils.tableUpperSorter(["sortidd", "star", "quality", "lev"]));
|
|
nx.gui.setActive(this.svcList, "empty", false);
|
|
this.svcList.rebuild(this.partners);
|
|
|
|
// 引导辅助
|
|
if (nx.bridge.plot && nx.bridge.plot.isDoing()) {
|
|
// console.log( "檢測引導" );
|
|
this.position20401();
|
|
}
|
|
},
|
|
// 阵营切换
|
|
onTogCamp: function onTogCamp(_index) {
|
|
var idx = parseInt(_index) || 0;
|
|
if (this.curCamp == idx) {
|
|
return;
|
|
}
|
|
nx.debug("[Hero]\u9635\u8425\u5207\u6362:" + this.curCamp + " -> " + idx);
|
|
this.curCamp = idx;
|
|
|
|
// 整体刷新
|
|
this.freshList();
|
|
},
|
|
// 选中切换
|
|
onFocusChanged: function onFocusChanged(_item) {
|
|
nx.audio.playSFX("audios/effects/touchitem");
|
|
// 空
|
|
if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) {
|
|
return;
|
|
}
|
|
|
|
// // 聚焦
|
|
// this.svcList.cleanFocus();
|
|
// this.svcList.addFocus( _item.index );
|
|
|
|
var HC = HeroControl.getInstance();
|
|
if (HC) {
|
|
HC.openHeroMainInfoWindow(true, _item.mdata, this.partners);
|
|
}
|
|
},
|
|
// ============================================
|
|
// 引导辅助
|
|
// ============================================
|
|
|
|
// 特定英雄定位
|
|
position20401: function position20401() {
|
|
// console.log( "當前的引導" + JSON.stringify( nx.bridge.plot ) );
|
|
|
|
var info = nx.bridge.plot.vget("info");
|
|
var step = nx.bridge.plot.vget("step");
|
|
var units = "";
|
|
var unit = null;
|
|
if (info && info.steps) {
|
|
unit = info.steps[step + 1].unit;
|
|
if (unit) {
|
|
units = unit.split('_');
|
|
}
|
|
}
|
|
var node = null;
|
|
var have = 0;
|
|
var children = this.svcList.bindSCV.content.children;
|
|
children.forEach(function (_item) {
|
|
if (_item.svItem && _item.svItem.mdata && _item.svItem.mdata.bid && _item.svItem.mdata.bid != 0) {
|
|
have++;
|
|
}
|
|
});
|
|
for (var i = 0; i < children.length; ++i) {
|
|
var temp = children[i];
|
|
if (temp.svItem && temp.svItem.mdata) {
|
|
if (have <= 2) {
|
|
if (unit && temp.svItem.mdata.bid == units[1] && units[1] == 20401) {
|
|
node = temp;
|
|
break;
|
|
}
|
|
}
|
|
if (have >= 3) {
|
|
if (unit && temp.svItem.mdata.bid == units[1] && (units[1] == 20401 || units[1] == 30508)) {
|
|
node = temp;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!node) {
|
|
nx.error("$ParterPage:定位特定英雄失败!" + have);
|
|
node = have == 2 ? children[0] : children[2];
|
|
if (!node) {
|
|
return;
|
|
}
|
|
}
|
|
var cell = nx.gui.find(this, "panel/plotCell");
|
|
var cmp = nx.gui.getComponent(cell, "", "cmp.plot.trigger");
|
|
var pos = node.convertToWorldSpaceAR(cc.Vec2.ZERO);
|
|
cell.position = cell.parent.convertToNodeSpaceAR(pos);
|
|
cell.width = node.width;
|
|
cell.height = node.height;
|
|
cell.mdata = node.svItem.mdata;
|
|
if (cmp) {
|
|
cmp.pID = "partner_" + cell.mdata.bid;
|
|
cmp.regist();
|
|
}
|
|
},
|
|
// 点击特定英雄处理
|
|
onTouchPartner20401: function onTouchPartner20401() {
|
|
var cell = nx.gui.find(this, "panel/plotCell");
|
|
var cmp = nx.gui.getComponent(cell, "", "cmp.plot.trigger");
|
|
var HC = HeroControl.getInstance();
|
|
if (HC) {
|
|
HC.openHeroMainInfoWindow(true, cell.mdata);
|
|
if (cmp) {
|
|
nx.bridge.plot.unregUnit(this.pID);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |