// -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 跨服时空,zys //
Create: 2019-07-29 10:38:42 // -------------------------------------------------------------------- const BridgeController = require( "bridge.controller" ); var RoleEvent = require("role_event"); var ElitematchEvent = require("elitematch_event"); var RoleController = require("role_controller") var PartnerConst = require("partner_const") var HeroController = require("hero_controller"); var BattleController = require( "battle_controller" ); var BattleConst = require( "battle_const" ); var PVPRank = cc.Class({ extends: BridgeController, ctor: function () { }, // 初始化配置数据 initConfig: function () { var ElitematchModel = require("elitematch_model"); this.model = new ElitematchModel(); this.model.initConfig(); }, // 返回当前的model getModel: function () { return this.model; }, // 注册监听事件 registerEvents: function () { }, // 注册协议接受事件 registerProtocals: function () { this.RegisterProtocal(24900, this.handle24900) //請求精英賽基礎信息 this.RegisterProtocal(24901, this.handle24901) //請求對手信息 this.RegisterProtocal(24902, this.handle24902) //請求匹配對手 this.RegisterProtocal(24903, this.handle24903) //挑戰對手 this.RegisterProtocal(24904, this.handle24904) //購買挑戰次數 this.RegisterProtocal(24905, this.handle24905) //"請求精英賽是否開戰" this.RegisterProtocal(24906, this.handle24906) //戰鬥結算 this.RegisterProtocal(24910, this.handle24910) //歷史賽季賽區信息 this.RegisterProtocal(24911, this.handle24911) //歷史賽季 this.RegisterProtocal(24915, this.handle24915) //領取獎勵 //陣法 this.RegisterProtocal(24920, this.handle24920) //請求精英賽功能陣法 this.RegisterProtocal(24921, this.handle24921) //設置精英賽功能陣法 this.RegisterProtocal(24930, this.handle24930) //獲取個人日誌 this.RegisterProtocal(24931, this.handle24931) //獲取個人詳情 this.RegisterProtocal(24940, this.handle24940) //獲取個人記錄信息 this.RegisterProtocal(24941, this.handle24941) //分享 this.RegisterProtocal(24942, this.handle24942) //分享 this.RegisterProtocal(24945, this.handle24945) //精英賽宣言 this.RegisterProtocal(24946, this.handle24946) //保存精英賽宣言 this.RegisterProtocal(24950, this.handle24950) //顯示精英賽宣言結束 this.RegisterProtocal(24952, this.handle24952) //段位賽戰令基本信息 this.RegisterProtocal(24953, this.handle24953) //段位賽戰令一鍵領取等級禮包 this.RegisterProtocal(24954, this.handle24954) //段位賽戰令紅點 this.RegisterProtocal(24955, this.handle24955) //段位賽活動提示 this.RegisterProtocal(24960, this.handle24960) //段位賽活動提示 this.RegisterProtocal(24961, this.getTaskAwardBack) //段位賽活動提示 }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { // 配置加载 let cfgs = [ "arena_elite_data", "arena_elite_war_order_data", // 段位赛通行证 ]; this.cfgs = cfgs; this.loadConfigs( cfgs, ( _ret, _data ) => { this.reqOrderData( _cb ); this.sender24900(); this.reqTaskStatus(); } ); }, reqOrderData: function( _cb ) { this.SendProtocal(24952, {},_cb) }, //精英赛基础信息 sender24900:function(){ this.SendProtocal(24900,{}); }, handle24900:function(data){ nx.mTip.openTip( "pvp.pvprank.challenge", data.day_combat_count > 0 ); nx.bridge.vset( "rankMatch", data ); this.model.setSCData(data) gcore.GlobalEvent.fire(ElitematchEvent.Get_Elite_Main_Info_Event, data) if (this.is_check_redpoint) { this.sender24920(1) this.sender24920(2) //王者賽需要弄多一個陣法類型 this.is_check_redpoint = false } this.model.setSCDataBack24900() }, //精英赛基础信息 reqTaskStatus:function(){ this.SendProtocal(24960,{}); }, handle24960: function( _data ){ let count = 0; if( _data && nx.dt.arrNEmpty( _data.list ) ){ _data.list.forEach( _info =>{ if( _info.award_status == 2 ){ _info.getstatus = _data.list.length + 3; }else if( _info.award_status == 1 ){ _info.getstatus = 1; count++; }else{ _info.getstatus = _info.id + 3; } } ) } nx.mTip.openTip( "pvp.pvprank.task", count > 0 ); nx.bridge.vset( "PvpRankTask", _data ); }, //精英赛基础信息 reqGetTaskAward:function(){ this.SendProtocal(24961,{}); }, //精英赛基础信息 getTaskAwardBack:function( _data ){ if( nx.dt.strNEmpty( _data.msg ) ){ nx.tbox( _data.msg ); } }, getCfg: function(){ return this.cfgs; }, // 請求对手信息 sender24901( ){ this.SendProtocal(24901, {}) }, handle24901( data ){ gcore.GlobalEvent.fire(ElitematchEvent.Get_Elite_Enemy_Info_Event, data); nx.bridge.vset( "rankMatching", data ); }, dealUI:function( _lev ){ let path = ""; if( _lev == 1 ) { path = "prefab/pvp/rank/ui/png_rank_1" ; }else if( _lev >= 2 && _lev <= 3 ){ path = "prefab/pvp/rank/ui/png_rank_2" ; }else if( _lev >= 4 && _lev <= 6 ){ path = "prefab/pvp/rank/ui/png_rank_3" ; }else if( _lev >= 7 && _lev <= 9 ){ path = "prefab/pvp/rank/ui/png_rank_4" ; }else if( _lev >= 10 && _lev <= 13 ){ path = "prefab/pvp/rank/ui/png_rank_5" ; }else if( _lev >= 14 && _lev <= 17 ){ path = "prefab/pvp/rank/ui/png_rank_6" ; }else{ path = "prefab/pvp/rank/ui/png_rank_7" ; } return path; }, // --請求匹配對手 sender24902(is_skip){ let protocal = {} protocal.type = is_skip this.SendProtocal(24902, protocal); let dataa = { rand_list : [], is_match : 1, } nx.bridge.vset( "rankMatching", dataa ); }, handle24902(data){ }, // --挑戰對手 sender24903(){ let protocal = {} this.SendProtocal(24903, protocal) }, handle24903(data){ if (data.code == 1) { }else{ nx.tbox(data.msg) gcore.GlobalEvent.fire(ElitematchEvent.Elite_Fight_Fail_Event) } }, // --購買次數 sender24904(){ let protocal = {} this.SendProtocal(24904, protocal) }, handle24904(data){ if (data.code == 1 ){ gcore.GlobalEvent.fire(ElitematchEvent.Elite_buy_count_Event, data) }else{ nx.tbox(data.msg) } }, // --開戰時間 sender24905(){ let protocal = {} this.SendProtocal(24905, protocal) }, handle24905(data){ this.model.setEliteMatchFightTime(data) gcore.GlobalEvent.fire(ElitematchEvent.Elite_Start_Time_Event, data) this.model.setSCDataBack24905() }, // --戰鬥結算 handle24906(data){ this.new_result_data = data; data.award_list = []; let info = nx.bridge.vget( "rankMatch" ); if( info && data ){ info.lev = data.new_elite_lev; info.score = data.end_score; } let awarddss = []; for (let r = 0; r < data.awards.length; r++) { let award = data.awards[r]; let showa = { bid : award.item_id, num : award.item_num, id : 0 } awarddss.push( showa ); } data.award_list = awarddss; nx.bridge.vset( "rankMatch", info ); nx.bridge.vset( "ResultInfo", data ); // BattleController.getInstance().openFinishView( true, BattleConst.Fight_Type.EliteMatchWar, this.new_result_data ); // nx.bridge.createPanel( "WndWinSettle" ); return; }, reqGetDailyTaskReward: function(){ }, newResultWin: function(){ if(!this.new_result_data)return; let data = this.new_result_data; gcore.GlobalEvent.fire(ElitematchEvent.Elite_Fight_Result_Event) if( this.timer_id) { gcore.Timer.del(this.timer_id) this.timer_id = null } this.scdata24906 = data this.openElitematchFightResultPanel(false) this.timer_id = gcore.Timer.set(()=>{ if (this.timer_id) { gcore.Timer.del(this.timer_id) this.timer_id = null } if (this.scdata24906 ){ this.openElitematchFightResultPanel(true, this.scdata24906) } }, 1000, 1) this.new_result_data = null; }, //歷史賽季賽區信息 sender24910(){ let protocal = {} this.SendProtocal(24910, protocal) }, handle24910(data){ // -- if data.code == TRUE { gcore.GlobalEvent.fire(ElitematchEvent.Elite_History_Zone_Event, data) // -- else // -- message(data.msg) // -- end }, // --歷史賽季 sender24911(match_index, start_index, end_index, zone_id){ let protocal = {} protocal.period = match_index protocal.start_rank = start_index protocal.end_rank = end_index protocal.zone_id = zone_id this.SendProtocal(24911, protocal) }, handle24911(data){ // -- if data.code == TRUE { gcore.GlobalEvent.fire(ElitematchEvent.Elite_History_Record_Event, data) // -- else // -- message(data.msg) // -- end }, // --領取段位獎勵 sender24915(lev){ let protocal = {} protocal.lev = lev this.SendProtocal(24915, protocal) }, handle24915(data){ if (data.code == 1) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_Receive_Reward_Event, data) }else{ nx.tbox(data.msg) } }, // --請求陣法 sender24920(type){ let protocal = {} protocal.type = type this.SendProtocal(24920, protocal) }, handle24920(data){ gcore.GlobalEvent.fire(ElitematchEvent.Update_Elite_Fun_Form, data) gcore.GlobalEvent.fire(ElitematchEvent.Update_Elite_Fun_Form2, data) let _type = null if (data.type == 1) { _type = PartnerConst.Fun_Form.EliteMatch }else{ _type = PartnerConst.Fun_Form.EliteKingMatch } let model = HeroController.getInstance().getModel() for (let i in data.formations) { let v = data.formations[i] v.type = _type model.setFormList(v, v.order) } }, sender24921(type, formations ){ let protocal = {} protocal.type = type protocal.formations = formations this.SendProtocal(24921, protocal) }, handle24921(data){ if (data.code == 1) { gcore.GlobalEvent.fire(ElitematchEvent.Update_Elite_Save_Form, data) this.sender24920(1) this.sender24920(2) }else{ nx.tbox(data.msg) } }, sender24930(type){ let protocal = {} protocal.type = type this.SendProtocal(24930, protocal) }, handle24930(data){ gcore.GlobalEvent.fire(ElitematchEvent.Elite_Challenge_Record_Event, data) }, sender24931(type, id){ let protocal = {} protocal.type = type protocal.id = id this.SendProtocal(24931, protocal) }, handle24931(data){ gcore.GlobalEvent.fire(ElitematchEvent.Elite_Challenge_Record_Info_Event, data) }, sender24940(period){ let protocal = {} protocal.period = period this.SendProtocal(24940, protocal) }, handle24940(data){ gcore.GlobalEvent.fire(ElitematchEvent.Elite_Personal_Info_Event, data) }, sender24941(channel){ let protocal = {} protocal.channel = channel this.SendProtocal(24941, protocal) }, handle24941(data){ nx.tbox(data.msg) }, sender24942(id, share_srv_id, period){ let protocal = {} protocal.id = id protocal.share_srv_id = share_srv_id protocal.period = period this.SendProtocal(24942, protocal) }, handle24942(data){ gcore.GlobalEvent.fire(ElitematchEvent.Elite_Personal_Info_Event2, data) }, // --打開宣言 sender24945(){ let protocal = {} this.SendProtocal(24945, protocal) }, handle24945(data){ gcore.GlobalEvent.fire(ElitematchEvent.Elite_Declaration_Event, data) }, // --保存宣言設置 sender24946(manifesto){ let protocal = {} protocal.manifesto = manifesto this.SendProtocal(24946, protocal) }, handle24946(data){ nx.tbox(data.msg) }, // --show宣言結束 sender24950(){ let protocal = {} this.SendProtocal(24950, protocal) }, handle24950(data){ nx.tbox(data.msg) }, // ---------------------------@ 打開界面 // --打開精英大賽主界面 openElitematchMainWindow( status, setting ){ if (status) { // -- 判斷精英大賽是否開啟 if (!this.model.checkElitematchIsOpen().is_open ){ return } if (this.elitematch_main_window == null ){ let ElitematchMainWindow = require("elitematch_main_window") this.elitematch_main_window = new ElitematchMainWindow() } if (this.elitematch_main_window) { this.elitematch_main_window.open(setting) } }else{ if (this.elitematch_main_window) { this.elitematch_main_window.close() this.elitematch_main_window = null } } }, // --打開精英大賽匹配界面 openElitematchMatchingWindow(status, match_type, scdata){ if (status) { if (this.elitematch_matching_window == null) { let ElitematchMatchingWindow = require("elitematch_matching_window") this.elitematch_matching_window = new ElitematchMatchingWindow() } if (this.elitematch_matching_window) { this.elitematch_matching_window.open(match_type, scdata) } }else{ if( this.elitematch_matching_window) { this.elitematch_matching_window.close() this.elitematch_matching_window = null } } }, // --打開精英大賽戰鬥結果界面 openElitematchFightResultPanel(status, data){ if (status) { if (this.elitematch_fight_result_panel == null) { let ElitematchFightResultPanel = require("elitematch_fight_result_panel") this.elitematch_fight_result_panel = new ElitematchFightResultPanel() } if (this.elitematch_fight_result_panel.isOpen && this.elitematch_fight_result_panel) { this.elitematch_fight_result_panel.open(data) } }else{ if (this.elitematch_fight_result_panel) { this.elitematch_fight_result_panel.close() this.elitematch_fight_result_panel = null } } }, // --打開獎勵界面 openElitematchRewardPanel(status, index, level_id, rank){ if (status) { if (this.elitematch_reward_panel == null ){ let ElitematchRewardPanel = require("elitematch_reward_panel") this.elitematch_reward_panel = new ElitematchRewardPanel() } if (this.elitematch_reward_panel) { this.elitematch_reward_panel.open(index, level_id, rank) } }else{ if (this.elitematch_reward_panel) { this.elitematch_reward_panel.close() this.elitematch_reward_panel = null } } }, // --打開戰鬥記錄 openElitematchFightRecordPanel(status, index, level_id){ if (status) { if (this.elitematch_fight_record_panel == null) { let ElitematchFightRecordPanel = require("elitematch_fight_record_panel") this.elitematch_fight_record_panel = new ElitematchFightRecordPanel() } if (this.elitematch_fight_record_panel) { this.elitematch_fight_record_panel.open(index, level_id) } }else{ if (this.elitematch_fight_record_panel) { this.elitematch_fight_record_panel.close() this.elitematch_fight_record_panel = null } } }, // --打開錄像 openElitematchFightVedioPanel(status, index, level_id, _type, setting){ if (status) { if (this.elitematch_fight_vedio_panel == null) { let ElitematchFightVedioPanel = require("elitematch_fight_vedio_panel") this.elitematch_fight_vedio_panel = new ElitematchFightVedioPanel() } if (this.elitematch_fight_vedio_panel) { let ojb = {}; ojb.data = index; ojb.index = level_id; ojb._type = _type; ojb.setting = setting; this.elitematch_fight_vedio_panel.open(ojb) } }else{ if (this.elitematch_fight_vedio_panel) { this.elitematch_fight_vedio_panel.close() this.elitematch_fight_vedio_panel = null } } }, // --打開歷史賽季 openElitematchHistoryRecordWindow(status, index, max_period, zone_id){ if (status) { if (this.elitematch_history_record_window == null) { let ElitematchHistoryRecordWindow = require("elitematch_history_record_window") this.elitematch_history_record_window = new ElitematchHistoryRecordWindow() } if (this.elitematch_history_record_window) { this.elitematch_history_record_window.open(index, max_period, zone_id) } }else{ if (this.elitematch_history_record_window) { this.elitematch_history_record_window.close() this.elitematch_history_record_window = null } } }, // --個人戰績記錄 openElitematchPersonalInfoPanel(status, period,data){ if (status) { if( this.elitematch_personal_info_panel == null) { let ElitematchPersonalInfoPanel = require("elitematch_personal_info_panel") this.elitematch_personal_info_panel = new ElitematchPersonalInfoPanel() } if (this.elitematch_personal_info_panel) { this.elitematch_personal_info_panel.open(period, data) } }else{ if (this.elitematch_personal_info_panel) { this.elitematch_personal_info_panel.close() this.elitematch_personal_info_panel = null } } }, // --宣言設置 openElitematchDeclarationPanel(status,msgType){ // if status == true { // if this.elitematch_declaration_panel == null { // this.elitematch_declaration_panel = ElitematchDeclarationPanel.New(msgType) // end // if this.elitematch_declaration_panel:isOpen() == false { // this.elitematch_declaration_panel:open() // end // else // if this.elitematch_declaration_panel { // this.elitematch_declaration_panel:close() // this.elitematch_declaration_panel = null // end // end }, // --宣言設置 openChooseFacePanel(status, index, id, world_pos, msg_type){ if (status) { if (this.choose_face_panel == null) { let ChooseFacePanel = require("choose_face_panel") this.choose_face_panel = new ChooseFacePanel() } if (this.choose_face_panel) { this.choose_face_panel.open(index, id, world_pos, msg_type) } }else{ if (this.choose_face_panel) { this.choose_face_panel.close() this.choose_face_panel = null } } }, // --宣言設置 openElitematchZoneListPanel(status, max_zone, callback){ if (status) { if (this.elitematch_zone_list_panel == null) { let ElitematchZoneListPanel = require("elitematch_zone_list_panel") this.elitematch_zone_list_panel = new ElitematchZoneListPanel() } if (this.elitematch_zone_list_panel) { this.elitematch_zone_list_panel.open(max_zone, callback) } else if (this.elitematch_zone_list_panel) { this.elitematch_zone_list_panel.close() this.elitematch_zone_list_panel = null } } }, // -----------------------------------------段位賽戰令活動--------------------------------------------- // -- 戰令基本信息 sender24952(){ let protocal = {} this.SendProtocal(24952, protocal) }, /*** * {"period":2,"cur_day":2,"end_time":1714665600,"lev":2,"rmb_status":0,"win_count":6,"list":[]} */ handle24952(data){ this.model.setOrderactionData(data); if( nx.dt.arrEmpty( data.list ) ){ let cfg = game.configs.arena_elite_war_order_data.data_lev_reward_list[data.period ]; for (let c in cfg ) { let item = cfg[c]; if( data.win_count >= item.win_count ){ let newd = { "id":item.lev, "award_status":0, "rmb_award_status":0 } data.list.push( newd ); } } } nx.bridge.vset( "rankOrder", data ); this.model.setSCDataBackOrderaction() gcore.GlobalEvent.fire(ElitematchEvent.Elite_OrderAction_Init_Event, data) }, // --一鍵領取禮包 sender24953(id){ let protocal = {} protocal.id = id this.SendProtocal(24953, protocal) }, handle24953(data){ if (data) { nx.tbox(data.msg) } }, // --紅點 sender24954(){ let protocal = {} this.SendProtocal(24954, protocal) }, handle24954(data){ if (data) { this.model.setOrderactionRedStatus(data.flag) this.model.setSCDataBackOrderaction() } gcore.GlobalEvent.fire(ElitematchEvent.Elite_OrderAction_First_Red_Event) }, // --段位賽活動提示 sender24955(){ let protocal = {} this.SendProtocal(24955, protocal) }, handle24955(data){ gcore.GlobalEvent.fire(ElitematchEvent.Elite_OrderAction_IsPopWarn_Event,data) }, // --打開主界面 openElitematchOrderactionWindow(status){ if (status) { // -- 判斷精英大賽是否開啟 if (!this.model.checkElitematchIsOpen().is_open) { return } if( !this.elitematch_orderaction_window ){ let ElitematchOrderactionWindow = require("elitematch_orderaction_window") this.elitematch_orderaction_window = new ElitematchOrderactionWindow() } this.elitematch_orderaction_window.open() }else{ if (this.elitematch_orderaction_window) { this.elitematch_orderaction_window.close() this.elitematch_orderaction_window = null } } }, // --購買進階卡 openBuyCardView(status){ if (status) { if( !this.buy_card_view ){ let ElitematchOrderactionUntieRewardWindow = require("elitematch_orderaction_untie_reward_window") this.buy_card_view = new ElitematchOrderactionUntieRewardWindow() } this.buy_card_view.open() }else{ if (this.buy_card_view) { this.buy_card_view.close() this.buy_card_view = null } } }, // --打開活動結束警告界面 openElitematchEndWarnView(status,day){ if (status) { if( !this.end_warn_view) { let ElitematchOrderActionEndWarnWindow=require("elitematch_orderaction_end_warn_window") this.end_warn_view = new ElitematchOrderActionEndWarnWindow() } this.end_warn_view.open(day) }else{ if (this.end_warn_view) { this.end_warn_view.close() this.end_warn_view = null } } }, }); module.exports = PVPRank;