261 lines
8.7 KiB
JavaScript
261 lines
8.7 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 僚机背包页
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
const BridgeComponent = require( "bridge.component" );
|
||
|
|
const PathTool = require("pathtool");
|
||
|
|
const HallowsConst = require("hallows_const");
|
||
|
|
const HallowsEvent = require("hallows_event");
|
||
|
|
const HallowsController = require("hallows_controller");
|
||
|
|
const 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() {
|
||
|
|
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(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(){
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onDisable(){
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
clickRefine(){
|
||
|
|
if(this.select_hallows){
|
||
|
|
this.ctrl.send24135(this.select_hallows.id);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
setData(hallows){
|
||
|
|
this.select_hallows = hallows;
|
||
|
|
this.updateRefineInfo();
|
||
|
|
},
|
||
|
|
|
||
|
|
updateHallowsBaseInfo(){
|
||
|
|
if(this.select_hallows == null)return;
|
||
|
|
|
||
|
|
let 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)
|
||
|
|
}
|
||
|
|
let 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;
|
||
|
|
|
||
|
|
let atk_val = vo.getHallowsSkillAndRefineAtkVal();
|
||
|
|
let skill_atk_val = atk_val.skill_atk_val;
|
||
|
|
let refine_atk_val = atk_val.refine_atk_val;
|
||
|
|
let 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() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
//更新精炼信息显示
|
||
|
|
updateRefineInfo:function(){
|
||
|
|
if(!this.select_hallows){
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
let vo = this.select_hallows.vo;
|
||
|
|
if(!vo){
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
let refine_cfg = null;
|
||
|
|
let 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]
|
||
|
|
}
|
||
|
|
|
||
|
|
//当前技能伤害值
|
||
|
|
let atk_val = vo.getHallowsSkillAndRefineAtkVal();
|
||
|
|
let 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){
|
||
|
|
//精炼升级消耗
|
||
|
|
let expend_1 = next_refine_cfg.expend[0]
|
||
|
|
let expend_2 = next_refine_cfg.expend[1]
|
||
|
|
let is_one = false;
|
||
|
|
let is_two = false;
|
||
|
|
if (expend_1) {
|
||
|
|
let bid = expend_1[0]
|
||
|
|
let num = expend_1[1]
|
||
|
|
this.refine_cost_bid_1 = bid
|
||
|
|
this.refine_cost_num_1 = num
|
||
|
|
let 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) {
|
||
|
|
let bid2 = expend_2[0]
|
||
|
|
let num2 = expend_2[1]
|
||
|
|
this.refine_cost_bid_2 = bid2
|
||
|
|
this.refine_cost_num_2 = num2
|
||
|
|
let 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( 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, (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));
|
||
|
|
}
|
||
|
|
},
|
||
|
|
} );
|