Files
fc/dev/project/assets/Scripts/mod/partner/wings/cmp/cmp.wing.procurement.reward.wnd.js
T
2026-05-23 22:10:14 +08:00

295 lines
8.7 KiB
JavaScript

/******************************************************************
*
* 奖励弹窗
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const BackPackConst = require( "backpack_const" );
const FxSpine = require( "nx.fx.spine" );
cc.Class( {
extends: BridgeWindow,
properties: {
spAnim: { default: null, type: FxSpine },
nodRewards: { default: null, type: cc.Node },
nodOps: { default: null, type: cc.Node },
nodTouch: { default: null, type: cc.Node },
nodDesc: { default: null, type: cc.Node },
nodName: { default: null, type: cc.Node },
nodSpecial : { default: null, type: cc.Node },
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
this.params = _params ? _params.params : null;
// 道具拆解
this.items = [];
_params.list.forEach( _t => {
this.items.push( [ _t.base_id, _t.num || 1 ] );
} );
// 判空
if( nx.dt.arrEmpty( this.items ) ) {
this.close();
nx.error( "[REWARD]无效的道具表!" );
return;
}
let cmp = null;
let mul = ( this.items.length > 6 );
if( mul ) {
nx.gui.setActive( this.nodRewards, "ml", true );
nx.gui.setActive( this.nodRewards, "sl", false );
cmp = nx.gui.getComponent( this.nodRewards, "ml", "nx.fx.sv.expand" );
}
else {
nx.gui.setActive( this.nodRewards, "ml", false );
nx.gui.setActive( this.nodRewards, "sl", true );
cmp = nx.gui.getComponent( this.nodRewards, "sl", "cmp.item.layout" );
}
// 道具刷新
cmp.rebuild( this.items );
this.specials = [];
this.specialsCopy = [];
for (let i = 0; i < this.items.length; i++) {
let item = this.items[i];
let ifg = gdata( "item_data", "data_unit9", item[0] );
if( ifg && ifg.quality == BackPackConst.quality.orange ){
this.specials.push( item );
this.specialsCopy.push( item );
}
}
// this.specialsCopy = this.specials;
this.nodRewards.active = false;
this.nodSpecial.active = false;
// 节点统计
this.glowers = [];
if( mul ) {
let root = cmp.bindSCV.content;
for( let i in root.children ) {
let node = root.children[ i ];
if( node && node.children[ 0 ] ) {
node.children[ 0 ].opacity = 0;
this.glowers.push( node.children[ 0 ] );
}
}
}
else {
let root = cmp.node;
for( let i in root.children ) {
let node = root.children[ i ];
if( node ) {
node.opacity = 0;
this.glowers.push( node );
}
}
}
this.dealShow();
// // 动画流程
// this.doAnimation();
},
dealShow: function(){
let self = this;
let deal = function( _data ) {
// [[113008,1]]
let sfg = gdata( "sprite_data", "data_elfin_data", _data[0][0] )
let ifg = gdata( "item_data", "data_unit9", _data[0][0] );
if( ifg ){
let cmp = nx.gui.getComponent( self.nodSpecial, "item", "cmp.item.base" );
if( cmp ){
cmp.setData( _data[0][0] );
}
nx.gui.setActive( self.nodSpecial, "item" , false );
nx.bridge.setIcon( self.nodSpecial, "role", ifg.imageid );
if( sfg ){
let skill = gdata( "skill_data4","data_get_skill",sfg.skill );
if( skill ){
// console.log( "当前的数据信息ss" + JSON.stringify( sfg ) );
nx.gui.setString( self.nodDesc, "name", skill.name ) ;
nx.gui.setString( self.nodDesc, "desc/view/content/txt", nx.text.getKey( skill.des ) ) ;
}
}
// console.log( "当前的数据信息" + JSON.stringify( ifg ) );
nx.gui.setString( self.nodName, "name", ifg.name ) ;
nx.gui.setString( self.nodName, "type", ifg.use_desc ) ;
// console.log( JSON.stringify( ifg ) + "当前的奖励" + JSON.stringify( this.items[0] ) );
self.scheduleOnce( () => {
nx.gui.setActive( self.nodSpecial, "", true );
}, 0.2 );
}
};
// console.log( "当前的特殊显示" + JSON.stringify( this.specials ) );
// this.specials = [[113006,1]];
if( !nx.dt.arrEmpty( this.specials ) ){
let bid = this.specials.splice(0, 1);
deal( bid );
}else{
this.showRewards();
}
},
showRewards : function(){
nx.gui.setActive( this.nodSpecial, "", false );
this.doAnimation();
},
// 动画流程
doAnimation: function() {
// 隐藏操作
this.hideOps();
this.spAnim.action( "action", false, ( _key, _name ) => {
if( _key == "reward" ) {
this.nodRewards.active = true;
let dsec = 0;
for( let i in this.glowers ) {
let glow = this.glowers[ i ];
if( !glow ) continue;
nx.tween.delayFadeIn( glow, "", dsec, 0.01, () => {
let comp = glow.getComponent( "cmp.item.glow" );
if( comp ) {
comp.glowShow();
if( nx.dt.arrMember( this.specialsCopy, comp.mdata ) ){
nx.gui.setActive( glow, "icon/focus", true );
}else{
nx.gui.setActive( glow, "icon/focus", false );
}
nx.gui.setActive( glow, "icon/star", false );
}
} );
dsec += 0.05;
}
// 操作展示
this.freshAndDelayShowOps();
return;
}
// 第二阶段
if( _key == "complete" ) {
this.spAnim.action( "action2", true );
return;
}
} );
},
// ==================================================
// 不同的操作栏处理
// ==================================================
// 隐藏操作
hideOps: function() {
this.nodOps.active = false;
this.nodTouch.active = false;
},
// 操作展示
freshAndDelayShowOps: function() {
// 辨别展示节点
let optype = false;
if( nx.dt.objNEmpty( this.params ) ) {
this.nodOps.children.forEach( _node => {
_node.active = ( _node.name == this.params.op );
} );
optype = true;
switch( this.params.op ) {
// 召唤面板
case "summon": {
this.freshSummonOps( this.params );
} break;
// 无法识别
default: {
optype = false;
nx.error( "无效道具展示操作类型:", this.params.op );
} break;
}
}
// 延迟关闭
let node = optype ? this.nodOps : this.nodTouch;
this.scheduleOnce( () => {
node.active = true;
nx.tween.fadeIn( node, "", 0.5 );
}, 0.5 );
},
// 召唤相关
// 刷新召唤面板
/**
* 参数结构
* op: "summon",
* bid: 所需道具编号
* need: 所需道具数量
* txt: 按钮文本
* cb: 点击回调
*/
freshSummonOps: function( _args ) {
let node = nx.gui.find( this.nodOps, "summon/draw" );
if( node ) {
let cfg = gitemdata( _args.bid );
nx.bridge.setIcon( node, "need/list/icon", cfg ? cfg.icon : 0 );
nx.gui.setString( node, "need/list/num", _args.need );
nx.gui.setString( node, "btn/txt", nx.text.getKey( _args.txt ) );
}
},
// 点击召唤取消
onTouchSummonCancel: function() {
nx.dt.fnInvoke( this.params.cb, false );
},
// 点击召唤
onTouchSummonConfirm: function() {
nx.dt.fnInvoke( this.params.cb, true );
},
} );