UIWorldMapCtr.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. if(lastMapId < 1) then
  33. lastMapId =1
  34. end
  35. local lastLevelId = 0
  36. local levelData = ManagerContainer.CfgMgr:GetLevelDataByMapAndLevel(lastMapId, 1)
  37. while levelData ~= nil do
  38. lastLevelId = lastLevelId + 1
  39. levelData = ManagerContainer.CfgMgr:GetLevelDataByMapAndLevel(lastMapId, lastLevelId + 1)
  40. end
  41. if lastLevelId > 0 then
  42. self.lastMapId = lastMapId
  43. self.lastLevelId = lastLevelId
  44. return
  45. end
  46. LogError("Not Find lastMapId and lastLevelId. curMapId : " .. tostring(self.curMapId) .. " curLevelId : " .. tostring(self.curLevelId))
  47. end
  48. self.data = nil
  49. self.lastMapId = nil
  50. self.lastLevelId = nil
  51. end
  52. function UIWorldMapCtr:IsChangeMap()
  53. return self.data or false
  54. end
  55. function UIWorldMapCtr:GetCurMapId()
  56. return self.curMapId
  57. end
  58. function UIWorldMapCtr:GetLastMapId()
  59. return self.lastMapId
  60. end
  61. function UIWorldMapCtr:GetShowMapId()
  62. if self:IsChangeMap() then
  63. return self.lastMapId
  64. else
  65. return self.curMapId
  66. end
  67. end
  68. function UIWorldMapCtr:GetShowMapName()
  69. if self:IsChangeMap() then
  70. return self:GetMapName(self.lastMapId, self.lastLevelId)
  71. else
  72. return self:GetMapName(self.curMapId, self.curLevelId)
  73. end
  74. end
  75. function UIWorldMapCtr:ClearChangeMap()
  76. self.data = nil
  77. end
  78. function UIWorldMapCtr:GetMapName(mapId, levelId)
  79. -- local levelData = ManagerContainer.CfgMgr:GetLevelDataByMapAndLevel(mapId, levelId)
  80. -- local mapName = levelData and I18N.SetLanguageValue(levelData.Name) or ''
  81. -- if ManagerContainer.LuaBattleMgr:IsShowDifficultyTxt() then
  82. -- mapName = I18N.T(ManagerContainer.LuaBattleMgr:CurLevelQianZhuiKey())..mapName
  83. -- end
  84. return ManagerContainer.LuaBattleMgr:CurLevelName()
  85. end
  86. function UIWorldMapCtr:GetTopRankPlayerList()
  87. return ManagerContainer.DataMgr.BigMapData:GetTopRankPlayerList()
  88. end
  89. return UIWorldMapCtr