Files
fc/dev/project/library/imports/1b/1ba5e402-1ca0-45e8-a896-a176846b3367.js
T
2026-05-24 10:21:26 +08:00

152 lines
4.7 KiB
JavaScript

"use strict";
cc._RF.push(module, '1ba5eQCHKBF6KiWoXaEazNn', 'cmp.wing.upgrade');
// Scripts/mod/partner/wings/cmp/cmp.wing.upgrade.js
"use strict";
/******************************************************************
*
* 僚机进阶界面
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var ElfinController = require("elfin_controller");
var BackpackController = require("backpack_controller");
cc.Class({
"extends": BridgeWindow,
properties: {
lstProps: {
"default": null,
type: cc.Node
},
nodSkill: {
"default": null,
type: cc.Node
},
lstNeeds: {
"default": null,
type: cc.Node
}
},
onLoad: function onLoad() {
this.fresh();
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {},
// 刷新
fresh: function fresh() {
var _this = this;
var EC = ElfinController.getInstance();
var model = EC.getModel();
if (model) {
var wingData = model.getElfinTreeData();
var cbc = game.configs.sprite_data.data_tree_step[wingData.break_lev];
var nbc = game.configs.sprite_data.data_tree_step[wingData.break_lev + 1];
// 如果当前的突破数据不存在 关闭
if (nx.dt.objEmpty(cbc) || nx.dt.objEmpty(nbc)) {
this.scheduleOnce(function () {
_this.close();
}, 0.03);
return;
}
// 属性 数据刷新
// 首位为等级
var chds = this.lstProps.children;
var first = chds[0];
if (first) {
nx.gui.setSpriteFrame(first, "icon", null);
nx.gui.setString(first, "name", nx.text.getKey("Level"));
nx.gui.setString(first, "from", cbc.lev_max);
nx.gui.setString(first, "to", nbc.lev_max);
}
// 其他属性
for (var i = 1; i < chds.length; ++i) {
var node = chds[i];
var att = nbc.all_attr[i - 1];
if (!att) {
node.active = false;
continue;
}
node.active = true;
var id = att[0];
var icon = cc.path.join("coms/images", "ico_" + id);
nx.gui.setSpriteFrame(node, "icon", icon);
var name = game.configs.attr_data.data_key_to_name[id];
nx.gui.setString(node, "name", nx.text.getKey(name));
if (id == "hp_max") {
id = "hp";
}
if (!wingData[id]) {
node.active = false;
continue;
}
nx.gui.setString(node, "from", wingData[id]);
nx.gui.setString(node, "to", wingData[id] + att[1] || 0);
}
// 解锁新机位
// nx.gui.setActive( this.nodSkill, "icon", wingData.break_lev < 3 );
nx.gui.setActive(this.nodSkill, "max", false);
nx.gui.setString(this.nodSkill, "name", wingData.break_lev < 3 ? nx.text.format("tip_FortressLevel_Unlocked", nbc.count, nbc.count + 1) : nx.text.getKey("tip_FortressLevel_UnlockedAll"));
// 消耗
this.needs = [];
if (nx.dt.arrEmpty(cbc.expend)) {
// 无消耗
nx.gui.hideAllChildren(this.lstNeeds);
} else {
var _model = BackpackController.getInstance().getModel();
var _chds = this.lstNeeds.children;
for (var _i = 0; _i < _chds.length; ++_i) {
var _node = _chds[_i];
var info = cbc.expend[_i];
if (!info) {
_node.active = false;
continue;
}
_node.active = true;
var cmp = _node.getComponent("cmp.item.base");
if (cmp) {
cmp.setData(info[0]);
}
// let cfg = Utils.getItemConfig( info[ 0 ] );
// nx.bridge.setIconS( node, "icon", cfg.icon );
var have = _model.getItemNumByBid(info[0]);
var str = cc.js.formatStr("%s/%s", nx.dt.shortCount(have), Utils.getMoneyString(info[1]));
nx.gui.setString(_node, "count", str);
var clr = have >= info[1] ? cc.Color.WHITE : cc.Color.RED;
nx.gui.setColor(_node, "count", clr);
// 缺少记录
if (have < info[1]) {
this.needs.push(info[0]);
}
}
}
}
},
// 点击确认
onTouchConfirm: function onTouchConfirm() {
// 缺材料
if (nx.dt.arrNEmpty(this.needs)) {
var expend_item_cfg = gdata("item_data", "data_unit1", this.needs[0], false);
nx.tbox(nx.text.format(nx.text.getKey("lab_hero_break_window_tip1"), expend_item_cfg.name)); //Utils.TI18N("物品[" + expend_item_cfg.name + "]不足"));
BackpackController.getInstance().openTipsSource(true, this.needs[0]);
this.close();
return;
}
// 进阶
var EC = ElfinController.getInstance();
if (EC) {
EC.sender26512();
this.close();
}
}
});
cc._RF.pop();