|
require("game.role.RoleManager")
|
|
require("game.mainUI.MainRoleHeadInfoManager")
|
|
require("game.mainUI.ExpBarManager")
|
|
RoleController = RoleController or BaseClass(BaseController)
|
|
function RoleController:__init()
|
|
RoleController.Instance = self
|
|
|
|
self.mainRoleManager = MainRoleHeadInfoManager:GetInstance()
|
|
self.expBarManager = ExpBarManager:GetInstance()
|
|
|
|
RoleManager:getInstance()
|
|
self:registerAllProtocals()
|
|
self:addAllEvents()
|
|
end
|
|
function RoleController:__delete()
|
|
|
|
end
|
|
|
|
function RoleController:registerAllProtocals()
|
|
self:RegisterProtocal(13001,"on13001")
|
|
self:RegisterProtocal(13002,"on13002")
|
|
self:RegisterProtocal(13003,"on13003")
|
|
self:RegisterProtocal(13006,"on13006")
|
|
self:RegisterProtocal(13009,"on13009") --玩家当前正在参与的玩法
|
|
self:RegisterProtocal(13011,"on13011")
|
|
self:RegisterProtocal(13032,"on13032")
|
|
self:RegisterProtocal(13033,"on13033")
|
|
self:RegisterProtocal(13034,"on13034")
|
|
self:RegisterProtocal(13035,"on13035")
|
|
self:RegisterProtocal(13036,"on13036")
|
|
self:RegisterProtocal(13020,"on13020")
|
|
self:RegisterProtocal(13037,"on13037")
|
|
self:RegisterProtocal(13015,"on13015")
|
|
self:RegisterProtocal(13016,"on13016")
|
|
end
|
|
function RoleController:addAllEvents()
|
|
local function onGameStartHandler()
|
|
self:SendFmtToGame(13011)
|
|
self:SendFmtToGame(13016)
|
|
end
|
|
self:Bind(EventName.GAME_START, onGameStartHandler)
|
|
|
|
local function scene_start_func()
|
|
RoleManager.Instance.mainRoleInfo.kill_mon_exp = 0
|
|
end
|
|
GlobalEventSystem:Bind(SceneEventType.SCENE_CHANGED, scene_start_func)
|
|
|
|
local function reduce_role_hatred(num)
|
|
self:SendFmtToGame(13035, "h", num)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.REDUCE_ROLE_HATRED, reduce_role_hatred)
|
|
end
|
|
|
|
function RoleController:on13001()
|
|
RoleManager.Instance.mainRoleInfo:ReadFrom13001()
|
|
GlobalEventSystem:Fire(EventName.GAME_START)
|
|
GlobalEventSystem:Fire(EventName.INIT_MAINUI_EVENT)--主界面创建从LoginController的canvas_fun方法移动到这里
|
|
end
|
|
|
|
function RoleController:on13002()
|
|
local exp = UserMsgAdapter.ReadFmt("l")
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("exp",exp)
|
|
end
|
|
|
|
function RoleController:on13003()
|
|
RoleManager.Instance.mainRoleInfo:ReadFrom13003()
|
|
end
|
|
--更新彩钻和金币
|
|
function RoleController:on13006()
|
|
-- 交易券 彩钻 红钻 404钻 社团贡献 名望券 这样还搞错的话我也莫得办法了(╯‵□′)╯︵┻━┻
|
|
local tong, jin, jinLock, jinPink, guild_contribute, honor = self:ReadFmt("iiiiii")
|
|
if tong > RoleManager.Instance.mainRoleInfo.tong or
|
|
jin > RoleManager.Instance.mainRoleInfo.jin or
|
|
jinLock > RoleManager.Instance.mainRoleInfo.jinLock or
|
|
honor > RoleManager.Instance.mainRoleInfo.honor then
|
|
lua_soundM:PlayUIEffectSound(LuaSoundManager.SOUND_UI.SUCCESS)
|
|
end
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("tong",tong)
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("jinLock",jinLock)
|
|
local need_force_fire = false
|
|
local last_jinPink = RoleManager.Instance.mainRoleInfo.jinPink
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("jinPink",jinPink)
|
|
if last_jinPink ~= RoleManager.Instance.mainRoleInfo.jinPink then
|
|
need_force_fire = true
|
|
end
|
|
if need_force_fire then
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("jin",jin,false,true)
|
|
else
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("jin",jin)
|
|
end
|
|
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("guild_contribute",guild_contribute)
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("honor",honor)
|
|
end
|
|
|
|
function RoleController:on13011()
|
|
RoleManager.Instance.mainRoleInfo:ReadFrom13011()
|
|
GlobalEventSystem:Fire(EventName.UPDATE_WORLD_LEVEL_VIEW)
|
|
end
|
|
|
|
--读取八大基础属性
|
|
function RoleController:on13032()
|
|
RoleManager.Instance.mainRoleInfo:ReadFrom13032()
|
|
end
|
|
|
|
--更新主角属性
|
|
function RoleController:on13033()
|
|
RoleManager.Instance.mainRoleInfo:ReadFrom13033()
|
|
end
|
|
|
|
--更新主角仇恨值
|
|
function RoleController:on13034()
|
|
RoleManager.Instance.mainRoleInfo:ReadFrom13034()
|
|
end
|
|
|
|
function RoleController:on13035()
|
|
local code,reduce,left = self:ReadFmt("ihh")
|
|
if code == 1 then
|
|
local str = "成功消除"..reduce.."点罪恶值,您当前的罪恶值为 <color=#73ac44>"..left.."</color>"
|
|
ChatModel.Instance:AddInfoToChatView(str, ChatModel.CHANNEL_SYSTEM, 0)
|
|
Message.show(str)
|
|
else
|
|
ErrorCodeShow(code)
|
|
end
|
|
end
|
|
|
|
function RoleController:on13036()
|
|
local expType,exp,percent = self:ReadFmt("hlh")
|
|
if expType == 218 then
|
|
Message.show("增加经验"..exp)
|
|
elseif expType == 306 then -- 社团祝火经验值
|
|
SysInfoCtrl.Instance:AppendMsg(SysInfoCtrl.SysInfoType.EXP, exp, percent)
|
|
else
|
|
if BeachModel:GetInstance().is_open_chat_view then
|
|
return
|
|
end
|
|
SysInfoCtrl.Instance:AppendMsg(SysInfoCtrl.SysInfoType.EXP, exp, percent)
|
|
if expType == 217 then
|
|
-- if SceneManager.Instance:IsExpScene() then
|
|
-- BaseDungeonModel:getInstance():Fire(BaseDungeonModel.UPDATE_EXP,exp)
|
|
-- end
|
|
RoleManager.Instance.mainRoleInfo.kill_mon_exp = RoleManager.Instance.mainRoleInfo.kill_mon_exp + exp
|
|
end
|
|
end
|
|
end
|
|
|
|
--获得新技能
|
|
function RoleController:on13020( )
|
|
local len = self:ReadFmt("h")
|
|
local list = {}
|
|
for i=1,len do
|
|
local skill_id = self:ReadFmt("i")
|
|
local cfg = SkillManager.Instance:getSkillFromConfig(skill_id)
|
|
if cfg and cfg.type==2 then
|
|
SkillManager.Instance:AddSkillToSkillList(skill_id)
|
|
end
|
|
end
|
|
end
|
|
|
|
function RoleController:on13037()
|
|
|
|
local info = {
|
|
fighting = 0,
|
|
hp = 0,
|
|
maxHp = 0,
|
|
move_speed = 0,
|
|
}
|
|
|
|
info.fighting = UserMsgAdapter.ReadFmt("i")
|
|
BattleProtoVo.ReadFmt(info)
|
|
local main_role = Scene.Instance.main_role
|
|
if main_role and main_role.name_board then
|
|
main_role.name_board:SetHp(info.hp, info.maxHp)
|
|
end
|
|
GlobalEventSystem:Fire(EventName.UPDATE_ROLE_HEAD_INFO, info)
|
|
end
|
|
|
|
function RoleController:on13015( )
|
|
RoleManager.Instance.mainRoleInfo:ReadFrom13015()
|
|
end
|
|
|
|
function RoleController:on13016( )
|
|
local action_energy, max_action_energy = self:ReadFmt("cc")
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("action_energy", action_energy, false, true)
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("max_action_energy", max_action_energy)
|
|
end
|
|
|
|
--玩家当前正在参与的玩法
|
|
function RoleController:on13009()
|
|
local activity_id = self:ReadFmt("i") or 0
|
|
SceneManager:getInstance():SetMirrorSceneId(activity_id)
|
|
print('Cat:RoleController.lua[183] data', activity_id)
|
|
GlobalEventSystem:Fire(EventName.SCENE_LOAD_VIEW_COMPLETE, activity_id)
|
|
self.is_load_and_enter_finished = true
|
|
SetAsyncUpLoadLevel(1) --场景加载完成,重置状态
|
|
end
|