源战役客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

178 строки
4.7 KiB

1 месяц назад
  1. --任务界面
  2. TaskNewBaseView = TaskNewBaseView or BaseClass(BaseView)
  3. local TaskNewBaseView = TaskNewBaseView
  4. -----------------------扩展模块需要修改的地方--------------------------
  5. TaskNewBaseView.Index2View = {
  6. [1] = {index = 1,view = TaskSubMainView},
  7. [2] = {index = 2,view = TaskSubExtensionView},
  8. [3] = {index = 3,view = TaskSubCommonView},
  9. }
  10. ----------------------------------------------------------------
  11. function TaskNewBaseView:__init()
  12. self.base_file = "task"
  13. self.layout_file = "TaskNewBaseView"
  14. self.layer_name = "UI"
  15. self.append_to_ctl_queue = true
  16. self.use_background = true
  17. self.change_scene_close = true
  18. self.close_fog = true
  19. self.model = TaskModel:getInstance()
  20. self.show_tabs = {}
  21. self.tab_name_list = {}
  22. self.contaner_list = {}
  23. local playerLv = RoleManager:getInstance():GetMainRoleVo().level
  24. for i,v in ipairs(Config.ConfigTaskEffect.Tabbuttons) do
  25. if v.open_lv <= playerLv then
  26. if i == 2 and not ClientConfig.alpha_mode then
  27. table.insert(self.show_tabs, TaskNewBaseView.Index2View[i])
  28. table.insert(self.tab_name_list,v)
  29. -- elseif i == 5 and self.model:HasTurnLine() then
  30. -- table.insert(self.show_tabs, TaskNewBaseView.Index2View[i])
  31. -- table.insert(self.tab_name_list,v)
  32. else
  33. table.insert(self.show_tabs, TaskNewBaseView.Index2View[i])
  34. table.insert(self.tab_name_list,v)
  35. end
  36. end
  37. end
  38. self.load_callback = function ()
  39. self:LoadSuccess()
  40. self:InitEvent()
  41. end
  42. self.open_callback = function ()
  43. self:InitView()
  44. end
  45. self.close_callback = function( )
  46. end
  47. self.destroy_callback = function ()
  48. self:Remove()
  49. end
  50. end
  51. -- task_id 针对第二个标签
  52. --parent_index,sub_index 针对第三个标签
  53. function TaskNewBaseView:Open(index,task_id,parent_index,sub_index)
  54. self.open_index = self:GetRealTabIndex(index or 1)
  55. self.task_id = task_id
  56. self.parent_index = parent_index
  57. self.sub_index = sub_index
  58. BaseView.Open(self)
  59. end
  60. function TaskNewBaseView:InitView()
  61. self:SeletedTabbar(self.open_index)
  62. end
  63. function TaskNewBaseView:LoadSuccess()
  64. self.sub_conta = self:GetChild("SubElement")
  65. local select_callback = function(index)
  66. self:SeletedTabbar(index)
  67. end
  68. local closeWin_callback = function()
  69. self:Close()
  70. end
  71. self.tabWindowComponent = TabWindowComponent.New(self.transform,"主线任务",self.tab_name_list,1264,632,306,52,
  72. select_callback,closeWin_callback,Vector3(0,0,0),self.background_wnd,"task_asset")
  73. end
  74. function TaskNewBaseView:InitEvent()
  75. local close_fun = function ()
  76. self:Close()
  77. end
  78. self.event_id = self.model:Bind(TaskEvent.CLOSE_TASK_VIEW, close_fun)
  79. end
  80. function TaskNewBaseView:Remove()
  81. if self.event_id then
  82. self.model:UnBind(self.event_id)
  83. self.event_id = nil
  84. end
  85. for i, view in pairs(self.contaner_list) do
  86. view:DeleteMe()
  87. end
  88. self.contaner_list = nil
  89. if self.tabWindowComponent then
  90. self.tabWindowComponent:DeleteMe()
  91. end
  92. self.tabWindowComponent = nil
  93. end
  94. function TaskNewBaseView:SeletedTabbar(index)
  95. local current_index = self.tabWindowComponent:GetCurrentSelectIndex()
  96. if current_index == index then
  97. return
  98. end
  99. local real_index = self:GetRealTabIndex(index)
  100. if real_index == 4 then
  101. if RoleManager.Instance.mainRoleInfo.guild_id <= 0 then
  102. Message.show(string.format("请先加入一个社团"))
  103. return
  104. end
  105. end
  106. self.select_tab = index
  107. if self.tabWindowComponent ~= nil then
  108. self.tabWindowComponent:SetTabBarIndex(self.select_tab)
  109. self:SwitchBar()
  110. end
  111. end
  112. function TaskNewBaseView:SwitchBar()
  113. local index = self.tabWindowComponent:GetCurrentSelectIndex()
  114. local chile_view = self.contaner_list[index]
  115. local viewIndex,viewName = self.show_tabs[index].index,self.show_tabs[index].view
  116. local taskType = self:GetTaskTypeByIndex(viewIndex)
  117. local config = Config.ConfigTaskEffect.Tabbuttons[viewIndex]
  118. if config then
  119. self.tabWindowComponent:SetTitle(config.name)
  120. end
  121. if chile_view == nil then
  122. local viewModule = viewName
  123. chile_view = viewModule.New(self.sub_conta)
  124. self.contaner_list[index] = chile_view
  125. end
  126. chile_view:SetData(taskType,self.task_id,self.parent_index,self.sub_index)
  127. self.task_id = false
  128. self.parent_index = false
  129. self.sub_index = false
  130. self:PopUpChild(chile_view)
  131. end
  132. function TaskNewBaseView:GetRealTabIndex(index)
  133. for i,v in ipairs(self.show_tabs) do
  134. if v.index == index then
  135. return i
  136. end
  137. end
  138. return 1
  139. end
  140. function TaskNewBaseView:GetTaskTypeByIndex( index )
  141. local task_type
  142. if index == 1 then
  143. task_type = TaskType.MAIN_LINE
  144. elseif index == 2 then
  145. task_type = TaskType.EXTENSION_LINE
  146. elseif index == 3 then
  147. task_type = TaskType.BOUNTY_LINE
  148. elseif index == 4 then
  149. task_type = TaskType.GUILD_LINE
  150. elseif index == 5 then
  151. task_type = TaskType.TRUN_LINE
  152. end
  153. return task_type
  154. end