138 lines
3.2 KiB
JavaScript
138 lines
3.2 KiB
JavaScript
/*******************************************************************************
|
|
*
|
|
* 活动: 星之試煉
|
|
*
|
|
*
|
|
******************************************************************************/
|
|
|
|
const ActBase = require( "act.base" );
|
|
|
|
const HeroNewChalMod = 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 ) => {
|
|
nx.dt.fnInvoke( _cb, true );
|
|
} );
|
|
},
|
|
|
|
//任務完成情況
|
|
send31000( camp_id, _cb ) {
|
|
this.SendProtocal( 31000, {camp_id:camp_id}, _cb )
|
|
},
|
|
|
|
handle31000: function( _data ) {
|
|
|
|
if( !this.isGoodData( _data ) ) {
|
|
this.vset( "EncounterData", {} );
|
|
return;
|
|
}
|
|
|
|
this.setCampId(_data.camp_id);
|
|
this.setNextDay(_data.next_day);
|
|
this.vset( "EncounterData", _data );
|
|
// 提示刷新
|
|
// this.freshTips( _data );
|
|
},
|
|
|
|
//挑戰
|
|
send31001( params, _cb ) {
|
|
this.SendProtocal( 31001, {
|
|
camp_id: this.camp_id,
|
|
id: params.id,
|
|
formation_type: params.formation_type,
|
|
pos_info: params.pos_info,
|
|
hallows_id: params.hallows_id
|
|
}, _cb )
|
|
},
|
|
|
|
handle31001: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
//领取
|
|
send31002(id, _cb ) {
|
|
this.SendProtocal( 31002, {
|
|
camp_id: this.camp_id,
|
|
id: id
|
|
}, _cb )
|
|
},
|
|
|
|
handle31002: function( _data ) {
|
|
// nx.bridge.acts.reqActsRewards();
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
setNextDay(day){
|
|
this.next_day = day;
|
|
},
|
|
|
|
getNextDay(){
|
|
return this.next_day || 0;
|
|
},
|
|
|
|
setCurDay(id){
|
|
this.cur_id = id;
|
|
},
|
|
|
|
getCurDay(){
|
|
return this.cur_id || 1;
|
|
},
|
|
|
|
setCampId(camp_id){
|
|
this.camp_id = camp_id;
|
|
},
|
|
|
|
getCampId(){
|
|
return this.camp_id;
|
|
},
|
|
|
|
// ============================================================
|
|
// 活动红点提示
|
|
// ============================================================
|
|
|
|
// // 红点提示更新
|
|
// freshTips: function() {
|
|
|
|
// let can = false;
|
|
// let list = this.vget( "sign15" ) || [];
|
|
// for( let i = 0; i < list.length; ++i ) {
|
|
// // 0不可领取 1可领取 2已领取
|
|
// let task = list[i];
|
|
// if( task && task.status == 1 ) {
|
|
// can = true;
|
|
// break;
|
|
// }
|
|
// }
|
|
// this.openTip( "reward", can );
|
|
// },
|
|
|
|
} );
|
|
|
|
// 模块导出
|
|
module.exports = HeroNewChalMod; |