| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- local RemoteProxy = requireProxy("remote/RemoteProxy")
- local SceneEffectProxy = class("SceneEffectProxy", RemoteProxy)
- SceneEffectProxy.NAME = global.ProxyTable.SceneEffectProxy
- function SceneEffectProxy:ctor()
- SceneEffectProxy.super.ctor(self)
- self._mapEffectList = {}
- end
- function SceneEffectProxy:GetWeatherEffList(...)
- return self._mapEffectList
- end
- function SceneEffectProxy:ClearWeatherEffList()
- self._mapEffectList = {}
- end
- function SceneEffectProxy:handle_MSG_SC_SCREEN_EFFECT_PLAY(msg)
- local data = ParseRawMsgToJson(msg)
- dump(data)
- if not data or not next(data) then
- return nil
- end
- local item = {
- id = data.nEffectItemId,
- effectId = data.nEffectId,
- x = data.nClientX,
- y = data.nClientY,
- speed = data.nPlaySpeed,
- times = data.nPlayCount,
- mode = data.nPlayMode,
- }
- PlayEffectOnScreen(item)
- end
- function SceneEffectProxy:handle_MSG_SC_SCREEN_EFFECT_REMOVE(msg)
- local data = ParseRawMsgToJson(msg)
- dump(data)
- if not data or not next(data) then
- return nil
- end
- local removeName = tostring(data.nEffectItemId)
- global.Facade:sendNotification(global.NoticeTable.Layer_Notice_RemoveChild, removeName)
- end
- function SceneEffectProxy:handle_MSG_SC_PLAY_WEATHER_EFFECT(msg)
- local header = msg:GetHeader()
- local msgLen = msg:GetDataLength()
- local dataString = msg:GetData():ReadString(msgLen)
- local time = header.param1
- local mode = header.recog -- 1黄沙 2花瓣 3下雪
- local mapID = dataString
- if not self._mapEffectList[mapID] then
- self._mapEffectList[mapID] = {}
- end
- table.insert(self._mapEffectList[mapID], { mapID = mapID, time = time, mode = mode })
- local weather = { mapID = mapID, time = time, mode = mode }
- global.Facade:sendNotification(global.NoticeTable.Scene_Weather_Effect_Add, { params = weather })
- end
- function SceneEffectProxy:handle_MSG_SC_PLAY_MAP_ALL_WEATHER(msg)
- local header = msg:GetHeader()
- local num = header.recog -- 数量
- local msgLen = msg:GetDataLength()
- local dataString = msg:GetData():ReadString(msgLen) -- 格式:ID,time,map;ID,time,map
- local list = string.split(dataString, ";")
- for _, data in ipairs(list) do
- if data and string.len(data) > 0 then
- local params = string.split(data, ",")
- if params[1] and params[2] and params[3] then
- local mapID = params[3]
- if not self._mapEffectList[mapID] then
- self._mapEffectList[mapID] = {}
- end
- table.insert(self._mapEffectList[mapID], { mapID = mapID, time = tonumber(params[2]), mode = tonumber(params[1]) })
- end
- end
- end
- global.Facade:sendNotification(global.NoticeTable.Scene_Weather_Effect_Add, { init = true })
- end
- function SceneEffectProxy:handle_MSG_SC_CLEAR_WEATHER_BY_MAP(msg)
- local header = msg:GetHeader()
- local mode = header.recog -- 特效ID -- 0:全清理
- local msgLen = msg:GetDataLength()
- local dataString = msg:GetData():ReadString(msgLen)
- local mapID = dataString
- if mode and mode == 0 then
- self._mapEffectList[mapID] = nil
- else
- if self._mapEffectList[mapID] and next(self._mapEffectList[mapID]) then
- local list = clone(self._mapEffectList[mapID])
- for _, data in ipairs(list) do
- if mode and data.mode == mode then
- table.remove(list, _)
- end
- end
- self._mapEffectList[mapID] = list
- end
- end
- global.Facade:sendNotification(global.NoticeTable.Scene_Weather_Effect_Remove, mode)
- end
- function SceneEffectProxy:onRegister()
- SceneEffectProxy.super.onRegister(self)
- local msgType = global.MsgType
- LuaRegisterMsgHandler(msgType.MSG_SC_SCREEN_EFFECT_PLAY, handler(self, self.handle_MSG_SC_SCREEN_EFFECT_PLAY))
- LuaRegisterMsgHandler(msgType.MSG_SC_SCREEN_EFFECT_REMOVE, handler(self, self.handle_MSG_SC_SCREEN_EFFECT_REMOVE))
- LuaRegisterMsgHandler(msgType.MSG_SC_PLAY_WEATHER_EFFECT, handler(self, self.handle_MSG_SC_PLAY_WEATHER_EFFECT))
- LuaRegisterMsgHandler(msgType.MSG_SC_PLAY_MAP_ALL_WEATHER, handler(self, self.handle_MSG_SC_PLAY_MAP_ALL_WEATHER))
- LuaRegisterMsgHandler(msgType.MSG_SC_CLEAR_WEATHER_BY_MAP, handler(self, self.handle_MSG_SC_CLEAR_WEATHER_BY_MAP))
- end
- return SceneEffectProxy
|