Files
fc/dev/project/assets/Scripts/mod/battle/cmp/cmp.item.battle.hero.js
T
2026-05-23 22:10:14 +08:00

123 lines
3.3 KiB
JavaScript

const ItemBase = require( "nx.fx.sv.expand.item" );
const PathTool = require("pathtool");
const NxSpine = require("nx.fx.spine");
cc.Class({
extends: ItemBase,
properties: {
frame:{
default:null,
type:cc.Node
},
head:{
default:null,
type:cc.Node
},
effect:{
default:null,
type:NxSpine
},
showSp:{
default:null,
type:NxSpine
},
buff_con:{
default:null,
type:cc.Node
},
buff:{
default:null,
type:cc.Node
}
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
},
setConfig(){
},
setEmpty(){
},
setData(data){
if(nx.dt.objEmpty(data)){
this.setEmpty();
return false;
}
this.data = data;
let partner_bid = data.star == 0 ? data.object_id : data.object_bid;
this.partner_data = gdata("partner_data","data_partner_base",partner_bid);
this.object_bid = data.object_bid;
let res_id = this.partner_data.bustid;
if(data.extra_data.length > 0){
for(let i = 0;i < data.extra_data.length; i++){
if(data.extra_data[i].extra_key == 5 && data.extra_data[i].extra_value > 0){//皮肤
let skin_data = game.configs.partner_skin_data.data_skin_info[data.extra_data[i].extra_value];
res_id = skin_data.res_id;
}
}
}
let res_path = PathTool.getIconPath("models/"+ res_id + "/play","pkicon");
nx.gui.setSpriteFrame(this.head,"",res_path);
},
//动作列表
//攻击
useSkill(end_call,skill_delay){
this.frame.active = true;
let res_path = PathTool.getSpinePath("E80049","action",false);
this.showSp.load(res_path,(_e)=>{
if( !_e ) {
this.showSp.action( "action", false );
//上浮
let head_up = cc.moveBy(0.1,cc.v2(0,20)).easing(cc.easeOut(0.16));
//下沉
let head_down = cc.moveBy(0.3,cc.v2(0,-20)).easing(cc.easeIn(0.16));
this.head.runAction(cc.sequence(cc.spawn(head_up,end_call),cc.delayTime(skill_delay),head_down,cc.callFunc(()=>{
this.frame.active = false;
})));
} else {
this.showSp.stop();
}
});
},
//受击
getEncountor(){
let self = this;
let spine_act = cc.sequence(cc.rotateBy(0.05,10),cc.rotateBy(0.05,-10));
//受击
let hit_act = cc.repeat(spine_act,1);
let res_path = PathTool.getSpinePath("E65011","action",false);
self.effect.load(res_path,(_e)=>{
if(!_e){
this.effect.action("action",false,(_key,_name)=>{
if(_key == "start"){
self.node.runAction(hit_act);
}
if(_key == "complete"){
self.node.stopAllActions();
self.node.angle = 0;
}
});
}else{
self.effect.stop();
self.node.runAction(hit_act);
}
});
},
});