Files
fc/dev/project/library/imports/ad/ad1dbba8-5ae1-4532-9c5a-b0d7504728fe.js
2026-05-24 10:21:26 +08:00

270 lines
7.5 KiB
JavaScript

"use strict";
cc._RF.push(module, 'ad1dbuoWuFFMpxasNdQRyj+', 'cmp.partner.skin');
// Scripts/mod/partner/cmps/skin/cmp.partner.skin.js
"use strict";
/******************************************************************
*
* 伙伴换肤界面
*
******************************************************************/
var BridgeComponent = require("bridge.component");
var NxSpine = require("nx.fx.spine");
var HeroController = require("hero_controller");
var TipsController = require("tips_controller");
cc.Class({
"extends": BridgeComponent,
properties: {
spMini: {
"default": null,
type: NxSpine
},
spRole: {
"default": null,
type: NxSpine
},
nodName: {
"default": null,
type: cc.Node
},
rootAttrs: {
"default": null,
type: cc.Node
},
attrPersons: {
"default": null,
type: cc.Node
},
attrTeam: {
"default": null,
type: cc.Node
},
lstSkin: {
"default": null,
type: cc.Node
},
nodOps: {
"default": null,
type: cc.Node
}
},
// 设置伙伴
setPartner: function setPartner(_partner, _cbChanged) {
var _this = this;
// 置空
if (!_partner) {
this.spRole.stop();
this.spMini.stop();
return;
}
this.partner = _partner;
this.preskin = _partner.use_skin;
this.cbskin = _cbChanged;
this.scheduleOnce(function () {
_this.rebuildList();
_this.setSkin(0);
}, 0.05);
},
// 重建
rebuildList: function rebuildList() {
var SkinData = game.configs.partner_skin_data.data_skin_info;
var SkinPartners = game.configs.partner_skin_data.data_partner_bid_info;
var skins = SkinPartners[this.partner.bid];
this.skins = [];
for (var id in skins) {
var info = SkinData[id];
this.skins.push(nx.dt.objClone(info));
}
// 列表重构
var chds = this.lstSkin.children;
nx.gui.gocChildren(this.lstSkin, "", this.skins.length, chds[0]);
for (var i = 0; i < this.skins.length; ++i) {
var cmp = nx.gui.getComponent(chds[i], "", "cmp.partner.skin.item");
cmp.setSkin(i, this.skins[i]);
}
},
// 聚焦皮肤
setSkin: function setSkin(_index) {
var index = _index;
if (this.current == index) {
return;
}
var chds = this.lstSkin.children;
for (var i = 0; i < chds.length; ++i) {
var cmp = nx.gui.getComponent(chds[i], "", "cmp.partner.skin.item");
cmp.setFocus(i == index);
}
this.current = index;
this.currentShow(this.skins[index]);
this.freshShows();
},
// 当前展示
currentShow: function currentShow(_skin) {
var _this2 = this;
// 如果为空,则还原
if (nx.dt.objEmpty(_skin)) {
this.current = -1;
var key = this.partner.bid + "_" + this.partner.star;
var cfg = gdata("partner_data", "data_partner_star", key);
_skin = {
res_id: cfg.res_id,
skin_name: "SkinRaw",
skin_attr: []
};
}
// 立绘
var path = PathTool.getSpinePath(_skin.res_id, "show", false);
this.spRole.load(path, function (_e) {
if (!_e) {
_this2.spRole.action("action1", true);
} else {
_this2.spRole.stop();
}
});
// 战斗迷你
path = PathTool.getSpinePath(_skin.res_id, _skin.res_id, false);
this.spMini.load(path, function (_e) {
if (!_e) {
_this2.spMini.action("stand2", true);
} else {
_this2.spMini.stop();
}
});
// 名字
nx.gui.setString(this.nodName, "txt", nx.text.getKey(_skin.skin_name));
// 个人属性加成
var attrs = _skin.skin_attr || [];
if (nx.dt.arrEmpty(attrs)) {
this.attrPersons.active = false;
nx.gui.setActive(this.rootAttrs, "empty1", true);
} else {
this.attrPersons.active = true;
nx.gui.setActive(this.rootAttrs, "empty1", false);
var chds = this.attrPersons.children;
nx.gui.gocChildren(this.attrPersons, "", attrs.length, chds[0]);
for (var i = 0; i < attrs.length; ++i) {
nx.bridge.attrs.setAttribute(chds[i], attrs[i]);
}
}
// 团体属性加成
attrs = _skin.skin_attr_all || [];
if (nx.dt.arrEmpty(attrs)) {
this.attrTeam.active = false;
nx.gui.setActive(this.rootAttrs, "empty2", true);
} else {
this.attrTeam.active = true;
nx.gui.setActive(this.rootAttrs, "empty2", false);
var _chds = this.attrTeam.children;
nx.gui.gocChildren(this.attrTeam, "", attrs.length, _chds[0]);
for (var _i = 0; _i < attrs.length; ++_i) {
nx.bridge.attrs.setAttribute(_chds[_i], attrs[_i]);
}
}
this.voice = "";
if (nx.dt.strNEmpty(_skin.voice)) {
this.voice = cc.path.join("resDB/models", _skin.res_id, _skin.voice);
}
},
// 展示刷新
freshShows: function freshShows() {
var skin = this.skins[this.current];
if (nx.dt.objEmpty(skin)) {
this.nodOps.active = false;
return;
}
nx.gui.setActive(this.nodName, "icon", true);
nx.gui.setActive(this.nodName, "icon/lock", this.partner.use_skin == 0);
// nx.gui.setActive( this.nodName, "icon", this.partner.use_skin != 0 );
// 皮肤项刷新
var node = this.lstSkin.children[this.current];
var cmp = nx.gui.getComponent(node, "", "cmp.partner.skin.item");
if (cmp) {
cmp.freshVars();
}
// 操作刷新
var HC = HeroController.getInstance();
var HM = HC.getModel();
var used = this.partner.use_skin == skin.skin_id;
var lst = HM.hero_skin_list || {};
var have = nx.dt.numGood(lst[skin.skin_id]);
this.nodOps.active = true;
nx.gui.setActive(this.nodOps, "use", !used && have);
nx.gui.setActive(this.nodOps, "using", used);
nx.gui.setActive(this.nodOps, "lock", false);
// nx.gui.setString( this.nodOps, "lock/txt", nx.text.getKey( skin.unlock_tip ) );
},
// 使用
onTouchChange: function onTouchChange() {
var _this3 = this;
var skin = this.skins[this.current];
if (nx.dt.objEmpty(skin)) {
return;
}
var HC = HeroController.getInstance();
HC.sender11019(this.partner.partner_id, skin.skin_id, function (_ret, _data) {
if (!_ret) {
nx.tbox(_data);
return;
}
_this3.freshShows();
nx.dt.fnInvoke(_this3.cbskin);
if (nx.dt.strNEmpty(_this3.voice)) {
nx.audio.playSFX(_this3.voice);
}
});
},
// 点击还原
onTouchTakeOff: function onTouchTakeOff() {
var _this4 = this;
var HC = HeroController.getInstance();
HC.sender11019(this.partner.partner_id, 0, function (_ret, _data) {
if (!_ret) {
nx.tbox(_data);
return;
}
_this4.freshShows();
nx.dt.fnInvoke(_this4.cbskin);
});
},
onTouchLook: function onTouchLook() {
var skin_cfg = game.configs.partner_skin_data.data_skin_info[this.skins[this.current].skin_id];
if (skin_cfg) {
if (nx.dt.strEmpty(skin_cfg.hcg)) {
var tip = nx.text.getKey("NoImplementation");
nx.tbox(tip);
return;
}
nx.bridge.plot.done();
var hcg = skin_cfg.hcg;
nx.bridge.plot.records.ids.splice(nx.bridge.plot.records.ids.indexOf(hcg), 1);
nx.bridge.plot.fire(hcg);
}
},
onTouchLock: function onTouchLock() {
var skin_cfg = game.configs.partner_skin_data.data_skin_info[this.skins[this.current].skin_id];
var tip = skin_cfg.unlock_tip;
nx.tbox(tip);
},
// 点击规则
onTouchHelp: function onTouchHelp() {
var TC = TipsController.getInstance();
if (TC) {
var txt = game.configs.partner_skin_data.data_const.show_txt.desc;
TC.showTextPanel("tip", txt);
}
}
});
cc._RF.pop();