Files

335 lines
12 KiB
JavaScript
Raw Permalink Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '09247tt1z1PoKoY7Q61G2T6', 'guildskill_controller');
// Scripts/mod/guild/talent/guildskill_controller.js
"use strict";
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-01-19 17:37:33
// --------------------------------------------------------------------
var BridgeController = require("bridge.controller");
var BackpackConst = require("backpack_const");
var GuildskillConst = require("guildskill_const");
var RoleController = require("role_controller");
var GuildskillEvent = require("guildskill_event");
var HeroController = require("hero_controller");
var GuildskillController = cc.Class({
"extends": BridgeController,
ctor: function ctor() {},
// 初始化配置数据
initConfig: function initConfig() {
var GuildskillModel = require("guildskill_model");
this.model = new GuildskillModel();
this.model.initConfig();
},
// 返回当前的model
getModel: function getModel() {
return this.model;
},
// 注册监听事件
registerEvents: function registerEvents() {
//背包初始化之后,再请求公会信息,因为要判断是否可以升级技能的
if (this.backpack_init_event == null) {
this.backpack_init_event = gcore.GlobalEvent.bind(EventId.GET_ALL_DATA, function (bag_code) {
if (bag_code != BackpackConst.Bag_Code.BACKPACK) return;
this.role_vo = RoleController.getInstance().getRoleVo();
if (this.role_vo == null) {
if (this.init_role_event == null) {
this.init_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
gcore.GlobalEvent.unbind(this.init_role_event);
this.role_vo = RoleController.getInstance().getRoleVo();
if (this.role_vo) this.registerRoleEvent();
}.bind(this));
}
} else {
this.registerRoleEvent();
}
}.bind(this));
if (this.re_link_game_event == null) {
this.login_event_success = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () {
this.model.clearGuildCareerSkill();
this.requestInitProtocal();
}.bind(this));
}
}
},
registerRoleEvent: function registerRoleEvent() {
this.requestInitProtocal(true);
if (this.role_assets_event == null) {
this.role_assets_event = this.role_vo.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (key, value) {
if (key == "gid") this.requestInitProtocal();else if (key == "guild") {
// this.model.checkGuildSkillRedStatus();
}
}, this);
}
},
reqBaseFromServer: function reqBaseFromServer(_cb) {
var cfgs = ["guild_skill_data"];
this.loadConfigs(cfgs, function (_ret, _data) {
nx.dt.fnInvoke(_cb, true);
// this.send23711( _cb );
});
},
//请求技能状态,用于初始化红点
requestInitProtocal: function requestInitProtocal(_cb) {
if (this.role_vo != null) {
if (this.role_vo.gid != 0) {
this.SendProtocal(23703, {}, _cb);
// --公會pvp技能信息
this.send23711(_cb);
} else {
this.openGuildSkillMainWindow(false);
this.model.clearGuildCareerSkill();
}
}
},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
// this.RegisterProtocal(1110, this.on1110);
this.RegisterProtocal(23700, this.handle23700); // 获取指定职业技能信息
this.RegisterProtocal(23701, this.handle23701); // 激活技能
this.RegisterProtocal(23702, this.handle23702); // 更新当前分组技能
this.RegisterProtocal(23703, this.handle23703); // 可学习技能状态
this.RegisterProtocal(23704, this.handle23704); //重置技能信息消耗
this.RegisterProtocal(23705, this.handle23705); //确定重置技能
this.RegisterProtocal(23706, this.handle23706); //突破
this.RegisterProtocal(23707, this.handle23707); //升級突破後的屬性等級
this.RegisterProtocal(23708, this.handle23708); //升級突破後的技能等級
this.RegisterProtocal(23709, this.handle23709); //重置突破後的技能
this.RegisterProtocal(23710, this.handle23710); //查看突破後該類型的信息
this.RegisterProtocal(23711, this.handle23711); //返回所有數據
},
//打开公会技能的主界面
openGuildSkillMainWindow: function openGuildSkillMainWindow(status) {
if (status == false) {
if (this.main_window != null) {
this.main_window.close();
this.main_window = null;
}
} else {
if (this.main_window == null) this.main_window = Utils.createClass("guildskill_main_window");
this.main_window.open();
}
},
// --==============================--
// --desc:打開公會技能重置界面
// --time:2019年3月11日
// --@status:
// --@return
// --==============================--
openGuildskillResetPanel: function openGuildskillResetPanel(status, career, reset_type) {
if (status == false) {
if (this.guild_skill_reset_panel != null) {
this.guild_skill_reset_panel.close();
this.guild_skill_reset_panel = null;
}
} else {
if (this.guild_skill_reset_panel == null) {
var GuildskillResetPanel = require("guildskill_reset_panel");
this.guild_skill_reset_panel = new GuildskillResetPanel();
}
var ojb = {};
ojb.career = career;
ojb.reset_type = reset_type;
this.guild_skill_reset_panel.open(ojb);
}
},
// --==============================--
// --desc:打開公會技能升級界面
// --time:2020年4月12日
// --@status:
// --@return
// --==============================--
openGuildskillLevelUpPanel: function openGuildskillLevelUpPanel(status, career) {
if (status == false) {
if (this.guildskill_level_up_panel != null) {
this.guildskill_level_up_panel.close();
this.guildskill_level_up_panel = null;
}
} else {
if (this.guildskill_level_up_panel == null) {
var GuildskillLevelUpPanel = require("guildskill_level_up_panel");
this.guildskill_level_up_panel = new GuildskillLevelUpPanel();
}
this.guildskill_level_up_panel.open(career);
}
},
// --==============================--
// --desc:打開公會技能升級成功
// --time:2020年4月12日
// --@status:
// --@return
// --==============================--
openGuildskillLevelSuccessPanel: function openGuildskillLevelSuccessPanel(status, career) {
var skill = this.model.getPvpskillInfoByCareer(career);
var HC = HeroController.getInstance();
HC.openSkillUnlockWindow(status, skill.skill_id);
// if (status == false ){
// if( this.guildskill_level_success_panel != null ){
// this.guildskill_level_success_panel.close()
// this.guildskill_level_success_panel = null
// }
// }else{
// if( this.guildskill_level_success_panel == null ){
// var GuildskillLevelSuccessPanel = require("guildskill_level_success_panel")
// this.guildskill_level_success_panel = new GuildskillLevelSuccessPanel()
// }
// this.guildskill_level_success_panel.open(career)
// }
},
//请求指定职业的技能信息
requestCareerSkillInfo: function requestCareerSkillInfo(career) {
career = career || GuildskillConst.index.physics;
var protocal = {};
protocal.career = career;
this.SendProtocal(23700, protocal);
},
handle23700: function handle23700(data) {
this.model.initGuildCareerSkill(data);
},
//请求激活技能
requestActivitySkill: function requestActivitySkill(skill_id) {
var protocal = {};
protocal.skill_id = skill_id;
this.SendProtocal(23701, protocal);
},
handle23701: function handle23701(data) {
if (!nx.dt.strEmpty(data.msg)) {
nx.tbox(data.msg);
}
if (data.code == 1) this.model.updateGuildCareerSkill(data.career, data.skill_id);
},
//更新指定职业的分组技能信息,这个时候是主要升级
handle23702: function handle23702(data) {
this.model.upgradeGuildCareerSkill(data.career, data.group_id);
},
//可学习技能状态
handle23703: function handle23703(data) {
this.model.initGuildSkillStatus(data);
},
// --==============================--
// --desc:請求重置技能消耗
// --time:2019年3月11日
// --@ 作者: lwc
// --@return
// --==============================--
send23704: function send23704(career) {
var protocal = {};
protocal.career = career;
this.SendProtocal(23704, protocal);
},
handle23704: function handle23704(data) {
gcore.GlobalEvent.fire(GuildskillEvent.UpdateSkillResetEvent, data);
},
// --請求重置
send23705: function send23705(career) {
var protocal = {};
protocal.career = career;
this.SendProtocal(23705, protocal);
},
handle23705: function handle23705(data) {
if (nx.dt.strNEmpty(data.msg)) {
nx.tbox(data.msg);
}
if (data.code == 1) {
this.model.resetCareerSkillInfo(data.career);
}
},
// -- 突破
send23706: function send23706(career2) {
var career = career2 || GuildskillConst.index.physics;
var protocal = {};
protocal.career = career;
this.SendProtocal(23706, protocal);
},
handle23706: function handle23706(data) {
if (nx.dt.strNEmpty(data.msg)) {
nx.tbox(data.msg);
}
if (data.flag == 1) {
gcore.GlobalEvent.fire(GuildskillEvent.Guild_Pvp_Career_Break_Event, data.career);
}
},
// --升級突破後的屬性等級
send23707: function send23707(career2, id) {
var career = career2 || GuildskillConst.index.physics;
var protocal = {};
protocal.career = career;
protocal.id = id;
this.record_id = id;
this.SendProtocal(23707, protocal);
},
handle23707: function handle23707(data) {
if (nx.dt.strNEmpty(data.msg)) {
nx.tbox(data.msg);
}
if (data.flag == 1) {
gcore.GlobalEvent.fire(GuildskillEvent.Guild_Pvp_Career_Update_Event, data.career, 2, this.record_id);
}
},
// -- 升級突破後的技能等級
send23708: function send23708(career2) {
var career = career2 || GuildskillConst.index.physics;
var protocal = {};
protocal.career = career;
this.SendProtocal(23708, protocal);
},
handle23708: function handle23708(data) {
nx.tbox(data.msg);
if (data.flag == 1) {
if (this.guildskill_level_up_panel) {
this.openGuildskillLevelUpPanel(false);
}
gcore.GlobalEvent.fire(GuildskillEvent.Guild_Pvp_Career_Update_Event, data.career, 1);
this.openGuildskillLevelSuccessPanel(true, data.career);
}
},
// -- 重置突破後的技能
send23709: function send23709(career) {
var protocal = {};
protocal.career = career;
this.SendProtocal(23709, protocal);
},
handle23709: function handle23709(data) {
nx.tbox(data.msg);
if (data.flag == 1) {
this.model.setPvpFisrtReset(false);
}
},
// -- pvp單個creer職業 信息
send23710: function send23710(career2) {
var career = career2 || GuildskillConst.index.physics;
var protocal = {};
protocal.career = career;
this.SendProtocal(23710, protocal);
},
handle23710: function handle23710(data) {
this.model.initPvpCareerSkillInfo({
data: data
});
this.model.setPvpFisrtReset(data.is_first == 1);
gcore.GlobalEvent.fire(GuildskillEvent.Guild_Pvp_Career_Info_Event, data.career);
},
// -- pvp 所有職業信息
send23711: function send23711(_cb) {
var protocal = {};
this.SendProtocal(23711, protocal, _cb);
},
handle23711: function handle23711(data) {
this.model.initPvpCareerSkillInfo(data.guild_skill_break_group);
this.model.setPvpFisrtReset(data.is_first == 1);
gcore.GlobalEvent.fire(GuildskillEvent.Guild_Pvp_Skill_Info_Event, data);
}
});
module.exports = GuildskillController;
cc._RF.pop();