236 lines
7.1 KiB
JavaScript
236 lines
7.1 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 活动 中心城保卫战
|
|
*
|
|
******************************************************************/
|
|
|
|
const BasePage = require( "act.page.base" );
|
|
const NxSpine = require( "nx.fx.spine" );
|
|
const TipsController = require( "tips_controller" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: BasePage,
|
|
|
|
properties: {
|
|
nodContent : { type: cc.Node, default: null },
|
|
spRole: { default: null, type: NxSpine },
|
|
nodEndTime : { default: null, type: cc.Node },
|
|
nodScore : { default: null, type: cc.Node },
|
|
nodCloseIco : { default: null, type: cc.Node },
|
|
},
|
|
|
|
// 初始化
|
|
build: function( _data ) {
|
|
|
|
this.spRole.load( "resDB/models/H30115/show", ( _e ) => {
|
|
if( !_e ) {
|
|
this.spRole.action( "drama1", true );
|
|
} else {
|
|
this.spRole.stop();
|
|
}
|
|
} );
|
|
this._super( _data );
|
|
|
|
this.rfgs = gdata( this.data.config, "data_get_info3" );
|
|
let len = Object.keys( this.rfgs ).length;
|
|
nx.gui.gocChildren( this.nodContent, "", len );
|
|
// 无效
|
|
if( !this.mod ) {
|
|
|
|
return;
|
|
}
|
|
nx.gui.setActive( this.nodCloseIco, "", false );
|
|
// 活动监听
|
|
this.mod.vbind( this, [
|
|
[ "planeact", this.freshInfo.bind( this ) ],
|
|
[ "activepoints", this.freshActivePoints.bind( this ) ]
|
|
] );
|
|
|
|
|
|
|
|
},
|
|
|
|
onEnable: function(){
|
|
|
|
// 请求信息
|
|
this.mod.reqPlaneActData();
|
|
this.mod.reqGetActivePoints();
|
|
},
|
|
|
|
// 销毁
|
|
onDestroy: function() {
|
|
|
|
// 活动监听解除
|
|
if( this.mod ) {
|
|
this.mod.vunbind( this );
|
|
}
|
|
|
|
this._super();
|
|
},
|
|
|
|
freshInfo: function( _data ){
|
|
|
|
if( !_data || nx.dt.objEmpty( _data ) ){
|
|
return;
|
|
}
|
|
/****
|
|
* "aim_args":[
|
|
* {"aim_args_key":4,"aim_args_val":56,"aim_args_str":""},
|
|
* {"aim_args_key":5,"aim_args_val":0,"aim_args_str":""}
|
|
* ]
|
|
|
|
*/
|
|
let aim_list = _data.aim_list;
|
|
aim_list.sort( ( a ,b ) => {
|
|
return a.sortid - b.sortid;
|
|
} )
|
|
this.planeInfo = _data;
|
|
this.aims = aim_list;
|
|
let chd = this.nodContent.children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
|
|
let sinfo = aim_list[i];
|
|
let info = this.rfgs[sinfo.aim];
|
|
nx.gui.setString( nod, "descs/desc/title", info.desc );
|
|
let cmp = nx.gui.getComponent( nod, "lst", "cmp.common.itemlayout" );
|
|
if( cmp ){
|
|
cmp.rebuild( info.reward );
|
|
}
|
|
|
|
let target = 0;
|
|
let value = 0;
|
|
nx.gui.find( nod, "go" ).zIndex = info.source_id;
|
|
nx.gui.find( nod, "get" ).aim = sinfo.aim;
|
|
sinfo.aim_args.forEach( _aim => {
|
|
if( _aim && _aim.aim_args_key == 4 ){
|
|
target = _aim.aim_args_val;
|
|
}
|
|
if( _aim && _aim.aim_args_key == 5 ){
|
|
value = _aim.aim_args_val;
|
|
}
|
|
} )
|
|
nx.gui.setActive( nod, "go", sinfo.status == 0 );
|
|
nx.gui.setActive( nod, "get", sinfo.status == 1 );
|
|
nx.gui.setActive( nod, "finish", sinfo.status == 2 );
|
|
nx.gui.setString( nod, "descs/leftdesc/prog", value + "/" + target );
|
|
nx.gui.setActive( nod, "descs/leftdesc", sinfo.status != 2 );
|
|
}
|
|
let left = _data.remain_sec > 0 ? _data.remain_sec : 0.1;
|
|
nx.gui.setCdTxt( this.nodEndTime, "txt", left, () => {
|
|
nx.gui.setString( this.nodEndTime, "txt", nx.text.getKey( "lab_planesafk_main_have_over" ) );
|
|
} );
|
|
|
|
},
|
|
|
|
freshActivePoints: function( _actinfo ){
|
|
|
|
let point = _actinfo.point;
|
|
nx.gui.setString( this.nodScore, "title/points/point", point );
|
|
|
|
this.rfg = gdata( this.data.config, "data_get_reward" );
|
|
let len = gdata( this.data.config, "data_get_reward_length" );
|
|
|
|
let prog = nx.gui.getComponent( this.nodScore, "prog", cc.ProgressBar );
|
|
let total = this.rfg[len].need_point;
|
|
let percent = parseFloat( point / total );
|
|
if( prog ){
|
|
prog.progress = percent;
|
|
}
|
|
|
|
let rewards = _actinfo.reward_list;
|
|
let chd = nx.gui.find( this.nodScore, "rewards" ).children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
let item = this.rfg[i+1];
|
|
let showcmp = nx.gui.getComponent( nod, "show", "cmp.common.itemlayout" );
|
|
if( showcmp ){
|
|
showcmp.rebuild( item.reward );
|
|
}
|
|
nx.gui.setString( nod, "point", nx.text.format( "ActPoint", item.need_point ) );
|
|
nx.gui.find( nod, "touch" ).zIndex = i + 1;
|
|
nx.gui.find( nod, "get" ).zIndex = i + 1;
|
|
nx.gui.setActive( nod, "ico_close", true );
|
|
nx.gui.setActive( nod, "ico_open", false );
|
|
nx.gui.setActive( nod, "get", point >= item.need_point );
|
|
rewards.forEach( _get => {
|
|
if( _get && _get.id == ( i + 1 ) ){
|
|
nx.gui.setActive( nod, "ico_open", true );
|
|
nx.gui.setActive( nod, "get", false );
|
|
}
|
|
} )
|
|
nx.gui.setActive( nod, "show", false );
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
onTouchHideAllDesc: function(){
|
|
|
|
let chd = nx.gui.find( this.nodScore, "rewards" ).children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
nx.gui.setActive( nod, "show", false );
|
|
}
|
|
|
|
nx.gui.setActive( this.nodCloseIco, "", false );
|
|
},
|
|
|
|
|
|
onTouchGetActiveReward: function( _btn ){
|
|
|
|
let id = this.rfg[_btn.zIndex].id;
|
|
|
|
this.mod.reqGetActiveReward( id );
|
|
},
|
|
|
|
onTouchGet: function( _btn ){
|
|
|
|
if( this.planeInfo.remain_sec == 0 ){
|
|
nx.tbox( "lab_recruit_hero_window_tip_6" );
|
|
return;
|
|
}
|
|
let id = _btn.aim;
|
|
|
|
this.mod.reqGetPlaneActGift( id );
|
|
},
|
|
|
|
onTouchGoto: function( _btn ){
|
|
|
|
if( this.planeInfo.remain_sec == 0 ){
|
|
nx.tbox( "lab_recruit_hero_window_tip_6" );
|
|
return;
|
|
}
|
|
let source = _btn.zIndex;
|
|
nx.bridge.jumper.jump2Window( source );
|
|
|
|
},
|
|
|
|
onTouchShow: function( _btn ){
|
|
|
|
let index = parseInt( _btn.zIndex - 1);
|
|
let chd = nx.gui.find( this.nodScore, "rewards" ).children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
if( i != index ){
|
|
nx.gui.setActive( nod, "show", false );
|
|
}
|
|
|
|
}
|
|
let nodShow = nx.gui.find( chd[index], "show" );
|
|
nx.gui.setActive( nodShow, "", !nodShow.active );
|
|
nx.gui.setActive( this.nodCloseIco, "", nodShow.active == true );
|
|
},
|
|
|
|
onTouchHelp: function(){
|
|
|
|
let TC = TipsController.getInstance();
|
|
let explain = gdata( this.data.config, "data_explain" );
|
|
TC.showDetailPanel( explain );
|
|
|
|
},
|
|
|
|
} );
|