Files
fc/dev/project/assets/Scripts/mod/acts/encounter/act.encounter.mod.js
T

164 lines
4.1 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
/*******************************************************************************
*
* 活动:銀河奇遇
*
*
******************************************************************************/
const ActBase = require( "act.base" );
const Encounter = cc.Class( {
extends: ActBase,
// 初始化配置数据
initConfig: function() {
// 视图附着
nx.plugin.add( this, [ "view" ] );
this.vattach( "Acts" );
},
// 注册协议接受事件
registerProtocals: function() {
this.RegisterProtocal( 31000, this.handle31000.bind( this ) );
this.RegisterProtocal( 31001, this.handle31001.bind( this ) );
this.RegisterProtocal( 31002, this.handle31002.bind( this ) );
},
// 从服务器初始化数据
reqBaseFromServer: function( _cb ) {
let cfgs = [
"fake_battle_data",
]
this.loadConfigs( cfgs, ( _ret, _data ) => {
this.reqBaseData( _cb );
} )
},
// 请求剧情信息
reqBaseData: function( _cb ) {
this.send31000( _cb );
},
// ============================================================
// 銀河奇遇
// ============================================================
//任務完成情況
send31000( _cb ) {
this.SendProtocal( 31000, {}, _cb )
},
handle31000: function( _data ) {
if( !this.isGoodData( _data ) ) {
this.vset( "EncounterData", {} );
return;
}
this.vset( "EncounterData", _data );
// 提示刷新
this.freshTips( _data );
},
//挑戰
send31001( params, _cb ) {
this.SendProtocal( 31001, {
id: params.id,
formation_type: params.formation_type,
pos_info: params.pos_info
}, _cb )
},
handle31001: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
},
//领取
send31002( id, _cb ) {
this.SendProtocal( 31002, {
id: id
}, _cb )
},
handle31002: function( _data ) {
nx.bridge.acts.reqActsRewards();
if( !this.isGoodData( _data ) ) {
return;
}
},
// ============================================================
// 活动红点提示
// ============================================================
// 活动用到的提示KEY
tipKeys: function() {
return [ "award1", "award2", "award3", "award4", "award5", "award6" ];
},
// 红点提示更新
freshTips: function( _data ) {
//是否有未挑戰的
let ids = _data.ids;
let awards = _data.reward_ids;
if( ids.length < 6 || awards.length < 6 ) {
this.openTip( "reward", true );
} else {
this.openTip( "reward", false );
}
//是否有獎勵領取
for( let i = 0; i < 6; i++ ) {
let passid = ids[ i ];
let awardid = awards[ i ];
if( passid && !awardid ) {//已通過,未領取
this.openTip( this.tipKeys()[ i ], true );
} else {
this.openTip( this.tipKeys()[ i ], false );
}
}
},
// ============================================================
// 引导
// ============================================================
// 触发引导
fireGuide: function() {
let self = this;
let done = function() {
let campId = self.data.camp_id;
nx.bridge.acts.reqDoneGuide( campId );
};
nx.bridge.plot.fireForce( 30001, ( _done ) => {
if( _done ) {
done();
}
} );
},
// 首次触发
tryGuide: function() {
let campId = this.data.camp_id;
if( !nx.dt.numPositive( campId, false ) ) {
return;
}
nx.bridge.acts.needGuide( campId, ( _ret, _params ) => {
if( _ret && _params && _params.code == 1 ) {
this.fireGuide();
}
} );
},
} );
// 模块导出
module.exports = Encounter;