299 lines
8.4 KiB
JavaScript
299 lines
8.4 KiB
JavaScript
// --------------------------------------------------------------------
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 陣營大戰(打年獸)
|
|
// <br/>Create: 2019-02-27 11:03:16
|
|
// --------------------------------------------------------------------
|
|
|
|
const BridgeController = require( "bridge.controller" );
|
|
const CampfightConst = require( "campfight.const" );
|
|
const BTC = require("battle_controller");
|
|
|
|
const CampfightMod = cc.Class( {
|
|
|
|
extends: BridgeController,
|
|
ctor: function() {
|
|
},
|
|
|
|
// 初始化配置数据
|
|
initConfig: function() {
|
|
this.cur_peroid = 0;
|
|
this.cur_status = 0;
|
|
this.is_contest = false;//本人是否參賽
|
|
this.is_inPanel = false;
|
|
this.topthree = [];
|
|
this.first = true;
|
|
},
|
|
|
|
// 注册协议接受事件
|
|
registerProtocals: function() {
|
|
this.RegisterProtocal( 31300, this.handle31300 ); //擂臺賽信息
|
|
this.RegisterProtocal( 31301, this.handle31301 ); //设置阵法
|
|
this.RegisterProtocal( 31302, this.handle31302 ); //保存阵法
|
|
this.RegisterProtocal( 31303, this.handle31303 ); //打年獸
|
|
this.RegisterProtocal( 31305, this.handle31305 ); //往期排行榜
|
|
this.RegisterProtocal( 31304, this.handle31304 ); //資格公示分組榜
|
|
this.RegisterProtocal( 31306, this.handle31306 ); //戰鬥活動面板
|
|
this.RegisterProtocal( 31307, this.handle31307 ); //pvp戰鬥
|
|
this.RegisterProtocal( 31308, this.handle31308 ); //個人分組
|
|
this.RegisterProtocal( 31309, this.handle31309 ); //pve结束阶段公示榜
|
|
this.RegisterProtocal( 31310, this.handle31310 ); // 推送结算
|
|
this.RegisterProtocal( 31311, this.handle31311 ); //录像列表
|
|
this.RegisterProtocal( 31312, this.handle31312 ); //位次變動推送
|
|
this.RegisterProtocal( 31313, this.handle31313 ); //设置防御阵法
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function( _cb ) {
|
|
|
|
// 配置加载
|
|
let cfgs = [
|
|
"arena_camp_data"
|
|
];
|
|
this.loadConfigs( cfgs, ( _ret, _data ) => {
|
|
nx.dt.fnInvoke( _cb, true );
|
|
this.reqOldRank();
|
|
} );
|
|
|
|
|
|
},
|
|
|
|
setMainPanel(_is){
|
|
this.is_inPanel = _is;
|
|
},
|
|
|
|
//當前界面是否在主界面
|
|
inMainPanel(){
|
|
return this.is_inPanel;
|
|
},
|
|
|
|
// 请求主要信息
|
|
reqMainData: function( _cb ) {
|
|
this.SendProtocal( 31300, {}, _cb );
|
|
},
|
|
|
|
// 请求擂臺賽信息返回
|
|
handle31300: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
this.setCurPeriod(_data.period);
|
|
this.setActStatus(_data.status);
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_MAIN,_data);
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_STATUS_CHANGE,_data.status);
|
|
|
|
if(!this.inMainPanel()){
|
|
if(_data.status == 1 || _data.status == 5){
|
|
nx.bridge.createPanel("WndCampfightPush",{status:_data.status});
|
|
}
|
|
}
|
|
},
|
|
|
|
//设置阵法
|
|
sendForm: function(formation_type,group,posinfo,hallows_id,_cb){
|
|
this.SendProtocal( 31301, {formation_type:formation_type,group:group,pos_info:posinfo,hallows_id:hallows_id}, _cb );
|
|
},
|
|
|
|
handle31301: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
if(_data.flag == 1){
|
|
nx.tbox("CampFitFormSave");
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_UPDATE_BTN,"form");
|
|
}
|
|
},
|
|
|
|
//请求阵法
|
|
reqForm: function(formation_type,group,_cb){
|
|
this.SendProtocal( 31302, {formation_type:formation_type,group:group}, _cb );
|
|
},
|
|
|
|
handle31302: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_UPDATE_FORM,_data);
|
|
},
|
|
|
|
reqBatBoss: function(_cb){
|
|
this.SendProtocal( 31303, {}, _cb );
|
|
},
|
|
handle31303: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
reqZigeGroup: function( _group,_cb ) {
|
|
this.SendProtocal( 31304, {group:_group}, _cb );
|
|
},
|
|
|
|
handle31304: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_ZIGE_UI,_data);
|
|
},
|
|
|
|
reqOldRank: function( _cb ) {
|
|
this.SendProtocal( 31305, {}, _cb );
|
|
},
|
|
|
|
handle31305: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
|
|
let showdata = {
|
|
type: nx.text.getKey( "CampFitTopThree" ),
|
|
showCampList : _data.rank_list,
|
|
};
|
|
if( nx.dt.arrNEmpty( _data.rank_list ) ){
|
|
if( this.first ){
|
|
nx.bridge.vset( "CampfightTop", showdata );
|
|
for (let i = 0; i < _data.rank_list.length; i++) {
|
|
let item = _data.rank_list[i];
|
|
if( item.rank < 4 ){
|
|
this.topthree.push( item );
|
|
}
|
|
}
|
|
this.first = false;
|
|
}
|
|
|
|
}
|
|
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_UPDATE_RANK,_data);
|
|
},
|
|
|
|
reqBatGroup: function( _group,_cb ) {
|
|
this.SendProtocal( 31306, {group:_group}, _cb );
|
|
},
|
|
|
|
handle31306: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_BATUI,_data);
|
|
},
|
|
|
|
reqBat: function(formation_type,group,posinfo,hallows_id,_rid,_srv_id,_cb ) {
|
|
this.SendProtocal( 31307, {formation_type:formation_type, group:group, pos_info:posinfo, hallows_id:hallows_id,rid:_rid, srv_id:_srv_id}, _cb );
|
|
},
|
|
|
|
handle31307: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
|
|
},
|
|
|
|
reqSelfGroup: function( _cb ) {
|
|
this.SendProtocal( 31308, {}, _cb );
|
|
},
|
|
|
|
// 请求擂臺賽信息返回
|
|
handle31308: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
if(_data.rank == 0){
|
|
this.is_contest = false;
|
|
this.setGroup(1);//默認第一組
|
|
}else{
|
|
this.is_contest = true;
|
|
this.setGroup(_data.group);
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_UPSEAT,this.group);
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_SETRANK,_data.rank);
|
|
},
|
|
|
|
reqMonsDmgRank: function( _cb ) {
|
|
this.SendProtocal( 31309, {}, _cb );
|
|
},
|
|
|
|
handle31309: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_MONS_UI,_data);
|
|
},
|
|
|
|
handle31310: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
nx.bridge.vset( "ResultInfo", _data );
|
|
},
|
|
|
|
reqReportList: function( _group ,_cb ) {
|
|
this.SendProtocal( 31311, {group:_group}, _cb );
|
|
},
|
|
|
|
handle31311: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_REPORT,_data);
|
|
},
|
|
|
|
handle31312: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
nx.bridge.createPanel("WndCampfightPlace",{data:_data});
|
|
},
|
|
|
|
//设置防御阵法
|
|
setDefendForm: function(formation_type,group,pos_info,hallows_id,_cb){
|
|
this.SendProtocal( 31313, {formation_type:formation_type,group:group,pos_info:pos_info,hallows_id:hallows_id}, _cb );
|
|
},
|
|
|
|
handle31313: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
//配置
|
|
//當前活動周期
|
|
setCurPeriod(period){
|
|
this.cur_peroid = period;
|
|
},
|
|
|
|
getCurPeriod(){
|
|
return this.cur_peroid;
|
|
},
|
|
|
|
//當前分組
|
|
setGroup(group){
|
|
this.group = group;
|
|
},
|
|
|
|
getGroup(){
|
|
return this.group;
|
|
},
|
|
|
|
//活動階段
|
|
setActStatus(status){
|
|
this.cur_status = status;
|
|
},
|
|
|
|
getActStatus(){
|
|
return this.cur_status;
|
|
},
|
|
|
|
isContest(){
|
|
return this.is_contest;
|
|
},
|
|
|
|
setReqGroup(group){
|
|
this.reqing_group = group;
|
|
},
|
|
|
|
getReqGroup(){
|
|
return this.reqing_group || 1;
|
|
}
|
|
} );
|
|
|
|
module.exports = CampfightMod; |