Files
fc/dev/project/assets/Scripts/mod/pvp/ladder/cmp/cmp.pvp.ladder.wnd.js
T

296 lines
9.6 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const BridgeWindow = require( "bridge.window" );
const TipsController = require( "tips_controller" );
const ArenaEvent = require( "arena_event" );
const RoleController = require( "role_controller" );
const BattleEvent = require( "battle_event" );
const LadderEvent = require( "ladder_event" );
const MallConst = require( "mall_const" );
const BattleController = require( "battle_controller" );
const LadderController = require( "ladder_controller" );
const HeroController = require("hero_controller");
const HeroConst = require( "hero_const" );
cc.Class( {
extends: BridgeWindow,
properties: {
nodTop: { default: null, type: cc.Node, displayName:"自己排名相关" },
nodLst: { default: null, type: cc.Node, displayName:"挑战列表" },
nodBtm: { default: null, type: cc.Node, displayName:"结束时间" },
},
onLoad: function() {
// this.unscheduleAllCallbacks();
this.bindGEvent( BattleEvent.DISPENSE_TYPE_RESLUT, this.showResult.bind( this ) );
this.bindGEvent( LadderEvent.GetLadderEnemyData, this.showFightNod.bind( this ) );
this.bindGEvent( LadderEvent.UpdateLadderMyBaseInfo, this.freshInfo.bind( this ) );
this.bindGEvent( LadderEvent.UpdateAllLadderEnemyList, this.freshChallengeList.bind( this ) );
// this.bindGEvent( ArenaEvent.UpdateArena_Number, this.updateRankListInfo.bind(this));
},
onOpenConfigs( _params ) {
let LC = LadderController.getInstance();
let LCM = LC.getModel();
this.myinfo = LCM.getLadderMyBaseInfo();
if( nx.dt.objEmpty( this.myinfo ) ){
LC.requestLadderMyBaseInfo();
}
this.clist = LCM.getLadderEnemyListData();
LC.requestLadderEnemyListData();
/**[{"rid":974,"srv_id":"robot","idx":5,"name":"夜蕾依珊","lev":57,"sex":1,"face":30502,"power":104180,"rank":974,"look":150501,"face_update_time":0,"face_file":""},{"rid":943,"srv_id":"robot","idx":4,"name":"恨山紫藍","lev":57,"sex":1,"face":10303,"power":103312,"rank":943,"look":110506,"face_update_time":0,"face_file":""},{"rid":937,"srv_id":"robot","idx":3,"name":"念薇凡梅","lev":61,"sex":0,"face":20304,"power":103610,"rank":937,"look":150502,"face_update_time":0,"face_file":""},{"rid":900,"srv_id":"robot","idx":2,"name":"恨天紫安","lev":55,"sex":0,"face":20504,"power":104180,"rank":900,"look":130402,"face_update_time":0,"face_file":""},{"rid":866,"srv_id":"robot","idx":1,"name":"盼山元風","lev":64,"sex":1,"face":40503,"power":103610,"rank":866,"look":130405,"face_update_time":0,"face_file":""}]
* 排名信息--->>>
* {"rank":0,"best_rank":0,"can_combat_num":10,"buy_combat_num":0,"ref_time":0,"combat_time":1691334000}**/
this.freshInfo();
this.freshChallengeList();
if( nx.storage.get( "battleArena" ) ){
if( !nx.bridge.getBridgeWindow( "WndArenaLoopCResult" ) ){
nx.bridge.createPanel( "WndArenaLoopCResult" );
}
}
},
freshInfo : function( _info ){
this.myinfo = _info ? _info : this.myinfo;
let buy_cost = 0;
this.canbuyCount = 0;
let vip = RoleController.getInstance().getRoleVo().vip_lev;
let vip0 = 0;
let cfg = game.configs.sky_ladder_data.data_buy_num;
let need = game.configs.sky_ladder_data.data_const.arena_rank.val;
for (let i in cfg ) {
let dat = cfg[i];
if( vip >= dat.vip ){
this.canbuyCount++;
}
if( ( i - 1 ) == this.myinfo.buy_combat_num ){
buy_cost = dat.cost;
}
}
this.buy_cost = buy_cost;
let rankinfo = this.myinfo.rank > 0 ? this.myinfo.rank : nx.text.getKey( "RankEmpty" );
nx.gui.setString( this.nodTop, "rank/txt", rankinfo ); // 自己当前排名信息
nx.gui.setString( this.nodTop, "cond/need", need ); // 自己当前排名信息
nx.gui.setString( this.nodBtm, "ctimes/times", this.myinfo.can_combat_num ); // 可使用次数
nx.gui.setString( this.nodBtm, "remain/times", parseInt( this.canbuyCount - this.myinfo.buy_combat_num ) ); // 可使用次数
// nx.gui.setString( this.nodBtm, "etime/time", nx.bridge.time.toLocalString( this.myinfo.combat_time ) );
nx.gui.setCdTxt( this.nodBtm, "etime/time", ( this.myinfo.combat_time - Math.floor( cc.sys.now() / 1000 ) ), ()=>{
nx.gui.setActive( this.nodBtm, "etime", false );
} );
nx.gui.setActive( this.nodBtm, "etime", this.clist[0] && this.clist[0].rank != 0 );
nx.gui.setActive( this.nodBtm, "op/on", this.clist[0] && this.clist[0].rank != 0 );
nx.gui.setActive( this.nodBtm, "op/off", this.clist[0] && this.clist[0].rank == 0 );
},
// 重载:关闭前
onPreClosed: function() {
// this.nodLst.rebuild( [] );
},
freshChallengeList: function( _lst ) {
let LC = LadderController.getInstance();
let LCM = LC.getModel();
this.clist = _lst ? _lst : LCM.getLadderEnemyListData();;
let chd = this.nodLst.children;
for( let i = 0; i < chd.length; i++ ) {
let item = chd[ i ];
let data = {};
data = nx.dt.objClone( this.clist[ i ] );
let cmp = item.getComponent( "nx.fx.sv.expand.item" );
if( cmp ) {
cmp.rebind( i, data );
}
}
// // 引导辅助
// if( nx.bridge.plot && nx.bridge.plot.isDoing() ) {
// this.positionWeakest();
// }
},
onTouchRank: function() {
let rewards = [];
let rfg = game.configs.sky_ladder_data.data_award;
for (let i in rfg ) {
let reward = rfg[i];
rewards.push( reward );
}
let LC = LadderController.getInstance();
nx.bridge.createPanel( "WndArenaLoopCRankAward", {
ops: [ "RankNow", "RankAwards" ],
cb: () => {
LC.requestLadderRankData();
},
dfg: rewards,
show: "RankNow",
desc : nx.text.getKey( "lab_ladder_award_window_tip3" ),
} );
},
onTouchFresh: function() {
let AC = ArenaController.getInstance();
AC.sender20206();
},
// 跳转竞技场积分商城
onTouchShop: function() {
nx.bridge.jumper.jump2Window( 2, [ MallConst.MallType.ScoreShop, MallConst.MallType.ArenaShop ] );
},
openWarLog: function() {
let LC = LadderController.getInstance();
LC.openLadderLogWindow( true );
},
// 点击 显示对应的对手数据
showFightNod : function( _fightinfo ){
let LC = LadderController.getInstance();
LC.openLadderRoleInfoWindow( true, _fightinfo );
},
closeSelf: function() {
this.close();
},
// 规则说明
onTouchTip: function() {
let TC = TipsController.getInstance();
if( TC ) {
let txt = game.configs.sky_ladder_data.data_explain;
TC.showDetailPanel( txt );
}
},
showResult: function() {
nx.bridge.createPanel( "WndArenaLoopCResult" );
},
onTouchBuy: function() {
let msg = nx.text.format( "lab_star_tower_main_window_tip7", '3', this.buy_cost );
nx.mbox( msg, [ 'cancel', 'confirm' ], ( _key, _box ) => {
_box.close();
if( _key == 'confirm' ) {
const LC = LadderController.getInstance();
LC.requestBuyChallengeCount();
}
} );
},
//
onTouchQuick: function(){
let LC = LadderController.getInstance();
LC.requestQuickChallenge();
},
// 點擊英雄殿
onTouchHerosHall: function(){
let LC = LadderController.getInstance();
LC.openLadderTopThreeWindow( true );
},
// 點擊編隊
onTouchForm: function(){
let heros = HeroController.getInstance().getModel().getAllHeroArray();
HeroController.getInstance().openFormGoFightPanel( true, 45, {need_hide_top : true}, HeroConst.FormShowType.eFormSave );
// let LC = LadderController.getInstance();
// LC.openLadderTopThreeWindow( true );
},
// ============================================
// 引导辅助
// ============================================
// 定位最弱的一个
positionWeakest: function() {
let node = null;
let chd = nx.gui.find( this.nodLst, "" ).children;
node = chd[ 0 ];
// 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.mdata.bid == 20401 ) {
// node = temp;
// break;
// }
// }
if( !node ) {
nx.error( "$ParterPage:定位特定英雄失败!" );
node = chd[ 0 ];
if( !node ) {
return;
}
}
let cell = nx.gui.find( this, "plotWeakest" );
let pos = node.convertToWorldSpaceAR( cc.Vec2.ZERO );
cell.position = cell.parent.convertToNodeSpaceAR( pos );
cell.width = node.width;
cell.height = node.height;
cell.mdata = node.getComponent( "nx.fx.sv.expand.item" ).mdata;
},
// 点击挑战最弱
onTouchWeakest: function() {
let cell = nx.gui.find( this, "plotWeakest" );
let AC = ArenaController.getInstance();
AC.sender20203( cell.mdata.rid, cell.mdata.srv_id );
},
} );