223 lines
7.4 KiB
JavaScript
223 lines
7.4 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
|
||
|
|
},
|
||
|
|
skill_item:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Prefab
|
||
|
|
},
|
||
|
|
skill_name:{
|
||
|
|
default:null,
|
||
|
|
type:cc.RichText
|
||
|
|
},
|
||
|
|
skill_desc:{
|
||
|
|
default:null,
|
||
|
|
type:cc.RichText
|
||
|
|
},
|
||
|
|
main:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
skill_lvup_tips:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Label
|
||
|
|
},
|
||
|
|
skill_max:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad: function() {
|
||
|
|
this._super();
|
||
|
|
|
||
|
|
this.ctrl = HallowsController.getInstance();
|
||
|
|
this.model = this.ctrl.getModel();
|
||
|
|
this.is_in_advance = false;
|
||
|
|
this.skill_lvup_cost_bid_1 = 0; // 选中的神器技能升级所需消耗1
|
||
|
|
this.skill_lvup_cost_num_1 = 0;
|
||
|
|
this.skill_lvup_cost_bid_2 = 0; // 选中的神器技能升级所需消耗2
|
||
|
|
this.skill_lvup_cost_num_2 = 0;
|
||
|
|
},
|
||
|
|
|
||
|
|
getCostObj(bid){
|
||
|
|
if(bid == this.skill_lvup_cost_bid_1){
|
||
|
|
this.setCostDataToNode(this.cost_icon_1, this.cost_num_1, bid, this.skill_lvup_cost_num_1);
|
||
|
|
}else if(bid == this.skill_lvup_cost_bid_2){
|
||
|
|
this.setCostDataToNode(this.cost_icon_2, this.cost_num_2, bid, this.skill_lvup_cost_num_2);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 技能升级
|
||
|
|
onClickSkillLvupBtn:function(){
|
||
|
|
if(this.select_hallows == null)return;
|
||
|
|
var vo = this.select_hallows.vo;
|
||
|
|
if(vo){
|
||
|
|
this.ctrl.requestHallowsSkillUpgrade(vo.id);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
onEnable(){
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onDisable(){
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
setData(hallows){
|
||
|
|
this.select_hallows = hallows;
|
||
|
|
|
||
|
|
let max_lev = game.configs.hallows_data.data_skill_max_lev[this.select_hallows.id];
|
||
|
|
if(this.select_hallows.vo && this.select_hallows.vo.skill_lev >= max_lev){
|
||
|
|
this.main.active = false;
|
||
|
|
this.skill_name.node.active = false;
|
||
|
|
this.skill_desc.node.active = false;
|
||
|
|
this.skill_max.active = true;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.updateSkillInfo();
|
||
|
|
this.updateHallowsBaseInfo();
|
||
|
|
},
|
||
|
|
|
||
|
|
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() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 更新神器技能相关显示
|
||
|
|
updateSkillInfo:function( ){
|
||
|
|
if(this.select_hallows == null)return;
|
||
|
|
var vo = this.select_hallows.vo;
|
||
|
|
if(vo == null)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){
|
||
|
|
//升级消耗
|
||
|
|
if(hallows_skill.lev_limit > vo.step){
|
||
|
|
this.main.active = false;
|
||
|
|
this.skill_lvup_tips.node.active = true;
|
||
|
|
this.skill_lvup_tips.string = cc.js.formatStr(nx.text.getKey("lab_hallows_main_window_tip16"), hallows_skill.lev_limit);
|
||
|
|
}else{
|
||
|
|
this.main.active = true;
|
||
|
|
this.skill_lvup_tips.node.active = false;
|
||
|
|
|
||
|
|
var expend_1 = hallows_skill.lose[0];
|
||
|
|
var expend_2 = hallows_skill.lose[1];
|
||
|
|
let is_one = false;
|
||
|
|
let is_two = false;
|
||
|
|
if(expend_1){
|
||
|
|
var bid = expend_1[0];
|
||
|
|
var num = expend_1[1];
|
||
|
|
this.skill_lvup_cost_bid_1 = bid;
|
||
|
|
this.skill_lvup_cost_num_1 = num;
|
||
|
|
this.setCostDataToNode(this.cost_icon_1, this.cost_num_1, bid, num);
|
||
|
|
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.skill_lvup_cost_bid_2 = bid2
|
||
|
|
this.skill_lvup_cost_num_2 = num2
|
||
|
|
this.setCostDataToNode(this.cost_icon_2, this.cost_num_2, bid2, num2);
|
||
|
|
var count2 = BackpackController.getInstance().getModel().getItemNumByBid(bid2);
|
||
|
|
if(count2 >= num2){
|
||
|
|
is_two = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(is_one && is_two){
|
||
|
|
nx.mTip.openTip("partner.hallows.skill",true);
|
||
|
|
}else{
|
||
|
|
nx.mTip.openTip("partner.hallows.skill",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));
|
||
|
|
}
|
||
|
|
},
|
||
|
|
} );
|