123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- ---
- --- Generated by EmmyLua(https://github.com/EmmyLua)
- --- Created by PZM.
- --- DateTime: 2024/7/9 11:21
- ---@class GlobalEventManger
- GlobalEventManger = {}
- local this = GlobalEventManger
- function this.Init()
- this.RegistEvents()
- end
- function this.RegistEvents()
- SL:RegisterLUAEvent(LUA_EVENT_OPENMAINSYSTEMFUNCTION, this.LUA_EVENT_OPENMAINSYSTEMFUNCTION)
- SL:RegisterLUAEvent(LUA_EVENT_EXPAND_RIGHTSYSTEMFUNCTION, this.LUA_EVENT_EXPAND_RIGHTSYSTEMFUNCTION)
- SL:RegisterLUAEvent(LUA_EVENT_PANEL_LOAD_SUCCESS, this.LUA_EVENT_PANEL_LOAD_SUCCESS)
- SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, this.LUA_EVENT_CLOSEWIN)
- SL:RegisterLUAEvent(LUA_EVENT_ENTER_MAP, this.LUA_EVENT_ENTER_MAP)
- SL:RegisterLUAEvent(LUA_EVENT_LOGIN_MAP, this.LUA_EVENT_LOGIN_MAP)
- SL:RegisterLUAEvent(LUA_EVENT_PKMODE_CHANGE, this.LUA_EVENT_PKMODE_CHANGE)
- SL:RegisterLUAEvent(LUA_EVENT_ONHOOK_STATE_CHANGE, this.LUA_EVENT_ONHOOK_STATE_CHANGE)
- SL:RegisterLUAEvent(LUA_EVENT_LEVELCHANGE, this.LUA_EVENT_LEVELCHANGE)
- SL:RegisterLUAEvent(LUA_EVENT_OPEN_SERVER_DAY_CHANGE, this.LUA_EVENT_OPEN_SERVER_DAY_CHANGE)
- SL:RegisterLUAEvent(LUA_EVENT_EXIT_GAME, this.LUA_EVENT_EXIT_GAME)
- SL:RegisterLUAEvent(LUA_EVENT_CREATE_PLAYER_SUCCESS, this.LUA_EVENT_CREATE_PLAYER_SUCCESS)
- SL:RegisterLUAEvent(LUA_EVENT_FRIEND_LIST_CHANGE, this.LUA_EVENT_FRIEND_LIST_CHANGE)
-
- SL:RegisterLuaNetMsg(MessageDef.ResPlayerEnterMapMessage,this.ResPlayerEnterMapMessage)
- end
- function this.UnRegistEvents()
- SL:UnRegisterLUAEvent(LUA_EVENT_OPENMAINSYSTEMFUNCTION, this.LUA_EVENT_OPENMAINSYSTEMFUNCTION)
- SL:UnRegisterLUAEvent(LUA_EVENT_EXPAND_RIGHTSYSTEMFUNCTION, this.LUA_EVENT_EXPAND_RIGHTSYSTEMFUNCTION)
- SL:UnRegisterLUAEvent(LUA_EVENT_PANEL_LOAD_SUCCESS, this.LUA_EVENT_PANEL_LOAD_SUCCESS)
- SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, this.LUA_EVENT_CLOSEWIN)
- SL:UnRegisterLUAEvent(LUA_EVENT_ENTER_MAP, this.LUA_EVENT_ENTER_MAP)
- SL:UnRegisterLUAEvent(LUA_EVENT_LOGIN_MAP, this.LUA_EVENT_LOGIN_MAP)
- SL:UnRegisterLUAEvent(LUA_EVENT_ONHOOK_STATE_CHANGE, this.LUA_EVENT_ONHOOK_STATE_CHANGE)
- SL:UnRegisterLUAEvent(LUA_EVENT_LEVELCHANGE, this.LUA_EVENT_LEVELCHANGE)
- SL:UnRegisterLUAEvent(LUA_EVENT_OPEN_SERVER_DAY_CHANGE, this.LUA_EVENT_OPEN_SERVER_DAY_CHANGE)
- SL:UnRegisterLUAEvent(LUA_EVENT_EXIT_GAME, this.LUA_EVENT_EXIT_GAME)
- SL:UnRegisterLUAEvent(LUA_EVENT_FRIEND_LIST_CHANGE, this.LUA_EVENT_FRIEND_LIST_CHANGE)
- SL:UnRegisterLuaNetMsg(MessageDef.ResPlayerEnterMapMessage,this.ResPlayerEnterMapMessage)
- end
- function this.Reset()
- this.UnRegistEvents()
- end
- --打开主界面系统功能
- ---@param systemName string
- function this.LUA_EVENT_OPENMAINSYSTEMFUNCTION(_, systemName)
- ---@type cfg_MainPanelUI_column
- local tbl = cfg_MainPanelUI_post.GetSystemInfoBySystemId(systemName)
- if tbl and not string.isNullOrEmpty(tbl.command)then
- GUI:UIPanel_Open(tbl.command)
- SL.HideMainPanel()
- end
- end
- --关闭主界面系统功能
- ---@param panelName string
- function this.LUA_EVENT_CLOSEWIN(_, panelName)
- ---@type cfg_MainPanelUI_column
- local tbl = cfg_MainPanelUI_post.GetSystemInfoByPanelName(panelName)
- if tbl then
- SL.ShowMainPanel()
- end
- end
- --展开主界面右侧系统功能
- ---@param isExpand boolean
- function this.LUA_EVENT_EXPAND_RIGHTSYSTEMFUNCTION(_, isExpand)
- SL:OpenGuideEnter(isExpand)
- end
- --界面加载成功
- ---@param control UIKmlLuaPanelBase
- function this.LUA_EVENT_PANEL_LOAD_SUCCESS(_, control)
- GUI:AddMainPanelUIHideShowPos(control)
- local dataList = SL:GetSystemInfoByPanelName(control.panelName)
- ---@param data cfg_system_switch_column
- for i, data in pairs(dataList) do
- if data and data.btnType == ESystemType.Btn then
- local isShow = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, data.systemName)
- SL:ControlSystemPortalVisible(data.btnPath, isShow)
- end
- end
- end
- --进入地图 预显示主界面
- function this.LUA_EVENT_ENTER_MAP(_, eventData)
- SL:ClearSystemFunctionState()
- GUI:UIPanel_Open("dev/ui/MainUI/Panel/KLUIPlayerInfo/KLUIPlayerInfoPanel")
- GUI:UIPanel_Open("dev/ui/MainUI/Panel/KLJoyStick/KLJoyStickPanel")
- GUI:UIPanel_Open("dev/ui/MainUI/Panel/KLUISystemLeft/KLUISystemLeftPanel")
-
- GUI:UIPanel_Open("dev/ui/MainUI/Panel/KLUILeftUp/KLUILeftUpPanel")
-
- GUI:UIPanel_Open("dev/ui/MainUI/Panel/KLUISystemTop/KLUISystemTopPanel")
- GUI:UIPanel_Open("dev/ui/Common/Panel/KLTop/KLTopPanel")
- GUI:UIPanel_Open("dev/ui/NPC/Panel/KLTalkBtn/KLTalkBtnPanel")
- GUI:UIPanel_Open("dev/ui/Chat/Panel/KLUIChatSmallPanel/KLUIChatSmallPanel")
- GUI:UIPanel_Open("dev/ui/Map/Panel/KLMiniMap/KLMiniMapPanel")
- GUI:UIPanel_Open("dev/ui/Role/Panel/KLUIInfo/KLUIInfoPanel")
-
- -- 功能预告入口加到KLUILeftUpPanel下
- local leftUpPanel = GUI:GetUI("dev/ui/MainUI/Panel/KLUILeftUp/KLUILeftUpPanel")
- if leftUpPanel then
- GUI:UIPanel_Open("dev/ui/Preview/Panel/KLPreviewEntrance/KLPreviewEntrancePanel", leftUpPanel.view.tabObjRoot)
- end
- ---非挂机状态下,和平模式自动反击
- local pkMode = SL:GetMetaValue(EMetaVarGetKey.PKMODE)
- SL:SetIsAutoCounterattack(pkMode == EPKMode.Peace)
- SL:AutoCounterattack(pkMode == EPKMode.Peace)
- SL.ShowMainPanel()
- end
- --登录地图
- function this.LUA_EVENT_LOGIN_MAP()
- end
- --战斗模式改变
- ---@param data number
- function this.LUA_EVENT_PKMODE_CHANGE(_, pkMode)
- SL:SetIsAutoCounterattack(pkMode == EPKMode.Peace)
- SL:AutoCounterattack(pkMode == EPKMode.Peace)
- end
- --挂机状态改变
- ---@param onHookStatus EAutoOnHookStatus
- function this.LUA_EVENT_ONHOOK_STATE_CHANGE(_, onHookStatus)
- if onHookStatus == EAutoOnHookStatus.OnHooking then
- SL:SetIsAutoCounterattack(false)
- elseif onHookStatus == EAutoOnHookStatus.StopOnHook then
- local pkMode = SL:GetMetaValue(EMetaVarGetKey.PKMODE)
- SL:SetIsAutoCounterattack(pkMode == EPKMode.Peace)
- end
- end
- ---等级改变
- function this.LUA_EVENT_LEVELCHANGE(_, level)
- --系统功能开启
- if GUI.uipanels then
- ---@param control UIKmlLuaPanelBase
- for i, controlList in pairs(GUI.uipanels) do
- for i, control in pairs(controlList) do
- local dataList = SL:GetSystemInfoByPanelName(control.panelName)
- ---@param data cfg_system_switch_column
- for i, data in pairs(dataList) do
- if data then
- local isShow = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, data.systemName)
- SL:ControlSystemPortalVisible(data.btnPath, isShow)
- end
- end
- end
- end
- end
- end
- ---开服天数改变
- function this.LUA_EVENT_OPEN_SERVER_DAY_CHANGE(_, day)
- --系统功能开启
- if GUI.uipanels then
- ---@param control UIKmlLuaPanelBase
- for i, controlList in pairs(GUI.uipanels) do
- for i, control in pairs(controlList) do
- local dataList = SL:GetSystemInfoByPanelName(control.panelName)
- ---@param data cfg_system_switch_column
- for i, data in pairs(dataList) do
- if data then
- local isShow = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, data.systemName)
- SL:ControlSystemPortalVisible(data.btnPath, isShow)
- end
- end
- end
- end
- end
- end
- ---退出游戏
- function this.LUA_EVENT_EXIT_GAME(_, data)
- end
- function this.ResPlayerEnterMapMessage()
- RoleManager.me.roleEffectContainer:ReleaseModelEffect(146)
- ---@param mapNameTipPanel KLMapNameTipPanel
- GUI:UIPanel_Open("dev/ui/Map/Panel/KLMapNameTip/KLMapNameTipPanel",nil,nil,nil,true,
- function(mapNameTipPanel)
- mapNameTipPanel:RefreshData(Scene.mapConfig.mapIcon)
- end)
- end
- ---角色创建成功事件
- function this.LUA_EVENT_CREATE_PLAYER_SUCCESS(id,rid)
- ---设置召唤兽(宠物)是否显示头顶血条
- local role = SL:GetRoleById(rid)
- if role and role.RoleType == ERoleType.Pet then
- local meRid = SL:GetMetaValue(EMetaVarGetKey.MAIN_ACTOR_ID)
- meRid = tonumber(meRid)
- SL:ShowOrHideHeadHp(role.data.id,role.data.masterId == meRid)
- end
- end
- --收到好友申请后显示刷新红点
- function this.LUA_EVENT_FRIEND_LIST_CHANGE()
- SL:RefreshPanelALLRedStateKmlByCondition("checkReceiveAddFriend")
- end
|