419 lines
14 KiB
JavaScript
419 lines
14 KiB
JavaScript
const BridgeWindow = require( "bridge.window" );
|
|
const FxTogs = require( "nx.fx.togs" );
|
|
const SvcList = require( "nx.fx.sv.expand" );
|
|
const mod = require( "mail.mod" );
|
|
const BattleDramaController = require( "battle_drama_controller" );
|
|
const PathTool = require( "pathtool" );
|
|
const NxSpine = require( "nx.fx.spine" );
|
|
const ModP8 = require( "act.appoint8.mod" );
|
|
const themeMod = require( "acts.mod" );
|
|
const RoleController = require( "role_controller" );
|
|
const BattleController = require("battle_controller");
|
|
const BattleConst = require( "battle_const" );
|
|
|
|
cc.Class({
|
|
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
|
|
nodTog : { default : null, type: FxTogs },
|
|
// nodCnt : { default : null, type: SvcList },
|
|
nodInfos: { default : [], type: [cc.Node] },
|
|
listPage1: { default: null, type: SvcList },
|
|
listPage2: { default: null, type: SvcList },
|
|
listPage3: { default: null, type: SvcList },
|
|
|
|
Info1Role: {
|
|
default: null,
|
|
type: NxSpine
|
|
},
|
|
|
|
//node2
|
|
textAct1Level: { default : null, type: cc.Label },
|
|
textDays: { default : [], type: [cc.Label] },
|
|
textDayLines: { default : [], type: [cc.Node] },
|
|
btnAct1Goto: { default : null, type: cc.Node },
|
|
labAct1NotOpen: { default : null, type: cc.Node },
|
|
labAct1NotOpen2: { default:null, type:cc.Node },
|
|
nodAct0Tip : { default : null, type: cc.Node },
|
|
|
|
//node3
|
|
},
|
|
|
|
onLoad: function(){
|
|
|
|
this.mod = mod.getInstance();
|
|
if( !this.mod ){
|
|
this.delayClose();
|
|
}
|
|
|
|
|
|
var cur_ui_fight_type = BattleController.getInstance().getUIFightType();
|
|
if(cur_ui_fight_type == BattleConst.Fight_Type.Darma)
|
|
{
|
|
//TODO:
|
|
}
|
|
this.controller = BattleDramaController.getInstance();
|
|
this.model = this.controller.getModel();
|
|
this.select_index = 0;
|
|
|
|
},
|
|
|
|
onOpenConfigs( _param ) {
|
|
|
|
this.openServer = RoleController.getInstance().openServer;
|
|
this.nodTog.posTog = this.onTogMenu.bind( this );
|
|
this.nodTog.togTo( 0 );
|
|
this.onTogMenu( 0 );
|
|
|
|
let cfg = game.configs.activity_advertisement_data.data_const;
|
|
let reg_time = this.openServer.reg_time + cfg.partner_time.val;
|
|
this.left = reg_time - Math.floor( cc.sys.now() / 1000 ) > 0;
|
|
this.nodTog.node.children[2].active = reg_time - Math.floor( cc.sys.now() / 1000 ) > 0;
|
|
|
|
//是不是跳转回来显示活动页签
|
|
let needShowAct = cc.sys.localStorage.getItem("needBackOpenServerAct");
|
|
if(needShowAct == 1)
|
|
cc.sys.localStorage.removeItem("needBackOpenServerAct")
|
|
|
|
//如果副本活动都领完了,那就不显示了
|
|
if(this.closeBtn1)
|
|
{
|
|
nx.gui.setActive( this.nodTog, "tog1", false );
|
|
this.nodTog.togTo( 1 );
|
|
this.onTogMenu( 1 );
|
|
|
|
if(this.closeBtn2)
|
|
{
|
|
nx.gui.setActive( this.nodTog, "tog2", false );
|
|
this.nodTog.togTo( 2 );
|
|
this.onTogMenu( 2 );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
let cfg = game.configs.activity_advertisement_data.data_info;
|
|
let acts = nx.bridge.acts.acts;
|
|
let showcamp = null;
|
|
if( acts ) {
|
|
for( let a in acts ) {
|
|
let act = acts[ a ];
|
|
for (let i in cfg ) {
|
|
let info = cfg[i];
|
|
if( act.data.source == info.source_id ) {
|
|
showcamp = act.data;
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
if( showcamp ){
|
|
this.onReflashActs();
|
|
}else{
|
|
this.closeBtn2 = true;
|
|
}
|
|
|
|
if(this.closeBtn2)
|
|
{
|
|
nx.gui.setActive( this.nodTog, "tog2", false );
|
|
}
|
|
}
|
|
|
|
if(this.closeBtn2 == false && needShowAct == 1)
|
|
{
|
|
this.nodTog.togTo( 1 );
|
|
this.onTogMenu( 1 );
|
|
}
|
|
},
|
|
|
|
onPreClosed() {
|
|
this.listPage1.rebuild( [] );
|
|
this.listPage2.rebuild( [] );
|
|
this.listPage3.rebuild( [] );
|
|
},
|
|
|
|
onTogMenu: function( _idx )
|
|
{
|
|
for( let i = 0; i < this.nodInfos.length; i++ ) {
|
|
nx.gui.setActive( this.nodInfos[i], "", i==_idx );
|
|
}
|
|
// nx.debug( "$UI:onTogMenu:", _idx );
|
|
switch( _idx ){
|
|
case 0 : { this.onReflashDrama(); } break;
|
|
case 1 : { this.onReflashActs(); } break;
|
|
case 2 : { this.onReflashHero(); } break;
|
|
}
|
|
},
|
|
|
|
onReflashDrama: function()
|
|
{
|
|
var pass_list = this.model.getDramaRewardPassList(); // 已通关列表
|
|
var drama_data = this.model.getDramaData(); // 当前剧情副本数据
|
|
this.rewards_list = []
|
|
var floor = 0;
|
|
var max_dun_id = drama_data.max_dun_id;
|
|
var cur_drama_dungeon_info = game.configs.dungeon_data.data_drama_dungeon_info[ max_dun_id ];
|
|
if( cur_drama_dungeon_info ) {
|
|
floor = cur_drama_dungeon_info.floor || 0; // 当前层,用于比较的
|
|
}
|
|
|
|
this.closeBtn1 = true;
|
|
|
|
// 遍历出整个列表
|
|
for( var key in game.configs.dungeon_data.data_drama_reward ) {
|
|
var config = game.configs.dungeon_data.data_drama_reward[ key ];
|
|
if( config ) {
|
|
var target_config = game.configs.dungeon_data.data_drama_dungeon_info[ config.limit_id ];
|
|
if( target_config && config.is_prediction == "1") {
|
|
var object = { config_data: config, id: config.id, is_received: pass_list[ config.id ] || false, cur_dunname: target_config.name, cur_dun: floor, sort_index: 0,sort: config.sort, target_dun: target_config.floor,prediction_desc:config.prediction_desc };
|
|
this.rewards_list.push( object );
|
|
if( max_dun_id >= config.limit_id )
|
|
{
|
|
if( object.is_received )
|
|
{
|
|
object.sort_index = 3; // 已领取
|
|
// if(object.id == 8)
|
|
// {
|
|
// bShowSepGet = true;
|
|
// }
|
|
}
|
|
else
|
|
{
|
|
object.sort_index = 1; // 可领取
|
|
this.closeBtn1 = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
object.sort_index = 2; // 条件不满足
|
|
this.closeBtn1 = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(this.closeBtn1) return;
|
|
|
|
//排序
|
|
this.rewards_list.sort( Utils.tableLowerSorter( [ "sort_index", "sort" ] ) );
|
|
this.listPage1.rebuild( this.rewards_list );
|
|
},
|
|
|
|
onReflashActs: function()
|
|
{
|
|
this.closeBtn2 = true;
|
|
//刷新主展示活动0-->八日约定
|
|
let a1 = ModP8.getInstance();
|
|
a1.loadConfigs( "login_days_new_data" );
|
|
|
|
let drama_data = this.model.getDramaData();
|
|
|
|
|
|
let cfgs = game.configs.login_days_new_data.data_day;
|
|
if( cfgs ){
|
|
//先把奖励设置上去
|
|
for (let i in cfgs ) {
|
|
let cfg = cfgs[i];
|
|
var str = cc.js.formatStr(nx.text.getKey("action_str35"), cfg.day, cfg.desc);
|
|
this.textDays[i-1].string = str;
|
|
}
|
|
}
|
|
//开放等级
|
|
var open_config = game.configs.source_data.data_source_data[333];
|
|
if( open_config )
|
|
{
|
|
var str = cc.js.formatStr(nx.text.getKey("action_str36"), open_config.lev_limit[1]);
|
|
this.textAct1Level.string = open_config.desc1;
|
|
|
|
this.act1_data = drama_data.max_dun_id >= open_config.lev_limit[1];
|
|
}
|
|
//
|
|
for( let i = 0; i < this.textDayLines.length; i++ ) {
|
|
// nx.gui.setActive( this.textDayLines[i], "", false );
|
|
this.textDayLines[i].active = false;
|
|
this.textDays[i].node.color = new cc.Color(1,1,1);
|
|
}
|
|
let time = 0;
|
|
if(a1)
|
|
{
|
|
if( a1.data ){
|
|
time = a1.data.end_time;
|
|
}
|
|
|
|
}
|
|
|
|
this.labAct1NotOpen.active = false;
|
|
this.labAct1NotOpen2.active = false;
|
|
|
|
|
|
if(this.act1_data)
|
|
{
|
|
this.closeBtn2 = false;
|
|
var bShowTip = false;
|
|
//活动开启的
|
|
for( let i = 0; i < this.act1_data.length; i++ ) {
|
|
let data = this.act1_data[i];
|
|
var day = data.day-1;
|
|
switch(data.status)
|
|
{
|
|
case 2 : { //可领取
|
|
this.textDays[day].node.color = new cc.Color(150,91,8);
|
|
bShowTip = true;
|
|
} break;
|
|
case 3 : { //已领取
|
|
// nx.gui.setActive( this.textDayLines[day], "", true );
|
|
this.textDayLines[day].active = true;
|
|
this.textDays[day].node.color = new cc.Color(143,141,141);
|
|
} break;
|
|
}
|
|
}
|
|
this.nodAct0Tip.active = bShowTip;
|
|
|
|
this.btnAct1Goto.active = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
//活动未开启
|
|
this.nodAct0Tip.active = false;
|
|
this.btnAct1Goto.active = false;
|
|
if( open_config )
|
|
{
|
|
var binder = RoleController.getInstance().getRoleVo();
|
|
if(binder.lev < open_config.lev_limit[1])
|
|
this.labAct1NotOpen2.active = true;
|
|
else
|
|
this.labAct1NotOpen.active = true;
|
|
}
|
|
else
|
|
this.labAct1NotOpen.active = true;
|
|
}
|
|
|
|
|
|
let acts = nx.bridge.acts.acts;
|
|
let showcamp = null;
|
|
if( acts ) {
|
|
for( let a in acts ) {
|
|
let act = acts[ a ];
|
|
if( act.data.source == 333 ) {
|
|
showcamp = act.data;
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
if( showcamp ){
|
|
this.labAct1NotOpen.active = false;
|
|
}else{
|
|
this.labAct1NotOpen.active = true;
|
|
|
|
this.btnAct1Goto.active = false;
|
|
}
|
|
|
|
|
|
|
|
if( time > 0 ){
|
|
nx.gui.setCdTxt( this.btnAct1Goto.parent, "time/time", time - Math.floor( cc.sys.now() / 1000 ) );
|
|
}else{
|
|
nx.gui.setString( this.btnAct1Goto.parent, "time/time", "" );
|
|
|
|
}
|
|
nx.gui.setActive( this.btnAct1Goto.parent, "time", time > 0 );
|
|
//第二个颜色不变
|
|
this.textDays[1].node.color = new cc.Color(235,0,0);
|
|
|
|
//下面是4个小框活动
|
|
this.act_list = []
|
|
for( var key in game.configs.activity_advertisement_data.data_info )
|
|
{
|
|
var cf = game.configs.activity_advertisement_data.data_info[key];
|
|
if(cf.source_id != 333)
|
|
{
|
|
var open_config = game.configs.source_data.data_source_data[cf.source_id];
|
|
var object = { name:cf.name,desc:cf.desc,items:cf.items,source_id:cf.source_id,lv:open_config.lev_limit[1],tip:false};
|
|
|
|
//判断下活动有没有开启
|
|
if(cf.source_id == 334)
|
|
{
|
|
var theme = themeMod.getInstance().queryThemeBySource( cf.source_id );
|
|
if(theme)
|
|
{
|
|
this.closeBtn2 = false;
|
|
let akey = `acts.${theme.theme_id}.1.1002`;
|
|
object.tip = nx.mTip.vget( akey );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var theme = themeMod.getInstance().queryTheme( 101 );
|
|
if(theme)
|
|
{
|
|
for( let k in theme.theme_holiday_list )
|
|
{
|
|
let act = theme.theme_holiday_list[ k ];
|
|
if( act && act.source == cf.source_id )
|
|
{
|
|
this.closeBtn2 = false;
|
|
let akey = `acts.${theme.theme_id}.${act.cate}.${act.camp_id}.reward`;
|
|
object.tip = nx.mTip.vget( akey );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
this.act_list.push( object );
|
|
}
|
|
}
|
|
|
|
if(this.closeBtn2)
|
|
{
|
|
//要叠加上开服天数,15天之内也要显示
|
|
let role = RoleController.getInstance().getRoleVo();
|
|
if( role && role.open_day > 15 )
|
|
return;
|
|
else
|
|
this.closeBtn2 = false;
|
|
}
|
|
this.act_list.sort( Utils.tableLowerSorter( [ "source_id" ] ) );
|
|
this.listPage2.rebuild( this.act_list );
|
|
},
|
|
|
|
touchAct0Goto(){
|
|
nx.bridge.closePanel("WndOpenServer");
|
|
cc.sys.localStorage.setItem( "needBackOpenServerAct", 1);
|
|
nx.bridge.createPanel( "WndAppoint8" );
|
|
},
|
|
|
|
onReflashHero: function()
|
|
{
|
|
this.hero_list = [];
|
|
this.hero_list.push( 1 );
|
|
this.listPage3.rebuild( this.hero_list );
|
|
|
|
let cfg = game.configs.activity_advertisement_data.data_const;
|
|
let nod = this.nodInfos[2];
|
|
let timenod = nx.gui.find( nod, "time" );
|
|
|
|
let reg_time = this.openServer.reg_time + cfg.partner_time.val;
|
|
nx.gui.setCdTxt( timenod, "time", reg_time - Math.floor( cc.sys.now() / 1000 ) );
|
|
|
|
},
|
|
|
|
close: function(){
|
|
|
|
let role = RoleController.getInstance().getRoleVo();
|
|
role.openserverstatus = !this.closeBtn1 && !this.closeBtn2 && this.left;
|
|
|
|
this._super();
|
|
},
|
|
});
|