360 lines
11 KiB
JavaScript
360 lines
11 KiB
JavaScript
const BridgeWindow = require( "bridge.window" );
|
|
const TowerMod = require( "startower.mod" );
|
|
const StartowerEvent = require( "startower.define" );
|
|
const RankConstant = require( "rank_constant" );
|
|
const RoleController = require( "role_controller" );
|
|
const ItemLayout = require( "cmp.common.itemlayout" );
|
|
const TipsController = require( "tips_controller" );
|
|
const FirstAwardCmp = require("cmp.startower.firstaward");
|
|
const NxSpine = require("nx.fx.spine");
|
|
const PathTool = require("pathtool");
|
|
|
|
cc.Class( {
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
rank_list: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
rank_item: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
tower_list: {
|
|
default: null,
|
|
type: ItemLayout
|
|
},
|
|
curawards:{
|
|
default: null,
|
|
type: ItemLayout
|
|
},
|
|
//十层解锁
|
|
jump_edit: {
|
|
default: null,
|
|
type: cc.EditBox
|
|
},
|
|
btn_jump: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
FirstCmp: {
|
|
default: null,
|
|
type: FirstAwardCmp
|
|
},
|
|
jumpSp:{
|
|
default:null,
|
|
type:NxSpine
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
|
|
nx.gui.setActive( this.btn_jump,"",false );
|
|
nx.gui.setActive( this, "main/right/powertip",false );
|
|
this.ctrl = TowerMod.getInstance();
|
|
this.top3_item_list = {};
|
|
this.jump_str = "";
|
|
this.is_enough_jump = false;//是否已到达跳关最大上限
|
|
|
|
this.bindGEvent( StartowerEvent.Update_All_Data, this.updateAllData.bind( this ) );
|
|
this.bindGEvent( StartowerEvent.Update_Top3_rank, this.updateTop3Info.bind( this ) );
|
|
this.bindGEvent( StartowerEvent.Update_First_Reward_Msg, this.updataRewardRedPoint.bind( this ) );
|
|
this.bindGEvent( StartowerEvent.Fight_Success_Event, this.FightSuccessInfo.bind( this ) );
|
|
this.bindGEvent( StartowerEvent.Count_Change_Event, this.CountChange.bind( this ) );
|
|
this.bindGEvent( StartowerEvent.Update_Jump_Floor, this.updateJumpFloor.bind( this ) );
|
|
//刷新本层奖励
|
|
this.bindGEvent( StartowerEvent.Update_Cur_Floor_Award, this.updateFloorAwards.bind( this ) );
|
|
this.bindGEvent( StartowerEvent.Show_Jump_Sp, this.showJumpEffect.bind(this));
|
|
|
|
|
|
},
|
|
|
|
showJumpEffect(){
|
|
this.jumpSp.node.active = false;
|
|
let res_path = PathTool.getSpinePath("E80050","action",false);
|
|
this.jumpSp.load( res_path, ( _e ) => {
|
|
this.jumpSp.node.active = true;
|
|
if( !_e ) {
|
|
this.jumpSp.action( "action", false, ( _key, _name ) => {
|
|
if(_key == "start"){
|
|
this.tower_list.node.runAction(cc.fadeOut(1));
|
|
}
|
|
|
|
if(_key == "change"){
|
|
this.tower_list.node.runAction(cc.fadeIn(0.1));
|
|
}
|
|
|
|
if( _key == "complete" ) {
|
|
this.jumpSp.stop();
|
|
return;
|
|
}
|
|
|
|
} );
|
|
} else {
|
|
this.tower_list.node.opacity = 255;
|
|
this.jumpSp.stop();
|
|
}
|
|
} );
|
|
},
|
|
|
|
updateJumpFloor( data ) {
|
|
this.from_floor = data.from_floor;
|
|
this.target_floor = data.target_floor;
|
|
},
|
|
|
|
updateFloorAwards( awards ){
|
|
let reward = awards || [];
|
|
this.curawards.rebuild(reward);
|
|
},
|
|
|
|
CountChange() {
|
|
this.refreshRankList();
|
|
this.updateTowerList();
|
|
this.FirstCmp.updateBoxAwards();
|
|
},
|
|
|
|
FightSuccessInfo() {
|
|
// if(!this.select_vo)return;
|
|
// this.refreshRankList();
|
|
this.updateTowerList();
|
|
this.FirstCmp.updateBoxAwards();
|
|
},
|
|
|
|
updateAllData() {
|
|
|
|
let need = game.configs.star_tower_data.data_tower_const.skip_floor_limit.val;
|
|
let needfloor = game.configs.star_tower_data.data_tower_const.skip_floor_need.val;
|
|
let maxfloor = game.configs.star_tower_data.data_tower_const.skip_floor_max_limit.val;
|
|
|
|
let max_tower = this.ctrl.getNowTowerId();
|
|
this.is_enough_jump = ( max_tower < maxfloor && max_tower >= needfloor );
|
|
let recommond = game.configs.star_tower_data.data_tower_base[ max_tower + need ].recommend;
|
|
nx.gui.setString( this, "main/right/powertip/txt", nx.text.getKey( "RankPowerArri" ) + recommond );
|
|
|
|
nx.gui.setActive( this.btn_jump,"",this.is_enough_jump );
|
|
nx.gui.setActive( this, "main/right/powertip",this.is_enough_jump );
|
|
this.updataRewardRedPoint();
|
|
},
|
|
|
|
updateTop3Info: function( rank_list ) {
|
|
if( rank_list == null ) return;
|
|
|
|
for( var i in rank_list ) {
|
|
if( !this.top3_item_list[ rank_list[ i ].rank ] ) {
|
|
var item = this.createSingleRankItem( rank_list[ i ].rank );
|
|
item.active = true;
|
|
this.rank_list.addChild( item );
|
|
this.top3_item_list[ rank_list[ i ].rank ] = item;
|
|
}
|
|
var item = this.top3_item_list[ rank_list[ i ].rank ];
|
|
if( item ) {
|
|
item.label.string = rank_list[ i ].name;
|
|
item.value.string = ( rank_list[ i ].tower || 0 ) + nx.text.getKey( "lab_star_tower_window_window_tip6" );
|
|
}
|
|
}
|
|
|
|
this.updateAllData();
|
|
},
|
|
|
|
onEditChange( edit ) {
|
|
this.jump_str = edit.string;
|
|
},
|
|
|
|
//指定通关跳转
|
|
onClickTargetJump() {
|
|
let cur_lev_id = this.ctrl.getNowTowerId();
|
|
|
|
let target = Number( this.jump_str );
|
|
if( target <= (cur_lev_id + 1) ) {
|
|
this.jumpTowerList( target );
|
|
} else {
|
|
return nx.tbox( "startower_jump_tip" );
|
|
}
|
|
},
|
|
|
|
//一键跳转
|
|
onClickOneJump() {
|
|
if( !this.from_floor || !this.target_floor ) {
|
|
return nx.tbox( "startower_power_jump" );
|
|
}
|
|
|
|
let cur_lev_id = this.ctrl.getNowTowerId();
|
|
if( cur_lev_id < game.configs.star_tower_data.data_tower_const.skip_floor_need ) {
|
|
return nx.tbox( "startower_ten_jump" );
|
|
}
|
|
|
|
this.ctrl.sender11335();
|
|
},
|
|
|
|
start() {
|
|
|
|
},
|
|
|
|
onOpenConfigs() {
|
|
|
|
//请求塔数据
|
|
this.ctrl.sender11320();
|
|
this.ctrl.sender11334();
|
|
this.refreshRankList();
|
|
|
|
// this.list_view.reloadData(lev_id);
|
|
this.updateTowerList();
|
|
},
|
|
|
|
refreshRankList() {
|
|
this.scheduleOnce(()=>{
|
|
this.ctrl.requestStarTowerRank();
|
|
},1);
|
|
},
|
|
|
|
onPreClosed() {
|
|
this.tower_list.rebuild( [] );
|
|
this.curawards.rebuild( [] );
|
|
},
|
|
|
|
//奖励红点
|
|
updataRewardRedPoint: function() {
|
|
|
|
},
|
|
|
|
createSingleRankItem: function( i ) {
|
|
var container = cc.instantiate( this.rank_item );
|
|
|
|
let sp = nx.gui.getComponent( container, "icon", cc.Sprite );
|
|
var res = cc.js.formatStr( "prefab/pve/startower/ui/rank_%s", i );
|
|
cc.loader.loadRes( res, cc.SpriteFrame, ( err, sf_obj ) => {
|
|
sp.spriteFrame = sf_obj;
|
|
} )
|
|
container.label = nx.gui.getComponent( container, "name", cc.Label );
|
|
container.value = nx.gui.getComponent( container, "tower", cc.Label );
|
|
return container;
|
|
},
|
|
|
|
jumpTowerList( target ) {
|
|
let tower_data_list = [];
|
|
for( let i = target - 1; i <= ( target + 1 ); i++ ) {
|
|
let data = game.configs.star_tower_data.data_tower_base[ i ];
|
|
if( i == ( target + 1 ) ) {//上层不需要数据
|
|
data = {};
|
|
}
|
|
|
|
if(!data){
|
|
data = {};
|
|
}
|
|
|
|
tower_data_list.push( data );
|
|
}
|
|
|
|
this.tower_list.tag_key = target;
|
|
this.tower_list.rebuild( tower_data_list );
|
|
},
|
|
|
|
updateTowerList: function() {
|
|
//需要处理最小值和最大值
|
|
let cur_lev_id = this.ctrl.getNowTowerId();
|
|
let tower_data_list = [];
|
|
if( !game.configs.star_tower_data.data_tower_base[ cur_lev_id ] ) {//起始位置
|
|
for( let i = 1; i <= 3; i++ ) {
|
|
let data = game.configs.star_tower_data.data_tower_base[ i ];
|
|
if( i == 3 ) {//上层不需要数据
|
|
data = {};
|
|
}
|
|
|
|
tower_data_list.push( data );
|
|
}
|
|
this.tower_list.tag_key = 1;
|
|
} else if( !game.configs.star_tower_data.data_tower_base[ cur_lev_id + 1 ] ) {//最终位置
|
|
//最大数量
|
|
this.max_count = game.configs.star_tower_data.data_tower_base_length;
|
|
for( let i = ( this.max_count + 1 ); i >= ( this.max_count - 2 ); i-- ) {
|
|
let data = game.configs.star_tower_data.data_tower_base[ i ];
|
|
if( i == ( this.max_count + 1 ) ) {//上层不需要数据
|
|
data = {};
|
|
}
|
|
|
|
tower_data_list.push( data );
|
|
}
|
|
this.tower_list.tag_key = cur_lev_id;
|
|
} else {
|
|
for( let i = cur_lev_id; i <= ( cur_lev_id + 2 ); i++ ) {
|
|
let data = game.configs.star_tower_data.data_tower_base[ i ];
|
|
if( i == ( cur_lev_id + 2 ) ) {//上层不需要数据
|
|
data = {};
|
|
}
|
|
|
|
tower_data_list.push( data );
|
|
}
|
|
this.tower_list.tag_key = cur_lev_id;
|
|
}
|
|
|
|
this.tower_list.rebuild( tower_data_list );
|
|
|
|
// 引导辅助
|
|
if( nx.bridge.plot && nx.bridge.plot.isDoing() ) {
|
|
this.scheduleOnce( () => {
|
|
this.positionPlotCells();
|
|
}, 0.5 );
|
|
}
|
|
},
|
|
|
|
// 规则说明
|
|
onTouchTip: function() {
|
|
|
|
let TC = TipsController.getInstance();
|
|
if( TC ) {
|
|
|
|
let txt = game.configs.star_tower_data.data_tower_const.rule_desc;
|
|
TC.showTextPanel( "tip", txt.desc );
|
|
}
|
|
},
|
|
|
|
onClickAward() {
|
|
this.ctrl.openAwardWindow( true );
|
|
},
|
|
|
|
onClickRank() {
|
|
nx.bridge.createPanel( "WndRank", { fromOther: RankConstant.RankType.tower } );
|
|
},
|
|
|
|
// ============================================
|
|
// 引导辅助
|
|
// ============================================
|
|
|
|
// 定位副本輔助热区
|
|
positionPlotCells: function() {
|
|
|
|
if( this.tower_list.tag_key != 1 ) return;
|
|
let children = this.tower_list.node.children;
|
|
let node = children[ 0 ];
|
|
|
|
if( !node ) {
|
|
nx.error( "$Dispatch:定位第一个派遣订单失败!" );
|
|
node = children[ 0 ];
|
|
if( !node ) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
let cell = nx.gui.find( this, "main/plotCell" );
|
|
let cmp = node.getComponent( "cmp.startower.item" );
|
|
let btn = nx.gui.find( node, "main/detail/btn_challenge" );
|
|
let pos = btn.convertToWorldSpaceAR( cc.Vec2.ZERO );
|
|
cell.position = cell.parent.convertToNodeSpaceAR( pos );
|
|
cell.width = btn.width;
|
|
cell.height = btn.height;
|
|
cell.svItem = cmp;
|
|
},
|
|
|
|
// 点击金币副本第一关挑战
|
|
onTouchFirstTower: function() {
|
|
|
|
let cell = nx.gui.find( this, "main/plotCell" );
|
|
if( cell && cell.svItem ) {
|
|
cell.svItem.clickFight();
|
|
}
|
|
},
|
|
} );
|