178 lines
5.0 KiB
JavaScript
178 lines
5.0 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 限定招募五选一升星活动
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const NxSpine = require("nx.fx.spine");
|
||
|
|
const NxExpand = require("nx.fx.sv.expand");
|
||
|
|
const PathTool = require("pathtool");
|
||
|
|
const HeroVo = require("hero_vo");
|
||
|
|
const TipsController = require("tips_controller");
|
||
|
|
const ActPage = require( "act.page.base" );
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: ActPage,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
empNd:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
roleNd:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
role:{
|
||
|
|
default:null,
|
||
|
|
type:NxSpine
|
||
|
|
},
|
||
|
|
roleTag:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
btnLock:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
list:{
|
||
|
|
default:null,
|
||
|
|
type:NxExpand
|
||
|
|
},
|
||
|
|
fabHero:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Prefab
|
||
|
|
},
|
||
|
|
limitTime:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 初始化
|
||
|
|
build: function( _data ) {
|
||
|
|
|
||
|
|
this._super( _data );
|
||
|
|
this.upstar_data = game.configs.holiday_upstars_new_data;
|
||
|
|
// 活动监听
|
||
|
|
this.mod.vbind( this, [
|
||
|
|
[ "limitUpstarAwards", this.freshList.bind( this ) ],
|
||
|
|
] );
|
||
|
|
},
|
||
|
|
|
||
|
|
onEnable(){
|
||
|
|
this.list.svcKey = this.data.source;
|
||
|
|
this.mod.send29220();
|
||
|
|
this.mod.send29221();
|
||
|
|
},
|
||
|
|
|
||
|
|
onDisable(){
|
||
|
|
this.list.rebuild([]);
|
||
|
|
},
|
||
|
|
|
||
|
|
// 销毁
|
||
|
|
onDestroy: function() {
|
||
|
|
|
||
|
|
// 活动监听解除
|
||
|
|
if( this.mod ) {
|
||
|
|
this.mod.vunbind( this );
|
||
|
|
}
|
||
|
|
this._super();
|
||
|
|
},
|
||
|
|
|
||
|
|
freshList(award_list){
|
||
|
|
if(!award_list || award_list.length == 0)return;
|
||
|
|
this.list.svcKey = this.data.source;
|
||
|
|
this.list.rebuild(award_list);
|
||
|
|
|
||
|
|
//先設置已經選擇的英雄
|
||
|
|
let partner_bid = this.mod.getChooseHero().bid;
|
||
|
|
let cfg = game.configs.partner_data.data_partner_base[partner_bid];
|
||
|
|
if(cfg){
|
||
|
|
nx.gui.hideAllChildren( this, "left/tag" );
|
||
|
|
this.empNd.active = false;
|
||
|
|
if(!this.select_hero){
|
||
|
|
this.select_hero = cc.instantiate(this.fabHero);
|
||
|
|
this.select_hero.parent = this.roleTag;
|
||
|
|
}
|
||
|
|
let cmp = nx.gui.getComponent(this.select_hero,"","cmp.item.base");
|
||
|
|
if(cmp){
|
||
|
|
let hero = new HeroVo();
|
||
|
|
hero.bid = this.mod.getChooseHero().bid;
|
||
|
|
hero.star = this.mod.getChooseHero().star;
|
||
|
|
hero.camp_type = cfg.camp_type;
|
||
|
|
cmp.rebind(0,hero,"");
|
||
|
|
}
|
||
|
|
|
||
|
|
let res_path = PathTool.getSpinePath( cfg.bustid, "show", false );
|
||
|
|
this.role.load( res_path, ( _e ) => {
|
||
|
|
if( !_e ) {
|
||
|
|
this.role.action( "action1", true );
|
||
|
|
} else {
|
||
|
|
this.role.stop();
|
||
|
|
}
|
||
|
|
} );
|
||
|
|
}else{
|
||
|
|
|
||
|
|
this.empNd.active = true;
|
||
|
|
nx.gui.setSpriteFrame(this.empNd,"",cc.path.join("resDB/empty","half_show"));
|
||
|
|
if(!this.select_hero){
|
||
|
|
this.select_hero = cc.instantiate(this.fabHero);
|
||
|
|
this.select_hero.parent = this.roleTag;
|
||
|
|
}
|
||
|
|
let cmp = nx.gui.getComponent(this.select_hero,"","cmp.item.base");
|
||
|
|
if(cmp){
|
||
|
|
cmp.rebind(0,{},"");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(this.mod.getIsLock() == 1){
|
||
|
|
this.btnLock.active = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setCdTxt(this.limitTime,"",this.mod.getLimitTime() - client.socket.getTime());
|
||
|
|
},
|
||
|
|
|
||
|
|
setLockHeroInfo(data){
|
||
|
|
if(nx.dt.objEmpty(data))return;
|
||
|
|
if(this.mod.getIsLock() == 1)return;//已鎖定
|
||
|
|
//先設置已經選擇的英雄
|
||
|
|
|
||
|
|
//打開英雄選擇界面
|
||
|
|
nx.bridge.createPanel("WndActUpstarHero",{plist:data.partner_list,mod:this.mod,acts_type:this.data.source});
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickSelectHero(){
|
||
|
|
if(this.mod.getIsLock() == 1)return;//已鎖定
|
||
|
|
let data = this.mod.vget("limitHeros");
|
||
|
|
if(nx.dt.objEmpty(data))return;
|
||
|
|
if(data.partner_list == 0){
|
||
|
|
return nx.tbox("NotAbortHero");
|
||
|
|
}else{
|
||
|
|
//打開英雄選擇界面
|
||
|
|
nx.bridge.createPanel("WndActUpstarHero",{plist:data.partner_list,mod:this.mod,acts_type:this.data.source});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickLock(){
|
||
|
|
let str = nx.text.getKey("ActUpstarLock_");
|
||
|
|
nx.mbox(str,["cancel","confirm"],(_key,_box)=>{
|
||
|
|
_box.close();
|
||
|
|
if(_key == "confirm"){
|
||
|
|
this.mod.send29223((_data)=>{
|
||
|
|
if(!_data)return;
|
||
|
|
this.btnLock.active = false;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickRule(){
|
||
|
|
let TC = TipsController.getInstance();
|
||
|
|
if( TC ) {
|
||
|
|
let config = gdata("holiday_upstars_new_data","data_const","desc");
|
||
|
|
TC.showTextPanel(null,config.desc );
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|