Files
fc/dev/project/assets/Scripts/mod/pve/trainingcamp/cmp/cmp.trainingcamp.wnd.js
T

129 lines
3.4 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const BridgeWindow = require( "bridge.window" );
const FxSVC = require( "nx.fx.sv.expand" );
const TCController = require( "trainingcamp_controller" );
const BattleController = require( "battle_controller" );
const BattleConst = require( "battle_const" );
const TrainingcampEvent = require( "trainingcamp_event" );
const SVCItem = require( "nx.fx.sv.expand.item" );
cc.Class({
extends: BridgeWindow,
properties: {
svcList : {
default: null,
type : FxSVC,
displayName: "训练列表",
},
},
onLoad: function(){
this.openTrain();
this.bindGEvent( TrainingcampEvent.Update_Trainingcamp_Data_Event, this.refreshItem.bind( this ) );
this.bindGEvent( TrainingcampEvent.Is_Show_Formation_Event, this.refreshItemDiff.bind( this ));
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
nx.storage.set( "battleArena", null );
// BattleController.getInstance().send20060( BattleConst.Fight_Type.Training_Camp );
// console.log( "当前的完成状态显示" + JSON.stringify( finishes ) );
},
openTrain : function(){
let cfg = game.configs.training_camp_data.data_info;
let lst = [];
this.plotData = {};
let TTC = TCController.getInstance().getModel();
for (let i in cfg ) {
let item = nx.dt.objClone( cfg[i] ) ;
if( item ){
item.open = 0;
if( item.id <= TTC.finish_ids.length + 1 ){
item.open = 1;
}
let finish = TTC.IsFinishById( i );
let complete = TTC.IsCompleteById( i );
item.finish = finish;
item.complete = complete;
if( item.id == 1 ){
this.plotData = nx.dt.objClone( item );
}
lst.push( item );
// finishes.push( finish );
}
}
this.svcList.rebuild( lst );
},
refreshItem: function( _data ){
if( _data ){
let id = _data.id;
let chd = nx.gui.find( this.svcList, "view/content" ).children;
let nod = chd[id-1];
let cmp = nod.svItem;
if( cmp ){
let data = nx.dt.objClone( cmp.mdata );
data.isfirst = false;
data.complete = true;
data.plot = data.id == 1;
cmp.rebind( id - 1 ,data );
}
}
},
refreshItemDiff: function( _data ){
if( _data.flag != 1 ){
return;
}
let id = _data.id;
let chd = nx.gui.find( this.svcList, "view/content" ).children;
let nod = chd[id-1];
let cmp = nod.svItem;
if( cmp ){
let data = nx.dt.objClone( cmp.mdata );
nx.bridge.createPanel( "WndTrainingCampMore", data );
nx.bridge.closePanel( "WndTrainingCamp" );
}
},
// onTouchGoPlot: function(){
// nx.bridge.createPanel( "WndTrainingCampMore", this.plotData );
// nx.bridge.closePanel( "WndTrainingCamp" );
// },
// nx.bridge.createPanel( "WndTrainingCampMore", this.mdata );
// nx.bridge.closePanel( "WndTrainingCamp" );
// 重载:关闭前
onPreClosed: function() {
// this.svcschemeList.rebuild( [] );
this.svcList.rebuild( [] );
},
});