214 lines
5.7 KiB
JavaScript
214 lines
5.7 KiB
JavaScript
/******************************************************************
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
|
*
|
|
* 主界面 --- 剧情辅助器
|
|
*
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeComponent = require( "bridge.component" );
|
|
const PlotDefine = require( "plot.define" );
|
|
const RoleController = require( "role_controller" );
|
|
const { SCENE_TAG } = require( "define" );
|
|
const PPT = PlotDefine.PlotType;
|
|
|
|
cc.Class( {
|
|
|
|
extends: BridgeComponent,
|
|
|
|
properties: {
|
|
|
|
},
|
|
|
|
// 显示
|
|
onEnable: function() {
|
|
|
|
if( window.nx && nx.bridge.plot ){
|
|
// 视图监听
|
|
nx.bridge.plot.vbind( this, [
|
|
[ "id", this.onPlotChanged.bind( this ) ],
|
|
] );
|
|
// console.log( nx.bridge.plot.vget( "id" ) + "当前的引导相关数据enable" + nx.bridge.plot.vget( "step" ) );
|
|
// 检查
|
|
this.backMainScene();
|
|
}
|
|
|
|
},
|
|
|
|
// 关闭
|
|
onDisable: function() {
|
|
|
|
// 视图解绑
|
|
nx.bridge.plot.vunbind( this );
|
|
},
|
|
|
|
// 剧情改变
|
|
onPlotChanged: function( _id ) {
|
|
|
|
|
|
let role = RoleController.getInstance().getRoleVo();
|
|
if( !nx.bridge.plot.configs ) {
|
|
nx.mTip.openTip( "tipTask.spine", role.lev < 30 );
|
|
return;
|
|
}
|
|
|
|
// 筛选一次为进行的剧情
|
|
this.ids = [];
|
|
let mains = nx.bridge.plot.configs.base.mains;
|
|
let done = nx.bridge.plot.records.ids;
|
|
mains.forEach( _t => {
|
|
if( !nx.dt.arrMember( done, _t ) ) {
|
|
this.ids.push( _t );
|
|
}
|
|
} );
|
|
|
|
nx.bridge.closePanel( "WndSpecialSettle" );
|
|
nx.bridge.closePanel( "WndPlotGuide" );
|
|
nx.bridge.closePanel( "WndPlotDialogue" );
|
|
|
|
let info = nx.bridge.plot.configs[ _id ];
|
|
if( nx.dt.objEmpty( info ) ) {
|
|
nx.mTip.openTip( "tipTask.spine", role.lev < 30 );
|
|
return;
|
|
}
|
|
|
|
let wname = "";
|
|
switch( info.type ) {
|
|
case PPT.Dialogue: {
|
|
wname = "WndPlotDialogue";
|
|
} break;
|
|
case PPT.Guide: {
|
|
wname = "WndPlotGuide";
|
|
} break;
|
|
default: break;
|
|
}
|
|
|
|
if( nx.dt.strNEmpty( wname ) ) {
|
|
if ( nx.bridge.popups ) { nx.bridge.popups.clean(); }
|
|
if ( nx.mTip ) { nx.mTip.openTip( "tipTask.spine", false ); }
|
|
nx.bridge.createPanel( wname );
|
|
|
|
}
|
|
},
|
|
|
|
// ====================================================
|
|
// 剧情触发
|
|
// ====================================================
|
|
|
|
// 回归主场景
|
|
backMainScene: function() {
|
|
|
|
if( !nx.gui.find( nx.bridge.ui.getSceneNode( SCENE_TAG.scene ), "MainScene" ) ){
|
|
return;
|
|
}
|
|
nx.debug( "$Plot:回归主场景,剧情触发检查..." );
|
|
let role = RoleController.getInstance().getRoleVo();
|
|
// 引导未开启
|
|
if( !nx.bridge.plot ) {
|
|
nx.mTip.openTip( "tipTask.spine", role.lev < 30 );
|
|
// if( !nx.bridge.plot || !nx.bridge.plot.opened ) {
|
|
return;
|
|
}
|
|
|
|
// 老号不引导
|
|
let start = nx.bridge.plot.configs.base.start;
|
|
let done = nx.bridge.plot.records.ids;
|
|
if( !nx.dt.arrMember( done, start ) ) {
|
|
nx.mTip.openTip( "tipTask.spine", role.lev < 30 );
|
|
nx.bridge.vset( "DailyPop", 1 );
|
|
return;
|
|
}
|
|
|
|
// 进行中
|
|
let cur = nx.bridge.plot.vget( "id" );
|
|
if( nx.dt.strNEmpty( cur ) ) {
|
|
nx.mTip.openTip( "tipTask.spine", false );
|
|
return;
|
|
}
|
|
|
|
let queue = nx.dt.objClone( this.ids );
|
|
let check = function() {
|
|
|
|
if( nx.dt.arrEmpty( queue ) ) {
|
|
nx.bridge.vset( "DailyPop", 1 );
|
|
return;
|
|
}
|
|
|
|
nx.bridge.plot.fire( queue.shift(), ( _ret, _data ) => {
|
|
if( !_ret ) {
|
|
check();
|
|
}
|
|
} );
|
|
|
|
};
|
|
check();
|
|
},
|
|
|
|
// 回归战斗剧情主界面
|
|
backDramaHook: function() {
|
|
|
|
nx.debug( "$Plot:回归战斗剧情主界面,剧情触发检查..." );
|
|
|
|
// 引导未开启
|
|
if( !nx.bridge.plot ) {
|
|
// if( !nx.bridge.plot || !nx.bridge.plot.opened ) {
|
|
return;
|
|
}
|
|
|
|
// 进行中
|
|
let cur = nx.bridge.plot.vget( "id" );
|
|
if( nx.dt.strNEmpty( cur ) ) {
|
|
return;
|
|
}
|
|
|
|
let queue = nx.dt.objClone( nx.bridge.plot.configs.base.drama );
|
|
let check = function() {
|
|
|
|
if( nx.dt.arrEmpty( queue ) ) {
|
|
return;
|
|
}
|
|
|
|
nx.bridge.plot.fire( queue.shift(), ( _ret, _data ) => {
|
|
if( !_ret ) {
|
|
check();
|
|
}
|
|
} );
|
|
};
|
|
check();
|
|
},
|
|
|
|
// 进入编队界面
|
|
backDramaTeamHook: function() {
|
|
|
|
nx.debug( "$Plot:进入编队界面,剧情触发检查..." );
|
|
|
|
// 引导未开启
|
|
if( !nx.bridge.plot ) {
|
|
// if( !nx.bridge.plot || !nx.bridge.plot.opened ) {
|
|
return;
|
|
}
|
|
|
|
// 进行中
|
|
let cur = nx.bridge.plot.vget( "id" );
|
|
if( nx.dt.strNEmpty( cur ) ) {
|
|
return;
|
|
}
|
|
|
|
let queue = nx.dt.objClone( nx.bridge.plot.configs.base.drama_team );
|
|
let check = function() {
|
|
|
|
if( nx.dt.arrEmpty( queue ) ) {
|
|
return;
|
|
}
|
|
|
|
nx.bridge.plot.fire( queue.shift(), ( _ret, _data ) => {
|
|
if( !_ret ) {
|
|
check();
|
|
}
|
|
} );
|
|
};
|
|
check();
|
|
},
|
|
|
|
} );
|