UIWorldMapCtr.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. local UIWorldMapCtr = class("UIWorldMapCtr", require("UICtrBase"))
  2. function UIWorldMapCtr:Init(view)
  3. self.view = view
  4. end
  5. ---@param data nil|boolean 是否播放进入下一个区域的动画
  6. function UIWorldMapCtr:SetData(data)
  7. self.asyncIdx = 0
  8. self.data = data
  9. self:InitData()
  10. ManagerContainer.DataMgr.BigMapData:SendGetData()
  11. end
  12. function UIWorldMapCtr:GetAsyncIdx()
  13. self.asyncIdx = self.asyncIdx + 1
  14. return self.asyncIdx
  15. end
  16. function UIWorldMapCtr:GetData()
  17. return self.data
  18. end
  19. function UIWorldMapCtr:OnDispose()
  20. self.data = nil
  21. self.view = nil
  22. self.curMapId = nil
  23. self.curLevelId = nil
  24. self.lastMapId = nil
  25. self.lastLevelId = nil
  26. end
  27. function UIWorldMapCtr:InitData()
  28. self.curMapId, self.curLevelId = ManagerContainer.LuaBattleMgr:GetCurMapAndLevel()
  29. if self:IsChangeMap() then
  30. -- 找到上一个区域的最后一个关卡点
  31. local lastMapId = self.curMapId - 1
  32. local lastLevelId = 0
  33. local levelData = ManagerContainer.CfgMgr:GetLevelDataByMapAndLevel(lastMapId, 1)
  34. while levelData ~= nil do
  35. lastLevelId = lastLevelId + 1
  36. levelData = ManagerContainer.CfgMgr:GetLevelDataByMapAndLevel(lastMapId, lastLevelId + 1)
  37. end
  38. if lastLevelId > 0 then
  39. self.lastMapId = lastMapId
  40. self.lastLevelId = lastLevelId
  41. return
  42. end
  43. LogError("Not Find lastMapId and lastLevelId. curMapId : " .. tostring(self.curMapId) .. " curLevelId : " .. tostring(self.curLevelId))
  44. end
  45. self.data = nil
  46. self.lastMapId = nil
  47. self.lastLevelId = nil
  48. end
  49. function UIWorldMapCtr:IsChangeMap()
  50. return self.data or false
  51. end
  52. function UIWorldMapCtr:GetCurMapId()
  53. return self.curMapId
  54. end
  55. function UIWorldMapCtr:GetLastMapId()
  56. return self.lastMapId
  57. end
  58. function UIWorldMapCtr:GetShowMapId()
  59. if self:IsChangeMap() then
  60. return self.lastMapId
  61. else
  62. return self.curMapId
  63. end
  64. end
  65. function UIWorldMapCtr:GetShowMapName()
  66. if self:IsChangeMap() then
  67. return self:GetMapName(self.lastMapId, self.lastLevelId)
  68. else
  69. return self:GetMapName(self.curMapId, self.curLevelId)
  70. end
  71. end
  72. function UIWorldMapCtr:ClearChangeMap()
  73. self.data = nil
  74. end
  75. function UIWorldMapCtr:GetMapName(mapId, levelId)
  76. local levelData = ManagerContainer.CfgMgr:GetLevelDataByMapAndLevel(mapId, levelId)
  77. return levelData and I18N.SetLanguageValue(levelData.Name) or ''
  78. end
  79. function UIWorldMapCtr:GetTopRankPlayerList()
  80. return ManagerContainer.DataMgr.BigMapData:GetTopRankPlayerList()
  81. end
  82. return UIWorldMapCtr