327 lines
11 KiB
JavaScript
327 lines
11 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'b7c6bk9cudNq7xr3s77FCOb', 'guildboss_controller');
|
||
|
|
// Scripts/mod/guild/boss/guildboss_controller.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
// --------------------------------------------------------------------
|
||
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
||
|
|
// @description:
|
||
|
|
// 这里填写详细说明,主要填写该模块的功能简要
|
||
|
|
// <br/>Create: 2019-01-24 17:44:54
|
||
|
|
// --------------------------------------------------------------------
|
||
|
|
var BridgeController = require("bridge.controller");
|
||
|
|
var RoleController = require("role_controller");
|
||
|
|
var GuildbossEvent = require("guildboss_event");
|
||
|
|
var BattleController = require("battle_controller");
|
||
|
|
var BattleConst = require("battle_const");
|
||
|
|
var GuildbossConst = require("guildboss_const");
|
||
|
|
var GuildbossController = cc.Class({
|
||
|
|
"extends": BridgeController,
|
||
|
|
ctor: function ctor() {},
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function initConfig() {
|
||
|
|
var GuildbossModel = require("guildboss_model");
|
||
|
|
this.model = new GuildbossModel();
|
||
|
|
this.model.initConfig();
|
||
|
|
},
|
||
|
|
// 返回当前的model
|
||
|
|
getModel: function getModel() {
|
||
|
|
return this.model;
|
||
|
|
},
|
||
|
|
// 注册监听事件
|
||
|
|
registerEvents: function registerEvents() {},
|
||
|
|
//请求或者清除一些基础信息的东西
|
||
|
|
// requestInitProtocal: function (force) {
|
||
|
|
// if (this.role_vo == null)
|
||
|
|
// return
|
||
|
|
// var config = gdata("guild_dun_data", "data_const", "guild_lev");
|
||
|
|
// if (config == null)
|
||
|
|
// return
|
||
|
|
// if (this.role_vo.gid == 0 || this.role_vo.guild_lev < config.val) {
|
||
|
|
// this.model.clearGuildBossInfo({});
|
||
|
|
// } else {
|
||
|
|
// if (force == true) {
|
||
|
|
// this.requestGuildDunBaseInfo();
|
||
|
|
// } else {
|
||
|
|
// var base_info = this.model.getBaseInfo();
|
||
|
|
// if (base_info == null || Utils.next(base_info) == null) {
|
||
|
|
// this.requestGuildDunBaseInfo();
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// },
|
||
|
|
|
||
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
||
|
|
var cfgs = ["guild_dun_data"];
|
||
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
||
|
|
nx.dt.fnInvoke(_cb, true);
|
||
|
|
// this.requestBaseData( _cb );
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
requestBaseData: function requestBaseData(_cb) {
|
||
|
|
this.requestGuildDunBaseInfo(_cb);
|
||
|
|
},
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function registerProtocals() {
|
||
|
|
this.RegisterProtocal(21300, this.handle21300); // 公会副本的基础信息
|
||
|
|
|
||
|
|
this.RegisterProtocal(21307, this.handle21307); // 重置返回
|
||
|
|
this.RegisterProtocal(21308, this.handle21308); // 请求挑战返回
|
||
|
|
|
||
|
|
this.RegisterProtocal(21312, this.handle21312); // 购买挑战次数返回
|
||
|
|
|
||
|
|
this.RegisterProtocal(21318, this.handle21318); // 公会排行榜
|
||
|
|
this.RegisterProtocal(21319, this.handle21319); // 个人排行榜
|
||
|
|
|
||
|
|
this.RegisterProtocal(21303, this.handle21303); // 公会宝箱情况
|
||
|
|
this.RegisterProtocal(21304, this.handle21304); // 领取公会宝箱
|
||
|
|
|
||
|
|
this.RegisterProtocal(21309, this.handle21309); // 战斗结果,用于显示战斗结算
|
||
|
|
this.RegisterProtocal(21317, this.handle21317); // 扫荡结果,用于显示战斗结算
|
||
|
|
|
||
|
|
this.RegisterProtocal(21305, this.handle21305); // 加buff
|
||
|
|
this.RegisterProtocal(21323, this.handle21323); //集结
|
||
|
|
},
|
||
|
|
|
||
|
|
//开关主窗体
|
||
|
|
openMainWindow: function openMainWindow(status) {
|
||
|
|
if (!status) {
|
||
|
|
nx.bridge.closePanel("WndGuildChallenge");
|
||
|
|
} else {
|
||
|
|
if (this.role_vo == null || this.role_vo.gid == 0) {
|
||
|
|
nx.tbox("lab_guild_boss_controller_tip_1");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var config = gdata("guild_dun_data", "data_const", "guild_lev");
|
||
|
|
if (config == null) {
|
||
|
|
nx.tbox("lab_guild_boss_controller_tip_2");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (this.role_vo.guild_lev < config.val) {
|
||
|
|
nx.tbox(config.desc);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var open_data = gdata("function_data", "data_base", [6]);
|
||
|
|
var bool = nx.bridge.checkConditions(open_data.activate);
|
||
|
|
if (bool == false) {
|
||
|
|
nx.tbox(open_data.desc);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.bridge.createPanel("WndGuildChallenge", {});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//开关boss总览窗体
|
||
|
|
openGuildBossPreviewWindow: function openGuildBossPreviewWindow(status) {
|
||
|
|
if (!status) {
|
||
|
|
if (this.boss_preview_window) {
|
||
|
|
this.boss_preview_window.close();
|
||
|
|
this.boss_preview_window = null;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if (this.boss_preview_window == null) {
|
||
|
|
this.boss_preview_window = Utils.createClass("guildboss_preview_window");
|
||
|
|
}
|
||
|
|
this.boss_preview_window.open();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//挑战或者扫荡结算面板
|
||
|
|
openGuildbossResultWindow: function openGuildbossResultWindow(status, data) {
|
||
|
|
if (!status) {
|
||
|
|
if (this.result_window) {
|
||
|
|
this.result_window.close();
|
||
|
|
this.result_window = null;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if (this.result_window == null) {
|
||
|
|
this.result_window = Utils.createClass("guildboss_result_window");
|
||
|
|
}
|
||
|
|
this.result_window.open(data);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//伤害排行榜
|
||
|
|
openGuildBossRankWindow: function openGuildBossRankWindow(status, data) {
|
||
|
|
if (!status) {
|
||
|
|
if (this.rank_window) {
|
||
|
|
this.rank_window.close();
|
||
|
|
this.rank_window = null;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if (this.rank_window == null) {
|
||
|
|
this.rank_window = Utils.createClass("guildboss_rank_window");
|
||
|
|
}
|
||
|
|
this.rank_window.open(data);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//打开总览奖励界面
|
||
|
|
oepnGuildRewardShowView: function oepnGuildRewardShowView(status) {
|
||
|
|
if (!status) {
|
||
|
|
if (this.reward_view) {
|
||
|
|
this.reward_view.close();
|
||
|
|
this.reward_view = null;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if (this.reward_view == null) {
|
||
|
|
this.reward_view = Utils.createClass("guildboss_reward_view");
|
||
|
|
}
|
||
|
|
this.reward_view.open();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//请求公会副本的基础信息,这个在每次打开面板的时候都请求一下吧
|
||
|
|
requestGuildDunBaseInfo: function requestGuildDunBaseInfo(_cb) {
|
||
|
|
this.SendProtocal(21300, {}, _cb);
|
||
|
|
},
|
||
|
|
//公会副本的基础信息返回
|
||
|
|
handle21300: function handle21300(data) {
|
||
|
|
gcore.GlobalEvent.fire(GuildbossEvent.MusterCoolTime, data.coldtime || 0);
|
||
|
|
this.model.updateGuildDunBaseInfo(data);
|
||
|
|
},
|
||
|
|
//购买次数提示,FALSE为普通购买次数 TRUE是挑战购买次数
|
||
|
|
requestBuyChallengeTimes: function requestBuyChallengeTimes(buy_type) {
|
||
|
|
var base_info = this.model.getBaseInfo();
|
||
|
|
if (base_info == null || base_info.buy_count == null) return;
|
||
|
|
var role_vo = RoleController.getInstance().getRoleVo();
|
||
|
|
if (role_vo == null) return;
|
||
|
|
if (base_info.count != 0) {
|
||
|
|
nx.tbox("lab_guild_boss_controller_tip_3");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var buy_callback = function (type) {
|
||
|
|
var protocal = {};
|
||
|
|
protocal.type = type;
|
||
|
|
this.SendProtocal(21312, protocal);
|
||
|
|
}.bind(this);
|
||
|
|
var buy_next_num = base_info.buy_count + 1;
|
||
|
|
var buy_config = gdata("guild_dun_data", "data_buy_count", [buy_next_num]);
|
||
|
|
var buy_configdiff = game.configs.guild_dun_data.data_buy_count[buy_next_num];
|
||
|
|
if (buy_configdiff == null) {
|
||
|
|
nx.tbox("lab_guild_boss_controller_tip_4");
|
||
|
|
} else {
|
||
|
|
if (role_vo.vip_lev < buy_config.vip_lev) {
|
||
|
|
var msg = cc.js.formatStr(nx.text.getKey("lab_guild_boss_controller_tip_5"), buy_config.vip_lev);
|
||
|
|
nx.mbox(msg, ["cancel", "confirm"], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == "confirm") {
|
||
|
|
nx.bridge.createPanel("WndPayment", {
|
||
|
|
key: "recharge"
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
var cost = buy_config.expend;
|
||
|
|
if (cost == null || Utils.getArrLen(cost) < 2) return;
|
||
|
|
var item_config = Utils.getItemConfig(cost[0]);
|
||
|
|
if (item_config) {
|
||
|
|
var msg = cc.js.formatStr(nx.text.getKey("lab_guild_boss_controller_tip_7"), item_config.icon, cost[1]);
|
||
|
|
nx.mbox(msg, ["cancel", "confirm"], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == "confirm") {
|
||
|
|
buy_callback(buy_type);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//购买次数返回
|
||
|
|
handle21312: function handle21312(data) {
|
||
|
|
nx.tbox(data.msg);
|
||
|
|
if (data.code == 1) this.model.updateBaseWithTimes(data.count, data.buy_count, data.type);
|
||
|
|
},
|
||
|
|
//请求重置公会章节信息
|
||
|
|
requestResetGuildDun: function requestResetGuildDun(type) {
|
||
|
|
var protocal = {};
|
||
|
|
protocal.type = type;
|
||
|
|
this.SendProtocal(21307, protocal);
|
||
|
|
},
|
||
|
|
//重置返回
|
||
|
|
handle21307: function handle21307(data) {
|
||
|
|
nx.tbox(data.msg);
|
||
|
|
},
|
||
|
|
//请求挑战指定的boss
|
||
|
|
send21308: function send21308(boss_id, formation_type, pos_info, hallows_id) {
|
||
|
|
var protocal = {};
|
||
|
|
protocal.boss_id = boss_id;
|
||
|
|
protocal.formation_type = formation_type;
|
||
|
|
protocal.pos_info = pos_info;
|
||
|
|
protocal.hallows_id = hallows_id;
|
||
|
|
this.SendProtocal(21308, protocal);
|
||
|
|
},
|
||
|
|
//请求挑战返回
|
||
|
|
handle21308: function handle21308(data) {},
|
||
|
|
//更新每日宝箱
|
||
|
|
handle21303: function handle21303(data) {
|
||
|
|
this.model.initDayBoxRewardsStatus(data.bos_list);
|
||
|
|
},
|
||
|
|
//领取宝箱返回
|
||
|
|
handle21304: function handle21304(data) {
|
||
|
|
nx.tbox(data.msg);
|
||
|
|
if (data.code == 1) this.model.updateBoxRewards(data.fid, data.num);
|
||
|
|
},
|
||
|
|
handle21321: function handle21321(data) {
|
||
|
|
nx.tbox(data.msg);
|
||
|
|
},
|
||
|
|
//集结
|
||
|
|
send21323: function send21323() {
|
||
|
|
this.SendProtocal(21323, {});
|
||
|
|
},
|
||
|
|
handle21323: function handle21323(data) {
|
||
|
|
if (data.code == 0) {
|
||
|
|
nx.tbox(data.msg);
|
||
|
|
} else if (data.code == 1) {
|
||
|
|
// var less_time = data.coldtime - client.socket.getTime();
|
||
|
|
// gcore.GlobalEvent.fire(GuildbossEvent.MusterCoolTime, less_time || 0);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//加buff数据
|
||
|
|
send21305: function send21305() {
|
||
|
|
this.SendProtocal(21305, {});
|
||
|
|
},
|
||
|
|
handle21305: function handle21305(data) {
|
||
|
|
nx.tbox(data.msg);
|
||
|
|
},
|
||
|
|
//请求排行榜数据
|
||
|
|
requestGuildDunRank: function requestGuildDunRank(index, protocal) {
|
||
|
|
if (index == GuildbossConst.rank.guild) {
|
||
|
|
this.SendProtocal(21327, {});
|
||
|
|
} else if (index == GuildbossConst.rank.role) {
|
||
|
|
if (protocal) this.SendProtocal(21319, protocal);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//公会排行榜
|
||
|
|
|
||
|
|
handle21318: function handle21318(data) {
|
||
|
|
gcore.GlobalEvent.fire(GuildbossEvent.UpdateGuildDunRank, data, GuildbossConst.rank.guild);
|
||
|
|
},
|
||
|
|
//个人排行榜
|
||
|
|
handle21319: function handle21319(data) {
|
||
|
|
this.model.setRaknRoleList(data);
|
||
|
|
gcore.GlobalEvent.fire(GuildbossEvent.UpdateGuildDunRank, data, GuildbossConst.rank.role);
|
||
|
|
},
|
||
|
|
//挑战结果,用于显示结算面板的
|
||
|
|
handle21309: function handle21309(data) {
|
||
|
|
this.new_result_data = data;
|
||
|
|
return;
|
||
|
|
BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.GuildDun, data);
|
||
|
|
},
|
||
|
|
newResultWin: function newResultWin() {
|
||
|
|
if (!this.new_result_data) return;
|
||
|
|
BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.GuildDun, this.new_result_data);
|
||
|
|
this.new_result_data = null;
|
||
|
|
},
|
||
|
|
//扫荡结算
|
||
|
|
handle21317: function handle21317(data) {
|
||
|
|
nx.tbox(data.msg);
|
||
|
|
if (data.code == 1) BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.GuildDun, data);
|
||
|
|
},
|
||
|
|
//请求扫荡指定boss
|
||
|
|
requestMopupMonster: function requestMopupMonster(boss_id) {
|
||
|
|
var protocal = {};
|
||
|
|
protocal.boss_id = boss_id;
|
||
|
|
this.SendProtocal(21317, protocal);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
module.exports = GuildbossController;
|
||
|
|
|
||
|
|
cc._RF.pop();
|