Files
2026-05-23 22:10:14 +08:00

203 lines
6.8 KiB
JavaScript

/******************************************************************
*
* 集結令 開服活动
*
******************************************************************/
const ActPage = require( "act.page.base" );
const NxSpine = require( "nx.fx.spine" );
const Payment = require( "payment.mod" );
const Mod = require( "act.assembly.mod" );
const themeMod = require( "acts.mod" );
const FID = require( "bridge.function.ids" );
cc.Class( {
extends: ActPage,
properties: {
nodItems : { type: cc.Node, default: null },
spRole: { default: null, type: NxSpine },
nodEndTime : { default: null, type: cc.Node },
nodOp : { type: cc.Node, default: null },
nodSpecial : { type: cc.Node, default: null },
},
// 初始化
build: function( _data ) {
this._super( _data );
this.spRole.load( "resDB/models/H30082/show", ( _e ) => {
if( !_e ) {
this.spRole.action( "action1", true );
} else {
this.spRole.stop();
}
} );
this.tweens = [];
this.canbuy = true;
// 活动监听
this.mod.vbind( this, [
[ "assembly", this.freshAssemblyInfo.bind( this ) ],
] );
},
onEnable: function(){
// 请求信息
this.mod.reqAssemblyData();
},
// 销毁
onDestroy: function() {
// 活动监听解除
if( this.mod ) {
this.mod.vunbind( this );
}
delete this.mod;
this._super();
},
freshAssemblyInfo: function( _data ){
if( !_data || nx.dt.objEmpty( _data ) || !this.nodItems ){
return;
}
/****
{"is_buy":0,"end_time":1695830399,"charge_id":912,
"award_list":[
{"id":7,"acv_id":263,"finish":0,"award_time":0,"award":[{"bid":29905,"num":50}]},
{"id":6,"acv_id":0,"finish":0,"award_time":0,"award":[{"bid":11403,"num":2}]},
{"id":5,"acv_id":0,"finish":0,"award_time":0,"award":[{"bid":11403,"num":2}]},
{"id":4,"acv_id":263,"finish":0,"award_time":0,"award":[{"bid":29905,"num":50}]},
{"id":3,"acv_id":0,"finish":0,"award_time":0,"award":[{"bid":11403,"num":2}]},
{"id":2,"acv_id":0,"finish":0,"award_time":0,"award":[{"bid":11403,"num":2}]},
{"id":1,"acv_id":263,"finish":0,"award_time":0,"award":[{"bid":29905,"num":50}]}
]
}
*/
this.award_id = 0;
nx.gui.setActive( this.nodEndTime, "", false );
nx.gui.setActive( this.nodEndTime, "title", true );
let descTime = _data.is_buy == 0 ? nx.text.getKey( "StepUpDone" ) : nx.text.getKey( "act_common_tips" );
let cd = _data.end_time - Math.floor( cc.sys.now() / 1000 ) > 0 ? _data.end_time - Math.floor( cc.sys.now() / 1000 ) : 0.1;
nx.gui.setCdTxt( this.nodEndTime, "txt", cd, () => {
nx.gui.setActive( this.nodEndTime, "title", false );
this.canbuy = _data.is_buy != 0;
nx.gui.setString( this.nodEndTime, "txt", descTime );
} );
let awardss = nx.dt.objClone( _data.award_list );
let free = awardss.shift();
let awards = awardss;
let cmp = nx.gui.getComponent( this.nodSpecial, "item", "cmp.item.base" );
if( cmp ){
cmp.setData( free.award[0] );
}
nx.gui.setActive( this.nodSpecial, "got", free.finish == 2 );
nx.gui.setActive( this.nodSpecial, "free", free.finish == 1 || free.finish == 0 );
this.buy_info = _data;
if( awards.length > 0 ){
let path = "prefab/acts/assembly/ui/assembly_0";
let price = game.configs.charge_data.data_charge_data[_data.charge_id].val;
nx.gui.gocChildren( this.nodItems, "", awards.length );
let chd = this.nodItems.children;
for ( let i = 0; i < chd.length; i++ ) {
let nod = chd[i];
let award = awards[i];
nx.gui.setActive( nod, "bg", award.acv_id == 0 );
nx.gui.setActive( nod, "bg_special", award.acv_id != 0 );
nx.gui.setSpriteFrame( nod, "number", path + ( award.id + 2 ) );
let cmp = nx.gui.getComponent( nod, "item", "cmp.item.base" );
if( cmp ){
cmp.setData( award.award[0] );
}
nx.gui.setActive( nod, "focus", award.finish == 1 && this.buy_info.is_buy == 1 );
nx.gui.setActive( nod, "icolog", award.finish == 1 );
nx.gui.setActive( nod, "got", award.finish == 2 );
if( award.finish == 1 ){
this.award_id = award.id;
}
let tween = nx.gui.find( nod, "focus" );
let tweenAct = cc.tween( tween )
.to( 0.6, {scale: 0.96 } )
.to( 0.6, {scale: 1 } )
.union()
.repeatForever()
.start();
this.tweens.push( tweenAct );
}
// nx.gui.setActive( this.nodEndTime, "", _data.is_buy == 0 );
let desc = _data.is_buy != 0 ? nx.text.getKey( "Get" ) : nx.text.format( "ChargeCost", Payment.getInstance().fmtPrice( price ) );
nx.gui.setString( this.nodOp, "txt", desc );
let btn = nx.gui.getComponent( this.nodOp, "", cc.Button );
if( btn ){
if( _data.is_buy != 0 ){
if( this.award_id == 0 ){
btn.interactable = false;
nx.gui.setOutlineColor( this.nodOp, "txt", cc.Color.BLACK );
}else{
btn.interactable = true;
nx.gui.setOutlineColor( this.nodOp, "txt", new cc.color( "#B85833" ) );
}
}else{
btn.interactable = true;
nx.gui.setOutlineColor( this.nodOp, "txt", new cc.color( "#B85833" ) );
}
}
}else{
nx.gui.hideAllChildren( this.nodItems, "" );
nx.gui.setString( this.nodOp, "txt", nx.text.getKey( "lab_planesafk_main_have_over" ) );
}
},
// 领取奖励 与 购买礼包
onTouchGet: function(){
if( !this.canbuy ){
nx.tbox( "StepUpDone" );
return;
}
if( this.buy_info.is_buy != 0 ){
this.mod.reqGetAssemblyAward( this.award_id );
return;
}
Payment.getInstance().reqPayment( this.buy_info.charge_id );
},
onTouchGetFree: function(){
this.mod.reqGetAssemblyAward( 0 );
},
} );