264 lines
9.4 KiB
JavaScript
264 lines
9.4 KiB
JavaScript
const BridgeWindow = require( "bridge.window" );
|
||
const FxSVC = require( "nx.fx.sv.expand" );
|
||
const BattleDramaController = require( "battle_drama_controller" );
|
||
const DramaEvent = require( "battle_drama_event" );
|
||
const NxSpine = require( "nx.fx.spine" );
|
||
const PathTool = require( "pathtool" );
|
||
|
||
cc.Class( {
|
||
extends: BridgeWindow,
|
||
|
||
properties: {
|
||
|
||
SVClist: { default: null, type: FxSVC },
|
||
|
||
pass_dungeon_name: {
|
||
default: null,
|
||
type: cc.Label
|
||
},
|
||
|
||
role: {
|
||
default: null,
|
||
type: NxSpine
|
||
},
|
||
|
||
sepGetIcon: {
|
||
default: null,
|
||
type: cc.Node
|
||
},
|
||
},
|
||
|
||
// LIFE-CYCLE CALLBACKS:
|
||
|
||
onLoad() {
|
||
this.controller = BattleDramaController.getInstance();
|
||
this.model = this.controller.getModel();
|
||
this.config_list = {};
|
||
// this.summon_special_data = {};
|
||
|
||
this.bindGEvent( DramaEvent.BattleDrama_Drama_Reward_Data, this.updateShowInfoList.bind( this ) );
|
||
},
|
||
|
||
onEnable: function(){
|
||
|
||
},
|
||
|
||
start() {
|
||
},
|
||
|
||
onOpenConfigs() {
|
||
this.updateShowInfoList();
|
||
},
|
||
|
||
onPreClosed() {
|
||
this.SVClist.rebuild( [] );
|
||
},
|
||
|
||
// 更新显示
|
||
updateShowInfoList: function( id, type ) {
|
||
if( id == null ) {
|
||
this.initConfigRewardList();
|
||
} else {
|
||
|
||
if( nx.dt.arrEmpty( id.list ) ){
|
||
if( type == 0 ) {
|
||
var object = this.config_list[ id ];
|
||
if( object ) {
|
||
object.is_received = true; // 已领取
|
||
object.sort_index = 3; // 已领取排序id
|
||
}
|
||
}
|
||
}else{
|
||
for (let i = 0; i < id.list.length; i++) {
|
||
let info = id.list[i];
|
||
let object = this.config_list[ info.id ];
|
||
if( object ) {
|
||
object.is_received = true; // 已领取
|
||
object.sort_index = 3; // 已领取排序id
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//特殊奖励
|
||
// if( type == 1 ) {
|
||
// var object = this.config_list[ id ];
|
||
// object.is_spe_received = true;
|
||
// object.spe_sort_index = 3;
|
||
// this.summon_special_data.sort_index = 3;
|
||
// }
|
||
}
|
||
if( this.rewards_list ) {
|
||
this.rewards_list.sort( Utils.tableLowerSorter( [ "sort_index", "sort" ] ) );
|
||
|
||
|
||
|
||
this.SVClist.rebuild( this.rewards_list );
|
||
// 引导辅助
|
||
if( nx.bridge.plot && nx.bridge.plot.isDoing() ) {
|
||
this.positionGet();
|
||
}
|
||
}
|
||
},
|
||
|
||
// 初始化奖励列表
|
||
initConfigRewardList: function() {
|
||
if( this.rewards_list ) return;
|
||
this.rewards_list = []
|
||
var floor = 0;
|
||
var pass_list = this.model.getDramaRewardPassList(); // 已通关列表
|
||
var spe_pass_list = this.model.getDramaSpeRewardPassList(); // 特殊通关奖励
|
||
var drama_data = this.model.getDramaData(); // 当前剧情副本数据
|
||
if( nx.dt.objEmpty( drama_data ) ) {
|
||
return false;
|
||
}
|
||
|
||
//spine动画,显示大奖励
|
||
let res_path = PathTool.getSpinePath( "H30095", "show", false );
|
||
this.role.load( res_path, ( _e ) => {
|
||
if( !_e ) {
|
||
this.role.action( "drama1", true );
|
||
} else {
|
||
this.role.stop();
|
||
}
|
||
} );
|
||
|
||
//已经通过显示
|
||
if(drama_data.max_dun_id == null || drama_data.max_dun_id == 0)
|
||
{
|
||
this.pass_dungeon_name.string = "--"; // 名字
|
||
}
|
||
else
|
||
{
|
||
var per_drama_dungeon_info = game.configs.dungeon_data.data_drama_dungeon_info[ drama_data.max_dun_id ];
|
||
this.pass_dungeon_name.string = per_drama_dungeon_info.name; // 名字
|
||
}
|
||
|
||
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; // 当前层,用于比较的
|
||
}
|
||
|
||
//特殊关卡1-40,10400,id是8,策划说写死
|
||
let bShowSepGet = false;
|
||
|
||
// 遍历出整个列表
|
||
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 ) {
|
||
let is_spe_received = spe_pass_list[ config.id ];
|
||
|
||
var object = { config_data: config, id: config.id, is_received: pass_list[ config.id ] || false, is_spe_received: is_spe_received, cur_dunname: target_config.name, cur_dun: floor, sort_index: 0,sort: config.sort, spe_sort_index: 0, target_dun: target_config.floor };
|
||
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; // 可领取
|
||
}
|
||
if( object.is_spe_received ) {
|
||
object.spe_sort_index = 3;
|
||
} else {
|
||
object.spe_sort_index = 1;
|
||
}
|
||
} else {
|
||
object.sort_index = 2; // 条件不满足
|
||
object.spe_sort_index = 2;
|
||
}
|
||
// 储存一下
|
||
this.config_list[ config.id ] = object;
|
||
}
|
||
}
|
||
|
||
//是否添加通关特殊奖励
|
||
// if( config.special_items.length != 0 ) {
|
||
// this.summon_special_data.id = config.id;
|
||
// this.summon_special_data.sort_index = this.config_list[ config.id ].spe_sort_index;
|
||
// if( floor < 40 ) {
|
||
// this.tips.string = cc.js.formatStr( "(%d/%d)", floor, 40 );
|
||
// } else {
|
||
// this.tips.string = "(40/40)";
|
||
// var RoleController = require( "role_controller" );
|
||
// let role_vo = RoleController.getInstance().getRoleVo();
|
||
// let claim_p = nx.storage.get( role_vo.srv_id + "_" + role_vo.rid + "chappass" );
|
||
// if( claim_p ) {//领取过
|
||
// nx.gui.setString(this.reflect_btn,"txt",nx.text.getKey("Got"));
|
||
// nx.gui.setLocked(this.reflect_btn.node,"",true);
|
||
// } else {//未领取
|
||
// nx.gui.setLocked(this.reflect_btn.node,"",false);
|
||
// }
|
||
// }
|
||
|
||
// let cmp = nx.gui.getComponent( this.summon_item, "", "nx.fx.sv.expand.item" );
|
||
// cmp.rebind( 1, { bid: config.special_items[ 0 ][ 0 ], num: config.special_items[ 0 ][ 1 ] }, "" );
|
||
// }
|
||
}
|
||
|
||
nx.gui.setActive( this.sepGetIcon, "", bShowSepGet );
|
||
},
|
||
|
||
// touchReflect() {
|
||
// if( this.summon_special_data.sort_index == 1 ) {
|
||
// this.controller.send13009( 1, this.summon_special_data.id );
|
||
// nx.gui.setString(this.reflect_btn,"txt",nx.text.getKey("Got"));
|
||
// nx.gui.setLocked(this.reflect_btn.node,"",true);
|
||
// var RoleController = require( "role_controller" );
|
||
// let role_vo = RoleController.getInstance().getRoleVo();
|
||
// nx.storage.set( role_vo.srv_id + "_" + role_vo.rid + "chappass", 1 );
|
||
// }
|
||
// },
|
||
|
||
// ============================================
|
||
// 引导辅助
|
||
// ============================================
|
||
|
||
// 首次领奖定位
|
||
positionGet: function() {
|
||
|
||
// 查找第一个能领取的任务
|
||
let node = null;
|
||
let children = this.SVClist.bindSCV.content.children;
|
||
for( let i = 0; i < children.length; ++i ) {
|
||
let temp = children[ i ];
|
||
if( temp.svItem && temp.svItem.mdata &&
|
||
temp.svItem.comfirm_btn.active && temp.svItem.mdata.id == 77 ) {
|
||
node = temp;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if( !node ) {
|
||
nx.error( "$DramaReward:定位首次领奖失败!" );
|
||
node = children[ 0 ];
|
||
if( !node ) {
|
||
return;
|
||
}
|
||
}
|
||
|
||
let btn = node.svItem.comfirm_btn;
|
||
let cell = nx.gui.find( this, "container/plotCell" );
|
||
let pos = btn.convertToWorldSpaceAR( cc.Vec2.ZERO );
|
||
cell.position = cell.parent.convertToNodeSpaceAR( pos );
|
||
cell.width = btn.width;
|
||
cell.height = btn.height;
|
||
cell.svItem = node.svItem;
|
||
},
|
||
|
||
// 点击首次领奖处理
|
||
onTouchFirstGet: function() {
|
||
|
||
let cell = nx.gui.find( this, "container/plotCell" );
|
||
if( cell && cell.svItem ) {
|
||
cell.svItem.touchConfirm();
|
||
}
|
||
},
|
||
|
||
} );
|