Files
fc/dev/project/library/imports/d6/d6fc1e59-72c6-4697-8495-77e47f325ebc.js
2026-05-24 10:21:26 +08:00

241 lines
8.0 KiB
JavaScript

"use strict";
cc._RF.push(module, 'd6fc15ZcsZGl4SVd+R/Ml68', 'cmp.hallows.main.refine');
// Scripts/mod/partner/hallows/cmp/cmp.hallows.main.refine.js
"use strict";
/******************************************************************
*
* 僚机背包页
*
******************************************************************/
var BridgeComponent = require("bridge.component");
var PathTool = require("pathtool");
var HallowsConst = require("hallows_const");
var HallowsEvent = require("hallows_event");
var HallowsController = require("hallows_controller");
var BackpackController = require("backpack_controller");
var PartnerCalculate = require("partner_calculate");
cc.Class({
"extends": BridgeComponent,
properties: {
cost_icon_1: {
"default": null,
type: cc.Sprite
},
cost_icon_2: {
"default": null,
type: cc.Sprite
},
cost_num_1: {
"default": null,
type: cc.Label
},
cost_num_2: {
"default": null,
type: cc.Label
},
refine_lv_txt_1: {
"default": null,
type: cc.Label
},
atk_txt_1: {
"default": null,
type: cc.Label
},
total_atk_txt_1: {
"default": null,
type: cc.Label
},
refine_lv_txt_2: {
"default": null,
type: cc.Label
},
atk_txt_2: {
"default": null,
type: cc.Label
},
total_atk_txt_2: {
"default": null,
type: cc.Label
},
refine_btn: {
"default": null,
type: cc.Node
},
refine_tips: {
"default": null,
type: cc.Label
}
},
onLoad: function onLoad() {
this._super();
this.ctrl = HallowsController.getInstance();
this.model = this.ctrl.getModel();
this.is_in_advance = false;
this.refine_cost_bid_1 = 0; // 选中的神器精炼升级所需消耗1
this.refine_cost_num_1 = 0;
this.refine_cost_bid_2 = 0; // 选中的神器精炼升级所需消耗2
this.refine_cost_num_2 = 0;
},
getCostObj: function getCostObj(bid) {
if (bid == this.refine_cost_bid_1) {
this.setCostDataToNode(this.cost_icon_1, this.cost_num_1, bid, this.refine_cost_num_1);
} else if (bid == this.refine_cost_bid_2) {
this.setCostDataToNode(this.cost_icon_2, this.cost_num_2, bid, this.refine_cost_num_2);
}
},
onEnable: function onEnable() {},
onDisable: function onDisable() {},
clickRefine: function clickRefine() {
if (this.select_hallows) {
this.ctrl.send24135(this.select_hallows.id);
}
},
setData: function setData(hallows) {
this.select_hallows = hallows;
this.updateRefineInfo();
},
updateHallowsBaseInfo: function updateHallowsBaseInfo() {
if (this.select_hallows == null) return;
var vo = this.select_hallows.vo;
if (!vo) return;
//神器技能
var hallows_skill = gdata("hallows_data", "data_skill_up", Utils.getNorKey(this.select_hallows.id, vo.skill_lev));
if (hallows_skill && hallows_skill.skill_bid != 0) {
var config = gskilldata("data_get_skill", hallows_skill.skill_bid);
if (!config) {
return;
}
if (!this.hallow_skill_icon) {
this.hallow_skill_icon = cc.instantiate(this.skill_item);
this.hallow_skill_icon.parent = this.node;
this.hallow_skill_icon.scale = 0.8;
this.hallow_skill_icon.position = cc.v2(-190, 90);
}
var cmp = this.hallow_skill_icon.getComponent("cmp.skill.base");
cmp.rebind(0, config.bid, "");
this.skill_name.string = cc.js.formatStr("%s [<color=#27ae10>%s</color>]", config.name, vo.skill_lev);
this.skill_desc.string = config.des;
var atk_val = vo.getHallowsSkillAndRefineAtkVal();
var skill_atk_val = atk_val.skill_atk_val;
var refine_atk_val = atk_val.refine_atk_val;
var total_atk_val = skill_atk_val + refine_atk_val;
this.skill_desc.string = cc.js.formatStr(config.des, total_atk_val, refine_atk_val);
}
},
// 重载:关闭前
onPreClosed: function onPreClosed() {},
//更新精炼信息显示
updateRefineInfo: function updateRefineInfo() {
if (!this.select_hallows) {
return;
}
var vo = this.select_hallows.vo;
if (!vo) {
return;
}
var refine_cfg = null;
var next_refine_cfg = null;
if (game.configs.hallows_refine_data.data_refine[vo.id]) {
refine_cfg = game.configs.hallows_refine_data.data_refine[vo.id][vo.refine_lev];
next_refine_cfg = game.configs.hallows_refine_data.data_refine[vo.id][vo.refine_lev + 1];
}
//当前技能伤害值
var atk_val = vo.getHallowsSkillAndRefineAtkVal();
var skill_atk_val = atk_val.skill_atk_val;
//当前精炼等级信息
this.refine_lv_txt_1.string = cc.js.formatStr(nx.text.getKey("lab_hallows_main_window_tip18"), vo.refine_lev);
if (refine_cfg) {
this.atk_txt_1.string = refine_cfg.add_dps;
this.total_atk_txt_1.string = refine_cfg.add_dps + skill_atk_val;
} else {
this.atk_txt_1.string = 0;
this.total_atk_txt_1.string = skill_atk_val;
}
if (next_refine_cfg) {
//精炼升级消耗
var expend_1 = next_refine_cfg.expend[0];
var expend_2 = next_refine_cfg.expend[1];
var is_one = false;
var is_two = false;
if (expend_1) {
var bid = expend_1[0];
var num = expend_1[1];
this.refine_cost_bid_1 = bid;
this.refine_cost_num_1 = num;
var is_full = this.setCostDataToNode(this.cost_icon_1, this.cost_num_1, bid, num);
if (!is_full) {
this.is_can_refine_2 = false;
}
var count = BackpackController.getInstance().getModel().getItemNumByBid(bid);
if (count >= num) {
is_one = true;
}
}
if (expend_2) {
var bid2 = expend_2[0];
var num2 = expend_2[1];
this.refine_cost_bid_2 = bid2;
this.refine_cost_num_2 = num2;
var _is_full = this.setCostDataToNode(this.cost_icon_2, this.cost_num_2, bid2, num2);
if (!_is_full) {
this.is_can_refine_3 = false;
}
var count2 = BackpackController.getInstance().getModel().getItemNumByBid(bid2);
if (count2 >= num2) {
is_two = true;
}
}
if (is_one && is_two) {
nx.mTip.openTip("partner.hallows.refine", true);
} else {
nx.mTip.openTip("partner.hallows.refine", false);
}
//精炼按钮状态
if (vo.step >= next_refine_cfg.need_lev) {
this.refine_btn.active = true;
this.refine_tips.node.active = false;
//下一级精炼等级信息
this.refine_lv_txt_2.string = cc.js.formatStr(nx.text.getKey("lab_hallows_main_window_tip18"), next_refine_cfg.lev);
this.atk_txt_2.string = next_refine_cfg.add_dps;
this.total_atk_txt_2.string = next_refine_cfg.add_dps + skill_atk_val;
// nx.gui.setActive(this.refine_cost_bg_1_img,"",true)
// nx.gui.setActive(this.refine_cost_bg_2_img,"",true)
} else {
this.refine_btn.active = false;
this.refine_tips.string = cc.js.formatStr(nx.text.getKey("lab_hallows_main_window_tip19"), next_refine_cfg.need_lev);
this.refine_tips.node.active = true;
this.is_can_refine_1 = false;
this.refine_lv_txt_2.string = "";
this.atk_txt_2.string = "";
this.total_atk_txt_2.string = "";
// nx.gui.setActive(this.refine_cost_bg_1_img,"",false)
// nx.gui.setActive(this.refine_cost_bg_2_img,"",false)
}
}
},
// 显示消耗数据
setCostDataToNode: function setCostDataToNode(item_icon, item_label, item_bid, item_num) {
var item_config = Utils.getItemConfig(item_bid);
if (item_config) {
var res = PathTool.queryIconPath(item_config.icon);
cc.loader.loadRes(res, cc.SpriteFrame, function (err, sf_obj) {
if (err) {
return;
}
item_icon.spriteFrame = sf_obj;
});
var count = BackpackController.getInstance().getModel().getItemNumByBid(item_bid);
item_label.string = cc.js.formatStr("%s/%s", Utils.getMoneyString(count, true, false), Utils.getMoneyString(item_num, true, false));
}
}
});
cc._RF.pop();