| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- local RemoteProxy = requireProxy( "remote/RemoteProxy" )
- local PlayerTitleProxy = class( "PlayerTitleProxy", RemoteProxy )
- PlayerTitleProxy.NAME = global.ProxyTable.PlayerTitleProxy
- function PlayerTitleProxy:ctor()
- self._activateTitle = nil --激活的称号
- self._titleData = {}
- self._titleList = {}
- PlayerTitleProxy.super.ctor( self )
- end
- function PlayerTitleProxy:onRegister()
- PlayerTitleProxy.super.onRegister(self)
- end
- --获取已激活的称号id
- function PlayerTitleProxy:getActivateTitle()
- return self._activateTitle
- end
- function PlayerTitleProxy:getTitleList()
- return self._titleList
- end
- function PlayerTitleProxy:getTitleData()
- return self._titleData
- end
- function PlayerTitleProxy:getTitleIdByTypeId(id)
- local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
- return ItemConfigProxy:GetItemLooks(id)
- end
- function PlayerTitleProxy:getTitleTime(id)
- if self._titleData[id] then
- return self._titleData[id].time
- end
- return nil
- end
- --称号界面 已激活的icon
- function PlayerTitleProxy:getTitleActivateImage(id)
- local titleId = self:getTitleIdByTypeId(id)
- if global.isWinPlayMode then
- return string.format("%s%s%s.png", global.MMO.PATH_RES_PRIVATE, "title_icon/", titleId + 2)
- else
- return string.format("%s%s%s.png", global.MMO.PATH_RES_PRIVATE, "title_icon/", titleId + 3)
- end
- return nil
- end
- --称号列表的图片
- function PlayerTitleProxy:getTitleListImage(id)
- local titleId = self:getTitleIdByTypeId(id)
- if global.isWinPlayMode then
- return string.format("%s%s%s.png", global.MMO.PATH_RES_PRIVATE, "title_icon/", titleId + 1)
- else
- return string.format("%s%s%s.png", global.MMO.PATH_RES_PRIVATE, "title_icon/", titleId + 2)
- end
- return nil
- end
- --场景中的图片
- function PlayerTitleProxy:getSceneTitleImage(id)
- local titleId = self:getTitleIdByTypeId(id)
- return string.format("%s%s%s.png", global.MMO.PATH_RES_PRIVATE, "title_icon/", titleId)
- end
- --获取称号列表
- function PlayerTitleProxy:ResquestTitleList()
- LuaSendMsg( global.MsgType.MSG_CS_TITLE_REQUEST, 1)
- end
- --激活称号
- function PlayerTitleProxy:ResquestActivateTitle(id)
- LuaSendMsg( global.MsgType.MSG_CS_TITLE_REQUEST, 4, id)
- end
- --卸下称号
- function PlayerTitleProxy:ResquestDisboardTitle()
- LuaSendMsg( global.MsgType.MSG_CS_TITLE_REQUEST, 5)
- end
- function PlayerTitleProxy:handle_MSG_SC_TITLE_REPONSE( msg )
- local header = msg:GetHeader()
- -- dump(header)
- if header.recog == 1 then
- local jsonData = ParseRawMsgToJson(msg)
- --称号列表
- self._activateTitle = {}
- self._titleList = {}
- if not jsonData then return end
- if jsonData.data then
- for i,v in pairs(jsonData.data) do
- local id = v[1]
- local time = v[2]
- local data = {id = id, time = time, index = i}
- self._titleData[id] = data
- self._titleList[i] = data
- end
- end
- self._activateTitle = jsonData.active
-
- elseif header.recog == 2 then
- --增加称号
- local id = header.param1
- if id and id > 0 then
- local time = header.param2
- if not self._titleData[id] then
- local index = #self._titleList + 1
- local data = {id = id, time = time, index = index}
- self._titleData[id] = data
- self._titleList[index] = data
- else
- self._titleData[id].time = time
- end
- end
-
- elseif header.recog == 3 then
- --删除称号
- local id = header.param1
- local config = self._titleData[id]
- if config then
- local index = config.index
- if index and self._titleList[index] then
- self._titleList[index] = nil
- end
- end
- self._titleData[id] = nil
- elseif header.recog == 4 then
- --激活
- if header.param1 and header.param1 > 0 then
- self._activateTitle = header.param1
- end
- elseif header.recog == 5 then
- --卸下
- self._activateTitle = nil
- elseif header.recog == 6 then
- --清理全部称号
- self._activateTitle = nil
- self._titleList = {}
- self._titleData = {}
- end
- global.Facade:sendNotification( global.NoticeTable.Layer_Title_Refresh )
- local titleId = nil
- if header.param1 and header.param1 > 0 then
- titleId = header.param1
- end
- SLBridge:onLUAEvent(LUA_EVENT_PLAYER_TITLE_CHANGE, {oper = header.recog, titleId = titleId})
- end
- function PlayerTitleProxy:RegisterMsgHandler()
- PlayerTitleProxy.super.RegisterMsgHandler(self)
- local msgType = global.MsgType
- LuaRegisterMsgHandler( msgType.MSG_SC_TITLE_REPONSE, handler( self, self.handle_MSG_SC_TITLE_REPONSE) )
- end
- return PlayerTitleProxy
|