115 lines
2.4 KiB
JavaScript
115 lines
2.4 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* PVP控制器
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeController = require( "bridge.controller" );
|
|
|
|
const PVPController = cc.Class( {
|
|
|
|
extends: BridgeController,
|
|
|
|
// 初始化配置数据
|
|
initConfig: function() {
|
|
|
|
},
|
|
|
|
// 注册监听事件
|
|
registerEvents: function() {
|
|
},
|
|
|
|
// 注册协议接受事件
|
|
registerProtocals: function() {
|
|
|
|
// 跨服时空当前信息
|
|
this.RegisterProtocal( 22150, this.handle22150 );
|
|
|
|
},
|
|
|
|
reqBaseFromServer: function( _cb ){
|
|
|
|
let cfgs = [
|
|
"cross_ground_data",
|
|
"arena_data",
|
|
];
|
|
this.loadConfigs( cfgs, ( _ret, _data ) =>{
|
|
this.reqTimeSpace( _cb );
|
|
|
|
} )
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
// 打开挑战界面
|
|
openPVPWindow: function( status ) {
|
|
|
|
if( status ) {
|
|
nx.bridge.createPanel( "WndPVP" );
|
|
}else{
|
|
nx.bridge.closePanel( "WndPVP" );
|
|
}
|
|
|
|
},
|
|
|
|
// 通过id查找指定CrossGround配置
|
|
queryCGData: function( _id ) {
|
|
|
|
// 无效ID
|
|
if( !nx.dt.numPositive( _id, false ) ) {
|
|
return null;
|
|
}
|
|
|
|
const DT = game.configs.cross_ground_data.data_base;
|
|
for( let k in DT ) {
|
|
|
|
const ARR = DT[ k ];
|
|
if( nx.dt.arrEmpty( ARR ) ) {
|
|
continue;
|
|
}
|
|
|
|
for( let i in ARR ) {
|
|
let ifo = ARR[ i ];
|
|
if( ifo && ifo.id == _id ) {
|
|
return ifo;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 查找失败
|
|
nx.error( "查找CrossGround配置失败:", _id );
|
|
return null;
|
|
|
|
},
|
|
|
|
// ======================================================
|
|
// 时空裂缝
|
|
// ======================================================
|
|
|
|
// 打开时空裂缝界面
|
|
openTimeSpaceWindow: function( status ) {
|
|
|
|
if( status ) {
|
|
nx.bridge.createPanel( "WndPVPTimespace" );
|
|
}else{
|
|
nx.bridge.closePanel( "WndPVPTimespace" );
|
|
}
|
|
|
|
},
|
|
|
|
// 数据请求
|
|
reqTimeSpace: function( _cb ) {
|
|
this.H22150 = _cb;
|
|
this.SendProtocal( 22150, {}, _cb );
|
|
},
|
|
|
|
// 数据返回
|
|
handle22150: function( _data ) {
|
|
nx.dt.fnInvoke( this.H22150( true, _data ) );
|
|
},
|
|
|
|
} );
|
|
|
|
module.exports = PVPController; |