MiniMapProxy.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local MiniMapProxy = class("MiniMapProxy", RemoteProxy)
  3. MiniMapProxy.NAME = global.ProxyTable.MiniMapProxy
  4. function MiniMapProxy:ctor()
  5. MiniMapProxy.super.ctor(self)
  6. self._monsters = {}
  7. self._teamData = {}
  8. self._portalConfig = {}
  9. end
  10. function MiniMapProxy:LoadConfig()
  11. self._portalConfig = requireGameConfig("cfg_mapdesc")
  12. end
  13. function MiniMapProxy:getMonsters()
  14. return self._monsters
  15. end
  16. function MiniMapProxy:getPortals()
  17. local mapProxy = global.Facade:retrieveProxy(global.ProxyTable.Map)
  18. local mapID = mapProxy:GetMapID()
  19. local items = {}
  20. for _, v in pairs(self._portalConfig) do
  21. if tostring(v.mapid) == mapID then
  22. table.insert(items, v)
  23. end
  24. end
  25. return items
  26. end
  27. function MiniMapProxy:getTeams()
  28. return self._teamData
  29. end
  30. function MiniMapProxy:RespMonsters(msg)
  31. local jsonData = ParseRawMsgToJson(msg)
  32. if not jsonData then
  33. return nil
  34. end
  35. self._monsters = jsonData
  36. SLBridge:onLUAEvent("LUA_EVENT_MINIMAP_MONSTER")
  37. end
  38. function MiniMapProxy:RequestMonsters()
  39. local mapProxy = global.Facade:retrieveProxy(global.ProxyTable.Map)
  40. local mapID = mapProxy:GetMapID()
  41. if not mapID then
  42. return
  43. end
  44. LuaSendMsg(global.MsgType.MSG_CS_MINIMAP_MONSTERS_POINT, 0, 0, 0, 0, mapID, string.len(mapID))
  45. end
  46. function MiniMapProxy:RespTeamMemebersData(msg)
  47. local jsonData = ParseRawMsgToJson(msg)
  48. if not jsonData then
  49. return nil
  50. end
  51. self._teamData = jsonData
  52. SLBridge:onLUAEvent("LUA_EVENT_MINIMAP_TEAM", jsonData)
  53. end
  54. function MiniMapProxy:RequestTeamMemberData()
  55. LuaSendMsg(global.MsgType.MSG_CS_TEAMMEMEBER_DATA)
  56. end
  57. function MiniMapProxy:RegisterMsgHandler()
  58. MiniMapProxy.super.RegisterMsgHandler(self)
  59. local msgType = global.MsgType
  60. LuaRegisterMsgHandler(msgType.MSG_SC_MINIMAP_MONSTERS_POINT, handler(self, self.RespMonsters))
  61. LuaRegisterMsgHandler(msgType.MSG_SC_MINIMAP_TEAM_DATA, handler(self, self.RespTeamMemebersData))
  62. end
  63. return MiniMapProxy