286 lines
8.3 KiB
JavaScript
286 lines
8.3 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '8d769Wp++5NQaPeTohqUfOs', 'campfight.mod');
|
|
// Scripts/mod/pvp/campfight/campfight.mod.js
|
|
|
|
"use strict";
|
|
|
|
// --------------------------------------------------------------------
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 陣營大戰(打年獸)
|
|
// <br/>Create: 2019-02-27 11:03:16
|
|
// --------------------------------------------------------------------
|
|
|
|
var BridgeController = require("bridge.controller");
|
|
var CampfightConst = require("campfight.const");
|
|
var BTC = require("battle_controller");
|
|
var CampfightMod = cc.Class({
|
|
"extends": BridgeController,
|
|
ctor: function ctor() {},
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
this.cur_peroid = 0;
|
|
this.cur_status = 0;
|
|
this.is_contest = false; //本人是否參賽
|
|
this.is_inPanel = false;
|
|
this.topthree = [];
|
|
this.first = true;
|
|
},
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(31300, this.handle31300); //擂臺賽信息
|
|
this.RegisterProtocal(31301, this.handle31301); //设置阵法
|
|
this.RegisterProtocal(31302, this.handle31302); //保存阵法
|
|
this.RegisterProtocal(31303, this.handle31303); //打年獸
|
|
this.RegisterProtocal(31305, this.handle31305); //往期排行榜
|
|
this.RegisterProtocal(31304, this.handle31304); //資格公示分組榜
|
|
this.RegisterProtocal(31306, this.handle31306); //戰鬥活動面板
|
|
this.RegisterProtocal(31307, this.handle31307); //pvp戰鬥
|
|
this.RegisterProtocal(31308, this.handle31308); //個人分組
|
|
this.RegisterProtocal(31309, this.handle31309); //pve结束阶段公示榜
|
|
this.RegisterProtocal(31310, this.handle31310); // 推送结算
|
|
this.RegisterProtocal(31311, this.handle31311); //录像列表
|
|
this.RegisterProtocal(31312, this.handle31312); //位次變動推送
|
|
this.RegisterProtocal(31313, this.handle31313); //设置防御阵法
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
// 配置加载
|
|
var cfgs = ["arena_camp_data"];
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
nx.dt.fnInvoke(_cb, true);
|
|
_this.reqOldRank();
|
|
});
|
|
},
|
|
setMainPanel: function setMainPanel(_is) {
|
|
this.is_inPanel = _is;
|
|
},
|
|
//當前界面是否在主界面
|
|
inMainPanel: function inMainPanel() {
|
|
return this.is_inPanel;
|
|
},
|
|
// 请求主要信息
|
|
reqMainData: function reqMainData(_cb) {
|
|
this.SendProtocal(31300, {}, _cb);
|
|
},
|
|
// 请求擂臺賽信息返回
|
|
handle31300: function handle31300(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
this.setCurPeriod(_data.period);
|
|
this.setActStatus(_data.status);
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_MAIN, _data);
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_STATUS_CHANGE, _data.status);
|
|
if (!this.inMainPanel()) {
|
|
if (_data.status == 1 || _data.status == 5) {
|
|
nx.bridge.createPanel("WndCampfightPush", {
|
|
status: _data.status
|
|
});
|
|
}
|
|
}
|
|
},
|
|
//设置阵法
|
|
sendForm: function sendForm(formation_type, group, posinfo, hallows_id, _cb) {
|
|
this.SendProtocal(31301, {
|
|
formation_type: formation_type,
|
|
group: group,
|
|
pos_info: posinfo,
|
|
hallows_id: hallows_id
|
|
}, _cb);
|
|
},
|
|
handle31301: function handle31301(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
if (_data.flag == 1) {
|
|
nx.tbox("CampFitFormSave");
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_UPDATE_BTN, "form");
|
|
}
|
|
},
|
|
//请求阵法
|
|
reqForm: function reqForm(formation_type, group, _cb) {
|
|
this.SendProtocal(31302, {
|
|
formation_type: formation_type,
|
|
group: group
|
|
}, _cb);
|
|
},
|
|
handle31302: function handle31302(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_UPDATE_FORM, _data);
|
|
},
|
|
reqBatBoss: function reqBatBoss(_cb) {
|
|
this.SendProtocal(31303, {}, _cb);
|
|
},
|
|
handle31303: function handle31303(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
},
|
|
reqZigeGroup: function reqZigeGroup(_group, _cb) {
|
|
this.SendProtocal(31304, {
|
|
group: _group
|
|
}, _cb);
|
|
},
|
|
handle31304: function handle31304(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_ZIGE_UI, _data);
|
|
},
|
|
reqOldRank: function reqOldRank(_cb) {
|
|
this.SendProtocal(31305, {}, _cb);
|
|
},
|
|
handle31305: function handle31305(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
var showdata = {
|
|
type: nx.text.getKey("CampFitTopThree"),
|
|
showCampList: _data.rank_list
|
|
};
|
|
if (nx.dt.arrNEmpty(_data.rank_list)) {
|
|
if (this.first) {
|
|
nx.bridge.vset("CampfightTop", showdata);
|
|
for (var i = 0; i < _data.rank_list.length; i++) {
|
|
var item = _data.rank_list[i];
|
|
if (item.rank < 4) {
|
|
this.topthree.push(item);
|
|
}
|
|
}
|
|
this.first = false;
|
|
}
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_UPDATE_RANK, _data);
|
|
},
|
|
reqBatGroup: function reqBatGroup(_group, _cb) {
|
|
this.SendProtocal(31306, {
|
|
group: _group
|
|
}, _cb);
|
|
},
|
|
handle31306: function handle31306(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_BATUI, _data);
|
|
},
|
|
reqBat: function reqBat(formation_type, group, posinfo, hallows_id, _rid, _srv_id, _cb) {
|
|
this.SendProtocal(31307, {
|
|
formation_type: formation_type,
|
|
group: group,
|
|
pos_info: posinfo,
|
|
hallows_id: hallows_id,
|
|
rid: _rid,
|
|
srv_id: _srv_id
|
|
}, _cb);
|
|
},
|
|
handle31307: function handle31307(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
},
|
|
reqSelfGroup: function reqSelfGroup(_cb) {
|
|
this.SendProtocal(31308, {}, _cb);
|
|
},
|
|
// 请求擂臺賽信息返回
|
|
handle31308: function handle31308(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
if (_data.rank == 0) {
|
|
this.is_contest = false;
|
|
this.setGroup(1); //默認第一組
|
|
} else {
|
|
this.is_contest = true;
|
|
this.setGroup(_data.group);
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_UPSEAT, this.group);
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_SETRANK, _data.rank);
|
|
},
|
|
reqMonsDmgRank: function reqMonsDmgRank(_cb) {
|
|
this.SendProtocal(31309, {}, _cb);
|
|
},
|
|
handle31309: function handle31309(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_MONS_UI, _data);
|
|
},
|
|
handle31310: function handle31310(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
nx.bridge.vset("ResultInfo", _data);
|
|
},
|
|
reqReportList: function reqReportList(_group, _cb) {
|
|
this.SendProtocal(31311, {
|
|
group: _group
|
|
}, _cb);
|
|
},
|
|
handle31311: function handle31311(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(CampfightConst.EVT_CAMP_REPORT, _data);
|
|
},
|
|
handle31312: function handle31312(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
nx.bridge.createPanel("WndCampfightPlace", {
|
|
data: _data
|
|
});
|
|
},
|
|
//设置防御阵法
|
|
setDefendForm: function setDefendForm(formation_type, group, pos_info, hallows_id, _cb) {
|
|
this.SendProtocal(31313, {
|
|
formation_type: formation_type,
|
|
group: group,
|
|
pos_info: pos_info,
|
|
hallows_id: hallows_id
|
|
}, _cb);
|
|
},
|
|
handle31313: function handle31313(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
},
|
|
//配置
|
|
//當前活動周期
|
|
setCurPeriod: function setCurPeriod(period) {
|
|
this.cur_peroid = period;
|
|
},
|
|
getCurPeriod: function getCurPeriod() {
|
|
return this.cur_peroid;
|
|
},
|
|
//當前分組
|
|
setGroup: function setGroup(group) {
|
|
this.group = group;
|
|
},
|
|
getGroup: function getGroup() {
|
|
return this.group;
|
|
},
|
|
//活動階段
|
|
setActStatus: function setActStatus(status) {
|
|
this.cur_status = status;
|
|
},
|
|
getActStatus: function getActStatus() {
|
|
return this.cur_status;
|
|
},
|
|
isContest: function isContest() {
|
|
return this.is_contest;
|
|
},
|
|
setReqGroup: function setReqGroup(group) {
|
|
this.reqing_group = group;
|
|
},
|
|
getReqGroup: function getReqGroup() {
|
|
return this.reqing_group || 1;
|
|
}
|
|
});
|
|
module.exports = CampfightMod;
|
|
|
|
cc._RF.pop(); |