248 lines
9.0 KiB
JavaScript
248 lines
9.0 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '9bb473zQ9pK2qZMP0N4kxFJ', 'cmp.pvp.ladder.wnd');
|
||
|
|
// Scripts/mod/pvp/ladder/cmp/cmp.pvp.ladder.wnd.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var TipsController = require("tips_controller");
|
||
|
|
var ArenaEvent = require("arena_event");
|
||
|
|
var RoleController = require("role_controller");
|
||
|
|
var BattleEvent = require("battle_event");
|
||
|
|
var LadderEvent = require("ladder_event");
|
||
|
|
var MallConst = require("mall_const");
|
||
|
|
var BattleController = require("battle_controller");
|
||
|
|
var LadderController = require("ladder_controller");
|
||
|
|
var HeroController = require("hero_controller");
|
||
|
|
var 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 onLoad() {
|
||
|
|
// 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: function onOpenConfigs(_params) {
|
||
|
|
var LC = LadderController.getInstance();
|
||
|
|
var 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 freshInfo(_info) {
|
||
|
|
var _this = this;
|
||
|
|
this.myinfo = _info ? _info : this.myinfo;
|
||
|
|
var buy_cost = 0;
|
||
|
|
this.canbuyCount = 0;
|
||
|
|
var vip = RoleController.getInstance().getRoleVo().vip_lev;
|
||
|
|
var vip0 = 0;
|
||
|
|
var cfg = game.configs.sky_ladder_data.data_buy_num;
|
||
|
|
var need = game.configs.sky_ladder_data.data_const.arena_rank.val;
|
||
|
|
for (var i in cfg) {
|
||
|
|
var 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;
|
||
|
|
var 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), function () {
|
||
|
|
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 onPreClosed() {
|
||
|
|
|
||
|
|
// this.nodLst.rebuild( [] );
|
||
|
|
},
|
||
|
|
freshChallengeList: function freshChallengeList(_lst) {
|
||
|
|
var LC = LadderController.getInstance();
|
||
|
|
var LCM = LC.getModel();
|
||
|
|
this.clist = _lst ? _lst : LCM.getLadderEnemyListData();
|
||
|
|
;
|
||
|
|
var chd = this.nodLst.children;
|
||
|
|
for (var i = 0; i < chd.length; i++) {
|
||
|
|
var item = chd[i];
|
||
|
|
var data = {};
|
||
|
|
data = nx.dt.objClone(this.clist[i]);
|
||
|
|
var 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 onTouchRank() {
|
||
|
|
var rewards = [];
|
||
|
|
var rfg = game.configs.sky_ladder_data.data_award;
|
||
|
|
for (var i in rfg) {
|
||
|
|
var reward = rfg[i];
|
||
|
|
rewards.push(reward);
|
||
|
|
}
|
||
|
|
var LC = LadderController.getInstance();
|
||
|
|
nx.bridge.createPanel("WndArenaLoopCRankAward", {
|
||
|
|
ops: ["RankNow", "RankAwards"],
|
||
|
|
cb: function cb() {
|
||
|
|
LC.requestLadderRankData();
|
||
|
|
},
|
||
|
|
dfg: rewards,
|
||
|
|
show: "RankNow",
|
||
|
|
desc: nx.text.getKey("lab_ladder_award_window_tip3")
|
||
|
|
});
|
||
|
|
},
|
||
|
|
onTouchFresh: function onTouchFresh() {
|
||
|
|
var AC = ArenaController.getInstance();
|
||
|
|
AC.sender20206();
|
||
|
|
},
|
||
|
|
// 跳转竞技场积分商城
|
||
|
|
onTouchShop: function onTouchShop() {
|
||
|
|
nx.bridge.jumper.jump2Window(2, [MallConst.MallType.ScoreShop, MallConst.MallType.ArenaShop]);
|
||
|
|
},
|
||
|
|
openWarLog: function openWarLog() {
|
||
|
|
var LC = LadderController.getInstance();
|
||
|
|
LC.openLadderLogWindow(true);
|
||
|
|
},
|
||
|
|
// 点击 显示对应的对手数据
|
||
|
|
showFightNod: function showFightNod(_fightinfo) {
|
||
|
|
var LC = LadderController.getInstance();
|
||
|
|
LC.openLadderRoleInfoWindow(true, _fightinfo);
|
||
|
|
},
|
||
|
|
closeSelf: function closeSelf() {
|
||
|
|
this.close();
|
||
|
|
},
|
||
|
|
// 规则说明
|
||
|
|
onTouchTip: function onTouchTip() {
|
||
|
|
var TC = TipsController.getInstance();
|
||
|
|
if (TC) {
|
||
|
|
var txt = game.configs.sky_ladder_data.data_explain;
|
||
|
|
TC.showDetailPanel(txt);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
showResult: function showResult() {
|
||
|
|
nx.bridge.createPanel("WndArenaLoopCResult");
|
||
|
|
},
|
||
|
|
onTouchBuy: function onTouchBuy() {
|
||
|
|
var msg = nx.text.format("lab_star_tower_main_window_tip7", '3', this.buy_cost);
|
||
|
|
nx.mbox(msg, ['cancel', 'confirm'], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == 'confirm') {
|
||
|
|
var LC = LadderController.getInstance();
|
||
|
|
LC.requestBuyChallengeCount();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
//
|
||
|
|
onTouchQuick: function onTouchQuick() {
|
||
|
|
var LC = LadderController.getInstance();
|
||
|
|
LC.requestQuickChallenge();
|
||
|
|
},
|
||
|
|
// 點擊英雄殿
|
||
|
|
onTouchHerosHall: function onTouchHerosHall() {
|
||
|
|
var LC = LadderController.getInstance();
|
||
|
|
LC.openLadderTopThreeWindow(true);
|
||
|
|
},
|
||
|
|
// 點擊編隊
|
||
|
|
onTouchForm: function onTouchForm() {
|
||
|
|
var 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 positionWeakest() {
|
||
|
|
var node = null;
|
||
|
|
var 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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var cell = nx.gui.find(this, "plotWeakest");
|
||
|
|
var 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 onTouchWeakest() {
|
||
|
|
var cell = nx.gui.find(this, "plotWeakest");
|
||
|
|
var AC = ArenaController.getInstance();
|
||
|
|
AC.sender20203(cell.mdata.rid, cell.mdata.srv_id);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|