TaskJumpCtr.lua 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. local TaskJumpCtr = {}
  2. local ConditionJudge = require("Common/ConditionJudge")
  3. function TaskJumpCtr:JumpBuyCfgId(_cfgId, customParams)
  4. --boss战不跳转
  5. local UIBattleCtr = ManagerContainer.LuaUIMgr:GetViewCtrById(Enum.UIPageName.UIBattle)
  6. if UIBattleCtr then
  7. local _bossFightState = UIBattleCtr:GetBattleState();
  8. if _bossFightState then
  9. return false;
  10. end
  11. end
  12. --试炼之塔不跳转
  13. local UICliBattleCtr = ManagerContainer.LuaUIMgr:GetViewCtrById(Enum.UIPageName.UIClimbingTowerBattle)
  14. if UICliBattleCtr then
  15. return false;
  16. end
  17. local UIExpeditionBattleCtr = ManagerContainer.LuaUIMgr:GetViewCtrById(Enum.UIPageName.UIExpeditionBattle)
  18. if UIExpeditionBattleCtr then
  19. return false;
  20. end
  21. --远征之门不跳转
  22. local page = ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UIGuildWar)
  23. if page ~= nil and page.MLuaTable then
  24. return false;
  25. end
  26. local _cfgData = ManagerContainer.CfgMgr:GetUIJumpData(_cfgId);
  27. --LogError("================="..Inspect(_cfgData))
  28. if _cfgData then
  29. --判断解锁条件
  30. local _unlockState = self:JudgeUnLock(_cfgData.UIFuncUnLock);
  31. if not _unlockState then
  32. return false;
  33. end
  34. else
  35. return false;
  36. end
  37. --跳转
  38. local _jumpType = _cfgData.JumpType;
  39. if _jumpType == Enum.TaskJumpType.WeaponHousePage then --武器屋
  40. local _panelsData, _mainPanelId = self:CreatePanelsData(_cfgData);
  41. for _i = 1, #_panelsData do
  42. _panelsData[_i]._param = Enum.EquipForgeType[_panelsData[_i]._param];
  43. end
  44. ManagerContainer.UIJumpMgr:CreateJumpTask(_mainPanelId, _panelsData);
  45. elseif _jumpType == Enum.TaskJumpType.HeroPage then --英灵殿
  46. local _curMinPage = self:JudgeCurMainPage();
  47. ManagerContainer.DataMgr.ArenaData:SendArenaDataReq(Enum.UIPageName.UIDojo2D, _curMinPage);
  48. elseif _jumpType == Enum.TaskJumpType.ChallengerHouse then --挑战者之家
  49. self:ClearWorldBossParam();
  50. local _panelsData, _mainPanelId = self:CreatePanelsData(_cfgData);
  51. self._backPageId = _mainPanelId;
  52. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.WORLD_BOSS_LIST_CHANGED, self, self.OpenWorldBossAck);
  53. self:OpenWorldBoss(self._backPageId);
  54. elseif _jumpType == Enum.TaskJumpType.RolePage then --角色界面
  55. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UIMAINVIEW_CHANGE_NOTICE, Enum.MainViewPageType.Role, 1)
  56. --ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIRoleMain1, nil);
  57. elseif _jumpType == Enum.TaskJumpType.Guild then
  58. local errorCode = ManagerContainer.DataMgr.GuildDataMgr:GetGuildDataStateErrorCode()
  59. if errorCode then
  60. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  61. return false
  62. end
  63. local _panelsData, _mainPanelId = self:CreatePanelsData(_cfgData)
  64. if customParams then
  65. if _panelsData and _panelsData[1] and not _panelsData[1]._param then
  66. _panelsData[1]._param = customParams
  67. end
  68. end
  69. ManagerContainer.UIJumpMgr:CreateJumpTask(_mainPanelId, _panelsData)
  70. elseif _jumpType == Enum.TaskJumpType.ActivityPage then
  71. local _panelsData, _mainPanelId = self:CreatePanelsData(_cfgData)
  72. if _panelsData and _panelsData[1] and _panelsData[1]._param then
  73. local actData = ManagerContainer.DataMgr.ActsDataMgr:GetActivityItemById(_panelsData[1]._param)
  74. if not (actData and not actData:IsOutofDate() and actData:IsOpened()) then
  75. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('UIJumpNoActivity')
  76. return false
  77. end
  78. _panelsData[1]._param = {pageBg = actData.pageBg, actId = actData.actId}
  79. ManagerContainer.UIJumpMgr:CreateJumpTask(_mainPanelId, _panelsData)
  80. else
  81. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('UIJumpNoActivity')
  82. return false
  83. end
  84. elseif _jumpType == Enum.TaskJumpType.TitleMaterials then
  85. local _panelsData, _mainPanelId = self:CreatePanelsData(_cfgData);
  86. _panelsData[1]._param = customParams
  87. ManagerContainer.UIJumpMgr:CreateJumpTask(_mainPanelId, _panelsData);
  88. else
  89. local _panelsData, _mainPanelId = self:CreatePanelsData(_cfgData);
  90. ManagerContainer.UIJumpMgr:CreateJumpTask(_mainPanelId, _panelsData);
  91. end
  92. return true;
  93. end
  94. function TaskJumpCtr:CreatePanelsData(_cfgData)
  95. local _panelsData = nil;
  96. if _cfgData.PanelData and #_cfgData.PanelData > 0 then
  97. _panelsData = {};
  98. local _curMinPage = self:JudgeCurMainPage();
  99. for _i = 1, #_cfgData.PanelData do
  100. local _panel = _cfgData.PanelData[_i];
  101. local _type = type(_panel);
  102. if _type == "number" then
  103. local _panelData = {
  104. _panelId = _panel,
  105. _param = nil,
  106. _backPageId = _curMinPage,
  107. };
  108. _curMinPage = _panel;
  109. table.insert(_panelsData, _panelData);
  110. elseif _type == "table" then
  111. local _id = _panel[1];
  112. if _id ~= nil then
  113. local _param = _panel[2];
  114. if _param then
  115. local _panelData = {
  116. _panelId = _id,
  117. _param = _param,
  118. _backPageId = _curMinPage,
  119. };
  120. _curMinPage = _id;
  121. table.insert(_panelsData, _panelData);
  122. else
  123. LogError("跳转页面传参有误:" .. Inspect(_panel))
  124. LogError(Inspect(_cfgData))
  125. end
  126. else
  127. LogError("跳转页面id有误:" .. Inspect(_panel))
  128. LogError(Inspect(_cfgData))
  129. end
  130. end
  131. end
  132. end
  133. local _mainPanelId = self:JudgeCurMainPage() or Enum.UIPageName.UIRoleMain1;
  134. if _cfgData.MainPanelId and _cfgData.MainPanelId > 0 then
  135. _mainPanelId = _cfgData.MainPanelId;
  136. end
  137. return _panelsData, _mainPanelId;
  138. end
  139. function TaskJumpCtr:JumpUIPage(_jumpType, _UIFunLockId)
  140. --boss战不跳转
  141. local _bossFightState = UIBattleCtr:GetBattleState();
  142. if _bossFightState then
  143. return;
  144. end
  145. --判断解锁条件
  146. local _unlockState = self:JudgeUnLock(_UIFunLockId);
  147. if not _unlockState then
  148. return;
  149. end
  150. --跳转
  151. local _curMinPage = self:JudgeCurMainPage();
  152. if _jumpType == Enum.TaskJumpType.BattlePage then --战斗巡游界面
  153. ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIBattle, nil);
  154. elseif _jumpType == Enum.TaskJumpType.RolePage then --角色界面
  155. ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIRoleMain1, nil);
  156. elseif _jumpType == Enum.TaskJumpType.WeaponHousePage then --武器屋
  157. local _panelsData = {{_panelId = Enum.UIPageName.UIForge1,
  158. _param = Enum.EquipForgeType[Enum.ForgeType.Sword],
  159. _backPageId = _curMinPage}};
  160. ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIMainCity1, _panelsData);
  161. elseif _jumpType == Enum.TaskJumpType.TowerPage then --试炼爬塔界面
  162. local _panelsData = {{_panelId = Enum.UIPageName.UIClimbingTower,
  163. _param = nil,
  164. _backPageId = _curMinPage}};
  165. ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIMainCity1, _panelsData);
  166. elseif _jumpType == Enum.TaskJumpType.HeroPage then --英灵殿
  167. ManagerContainer.DataMgr.ArenaData:SendArenaDataReq(Enum.UIPageName.UIDojo2D, _curMinPage);
  168. elseif _jumpType == Enum.TaskJumpType.AlliancePage then --工会
  169. elseif _jumpType == Enum.TaskJumpType.DevilAlliancePage then --恶魔协会
  170. local _panelsData = {{_panelId = Enum.UIPageName.UISkillExpBattle,
  171. _param = nil,
  172. _backPageId = _curMinPage}};
  173. ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIMainCity1, _panelsData);
  174. elseif _jumpType == Enum.TaskJumpType.ShopPage then --普通商店
  175. --暂时不开
  176. --ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIShopNew, nil);
  177. elseif _jumpType == Enum.TaskJumpType.HeroShopPage then --英灵殿商店
  178. --暂时不开
  179. --[[
  180. local _panelsData = {{_panelId = Enum.UIPageName.UIDojoShop,
  181. nil,
  182. _backPageId = Enum.UIPageName.UIMainCity1}};
  183. ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIMainCity1, _panelsData);]]--
  184. elseif _jumpType == Enum.TaskJumpType.CardHousePage then --卡片屋
  185. local _panelsData = {{_panelId = Enum.UIPageName.UICardList,
  186. _param = Enum.CardFuncType.Recreate,
  187. _backPageId = _curMinPage}};
  188. ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIMainCity1, _panelsData);
  189. elseif _jumpType == Enum.TaskJumpType.Fashion then --时装
  190. local _panelsData = {{_panelId = Enum.UIPageName.UIFashion,
  191. _param = nil,
  192. _backPageId = _curMinPage}};
  193. ManagerContainer.UIJumpMgr:CreateJumpTask(Enum.UIPageName.UIMainCity1, _panelsData);
  194. elseif _jumpType == Enum.TaskJumpType.ChallengerHouse then --挑战者之家
  195. local data = require('ExecuteSequenceData'):new()
  196. ManagerContainer.LuaUIMgr:OpenInputMask(9500);
  197. if not ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIMainCity1) then
  198. data:AppendUIViewFunc(false, Enum.UIPageName.UIMain, 'ChangePageMsg', Enum.MainViewPageType.Town)
  199. data:AppendUIListener(Enum.UIPageName.UIMainCity1, UIEventNames.UI_FILLCONTENT_COMPELETED, 5)
  200. end
  201. data:AppendUIViewFunc(false, Enum.UIPageName.UIMainCity1, 'OpenWorldBoss')
  202. data:AppendUIListener(Enum.UIPageName.UIWorldBossList, UIEventNames.UI_FILLCONTENT_COMPELETED, 5)
  203. data:AppendUIViewFunc(true, Enum.UIPageName.UIMainCity1, 'CloseInputMask')
  204. ManagerContainer.ExecuteSequenceMgr:Execute(data)
  205. end
  206. end
  207. --判断跳转的功能是否已经解锁
  208. function TaskJumpCtr:JudgeUnLock(_id)
  209. if _id == nil or _id == 0 then
  210. return true;
  211. end
  212. local _unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(_id)
  213. if not _unlockState then
  214. local _cfgData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(_id);
  215. if _cfgData and _cfgData.UnlockCond and _cfgData.UnlockCond[1] then
  216. local result, val, content = ConditionJudge:ConditionPassResult1(_cfgData.UnlockCond[1])
  217. if not result then
  218. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(content..I18N.T(_cfgData.FunName)..I18N.T("Fun"))
  219. end
  220. end
  221. end
  222. return _unlockState;
  223. end
  224. --创建提示字符串
  225. function TaskJumpCtr:CreateWarningStr(_levelId, _strId)
  226. local _nameStr = I18N.T(_strId);
  227. local _levelData = ManagerContainer.CfgMgr:GetLevelDataById(_levelId);
  228. local _levelName = "";
  229. if _levelData then
  230. _levelName = _levelData.Name;
  231. end
  232. local _str = I18N.SetLanguageValue("FunUnLock", _levelName, _nameStr);
  233. return _str;
  234. end
  235. --获取当前的主界面的id
  236. function TaskJumpCtr:JudgeCurMainPage()
  237. local _page = ManagerContainer.DataMgr.TaskDataNew:GetMainButton();
  238. if _page == Enum.MainViewPageType.Town then
  239. return Enum.UIPageName.UIMainCity1;
  240. elseif _page == Enum.MainViewPageType.Pub then
  241. return Enum.UIPageName.UIBag;
  242. elseif _page == Enum.MainViewPageType.Adventure then
  243. return Enum.UIPageName.UIBattle;
  244. end
  245. end
  246. --打开挑战者大厅(曾用名是世界boss)
  247. function TaskJumpCtr:OpenWorldBoss(_uiDataId)
  248. if ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIWorldBossList) then
  249. return
  250. end
  251. local _hasWordBoss = ManagerContainer.DataMgr.WorldBossData:HasWorldBossList();
  252. if _hasWordBoss then
  253. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIWorldBossList, nil, _uiDataId);
  254. else
  255. ManagerContainer.DataMgr.WorldBossData:SendWorldBossListRequest();
  256. end
  257. end
  258. function TaskJumpCtr:OpenWorldBossAck()
  259. self:OpenWorldBoss(self._backPageId);
  260. self:ClearWorldBossParam();
  261. end
  262. function TaskJumpCtr:ClearWorldBossParam()
  263. self._backPageId = nil;
  264. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.WORLD_BOSS_LIST_CHANGED, self, self.OpenWorldBoss)
  265. end
  266. return TaskJumpCtr