源战役客户端
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

337 lines
13 KiB

  1. --单人副本进入界面
  2. ArenaView = ArenaView or BaseClass(BaseView)
  3. local ArenaView = ArenaView
  4. -----------------------扩展模块需要修改的地方--------------------------
  5. ArenaView.Tab_list = {
  6. [1] = {id = ArenaConst.TabId.PKRANK, name = "竞技联赛", light_res = "icon_jn1_1", dark_res = "icon_jn1_2", view = "PkRankSubView", bg = "pkrank_bg"},
  7. [2] = {id = ArenaConst.TabId.ENDLESS, name = "无尽领域", light_res = "icon_jn1_1", dark_res = "icon_jn1_2", view = "EndlessSubView", bg = "endless_sub_bg"},
  8. -- [3] = {id = ArenaConst.TabId.CSGWAR, name = "国战", light_res = "icon_jn1_1", dark_res = "icon_jn1_2", view = "CSGWarSubView", bg = "window_bg_5"},
  9. [3] = {id = ArenaConst.TabId.WASTELAND, name = "饥饿游戏", light_res = "icon_jn1_1", dark_res = "icon_jn1_2", view = "WastelandSubView", bg = "wasteland_bg"},
  10. [4] = {id = ArenaConst.TabId.RAGEWAR, name = "狂战领域", light_res = "icon_jn1_1", dark_res = "icon_jn1_2", view = "RageWarSubView", bg = "arena_ragewar_bg"},
  11. [5] = {id = ArenaConst.TabId.CLOTHINGVOTE, name = "明日之星", light_res = "icon_jn1_1", dark_res = "icon_jn1_2", view = "ClothingVoteApplyView", bg = "clothing_vote_bg_1"},
  12. }
  13. ArenaView.clothing_vot_tab_list = {
  14. [1] = {id = ArenaConst.TabId.CLOTHINGVOTE, name = "明日之星", light_res = "icon_jn1_1", dark_res = "icon_jn1_2", view = "ClothingVoteApplyView", bg = "clothing_vote_bg_1"},
  15. [2] = {id = ArenaConst.TabId.CLOTHINGVOTE, name = "明日之星", light_res = "icon_jn1_1", dark_res = "icon_jn1_2", view = "ClothingVoteVotingView", bg = "clothing_vote_bg_3"},
  16. }
  17. -- ArenaView.Index2View = {
  18. -- [1] = {id = 1,view = "PkRankSubView"},
  19. -- [2] = {id = 3,view = "EndlessSubView"},
  20. -- [3] = {id = 5,view = "PkBattleEnterView"},
  21. -- [4] = {id = 4,view = "LeagueWarEnterView"},
  22. -- [5] = {id = 6,view = "CSPvPMainView"},
  23. -- [6] = {id = 7,view = "DiamondFightEnterView"},
  24. -- [7] = {id = 8,view = "CSOnevNEnterView"},
  25. -- [8] = {id = 9,view = "SpiritWarEnterView"},
  26. -- }
  27. -- ArenaView.Index2Name = {
  28. -- [1] = {id = 1,name = "竞技场",light_res = "icon_jjc1_1",dark_res = "icon_jjc1_2"},
  29. -- [2] = {id = 3,name = "巅峰竞技",light_res = "icon_dld1_1",dark_res = "icon_dld1_2"},
  30. -- [3] = {id = 5,name = "丛林突围",light_res = "icon_dld_h",dark_res = "icon_dld_p"},
  31. -- [4] = {id = 4,name = "三英会战",light_res = "icon_sx1_1",dark_res = "icon_sx1_2"},
  32. -- [5] = {id = 6,name = "跨服3V3",light_res = "icon_dld1_1",dark_res = "icon_dld1_2"},
  33. -- [6] = {id = 7,name = "彩钻大战",light_res = "icon_zs1_1",dark_res = "icon_zs1_2"},
  34. -- [7] = {id = 8,name = "跨服1vN",light_res = "icon_dld1_1",dark_res = "icon_dld1_2"},
  35. -- [8] = {id = 9,name = "星灵争霸",light_res = "icon_dld1_1",dark_res = "icon_dld1_2"},
  36. -- }
  37. function ArenaView:InitEvent()
  38. local function onRefreshTabDot()
  39. self:ShowTabRedPointState()
  40. end
  41. -- self:BindEvent(PkRankModel:getInstance(), PkRankModel.UPDATE_TAB_DOT, onRefreshTabDot)
  42. self:BindEvent(self.model, ArenaConst.ANS_ARENA_UPDATE_RED_DOT, onRefreshTabDot)
  43. --41600 明日之星切换阶段
  44. local function on_update_clothing_view()
  45. --重新初始化一下,更新tab信息,并重新打开明日之星界面
  46. self:InitTabList()
  47. --先把明日之星界面给清掉
  48. if self.contaner_list[ArenaConst.TabId.CLOTHINGVOTE] then
  49. self.contaner_list[ArenaConst.TabId.CLOTHINGVOTE]:DeleteMe()
  50. self.contaner_list[ArenaConst.TabId.CLOTHINGVOTE] = nil
  51. end
  52. --如果是当前在这个明日之星界面,重新open一下
  53. if self.select_index == ArenaConst.TabId.CLOTHINGVOTE then
  54. if ClothingVoteModel:getInstance().vote_stage == 0 then--活动状态变成0,不能打开界面
  55. self:Open(ArenaConst.TabId.PKRANK)
  56. else
  57. self:Open(ArenaConst.TabId.CLOTHINGVOTE)
  58. end
  59. end
  60. end
  61. self:BindEvent(ClothingVoteModel, ClothingVoteConst.INTO_CLOTHING_VOTE_NEXT_STAGE, on_update_clothing_view)
  62. self:BindEvent(ClothingVoteModel, ClothingVoteConst.UPDATE_CLOTHING_VOTE_SUB_VIEW, on_update_clothing_view)
  63. end
  64. function ArenaView:Remove()
  65. if self.refresh_red_point_id then
  66. self.model:UnBind(self.refresh_red_point_id)
  67. self.refresh_red_point_id = nil
  68. end
  69. for i, view in pairs(self.contaner_list) do
  70. view:DeleteMe()
  71. end
  72. if self.tabWindowComponent then
  73. self.tabWindowComponent:DeleteMe()
  74. self.tabWindowComponent = nil
  75. end
  76. self.contaner_list = nil
  77. end
  78. ----------------------------------------------------------------
  79. function ArenaView:__init()
  80. self.base_file = "arena"
  81. self.layout_file = "ArenaView"
  82. self.layer_name = "UI"
  83. self.append_to_ctl_queue = true
  84. self.use_background = true
  85. self.hide_maincancas = true
  86. self.change_scene_close = true
  87. self.show_tabs = {}
  88. self.tab_name_list = {}
  89. self.contaner_list = {}
  90. self.close_fog = true
  91. --self.click_bg_toClose = true
  92. -- self.blur_activity_bg = true
  93. -- self.use_show_anim = true
  94. -- self.use_hide_anim = true
  95. self.model = ArenaModel:getInstance()
  96. self:InitTabList()
  97. self.load_callback = function ()
  98. self:LoadSuccess()
  99. self:InitEvent()
  100. end
  101. self.open_callback = function ()
  102. self:SeletedTabbar(self.select_index, true)
  103. end
  104. self.close_callback = function ()
  105. self:Remove()
  106. end
  107. end
  108. function ArenaView:InitTabList( )
  109. self.show_tabs = {}
  110. self.tab_name_list = {}
  111. local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
  112. local playerLv = RoleManager:getInstance():GetMainRoleVo().level
  113. for i,v in ipairs(ArenaView.Tab_list) do
  114. --判断明日之星应该用哪个界面
  115. if i == ArenaConst.TabId.CLOTHINGVOTE then
  116. local clothing_vote_stage = ClothingVoteModel:getInstance():GetClothingVoteStage()
  117. if clothing_vote_stage <= 1 then
  118. v = ArenaView.clothing_vot_tab_list[1]
  119. else
  120. v = ArenaView.clothing_vot_tab_list[2]
  121. end
  122. end
  123. if i == ArenaConst.TabId.CLOTHINGVOTE then
  124. if ClothingVoteModel:getInstance():CanClothingVoteOpen() then
  125. table.insert(self.show_tabs, v)
  126. table.insert(self.tab_name_list, v)
  127. end
  128. else
  129. if Config.ViewTabbarOpenLevel.Arena[i].open_level <= playerLv and Config.ViewTabbarOpenLevel.Arena[i].open_day <= open_day then
  130. if not ClientConfig.alpha_mode or (ClientConfig.alpha_mode and (i == 1)) then
  131. table.insert(self.show_tabs, v)
  132. table.insert(self.tab_name_list, v)
  133. -- elseif i == ArenaConst.TabId.CLOTHINGVOTE and ClothingVoteModel:getInstance():CanClothingVoteOpen() then
  134. -- --某个服务器开服天数不到要求但也必须开启靓丽大赛的情况
  135. -- table.insert(self.show_tabs, v)
  136. -- table.insert(self.tab_name_list, v)
  137. end
  138. end
  139. end
  140. end
  141. end
  142. function ArenaView:Open(index)
  143. index = self:GetRealTabIndex(index or 1)
  144. self.select_index = index or 1
  145. if self.select_index == ArenaConst.TabId.CLOTHINGVOTE then--判断如果是明日之星界面,而活动状态是0,不允许打开界面
  146. if ClothingVoteModel:getInstance().vote_stage == 0 then
  147. index = ArenaConst.TabId.PKRANK
  148. self.select_index = index
  149. end
  150. else
  151. --这里是原来的逻辑
  152. if #self.show_tabs == 0 or not self.show_tabs[self.select_index] then
  153. Message.show("活动暂未开启~")
  154. logWarn("ArenaView:Open=>Try to open a index that is not opened 1")
  155. return
  156. end
  157. end
  158. BaseView.Open(self)
  159. end
  160. function ArenaView:ReOpen(index)
  161. index = self:GetRealTabIndex(index or 1)
  162. self.select_index = index or 1
  163. if self.select_index == ArenaConst.TabId.CLOTHINGVOTE then--判断如果是明日之星界面,而活动状态是0,不允许打开界面
  164. if ClothingVoteModel:getInstance().vote_stage == 0 then
  165. index = ArenaConst.TabId.PKRANK
  166. self.select_index = index
  167. end
  168. else
  169. --这里是原来的逻辑
  170. if #self.show_tabs == 0 or not self.show_tabs[self.select_index] then
  171. Message.show("活动暂未开启~")
  172. logWarn("ArenaView:Open=>Try to open a index that is not opened 2 ")
  173. return
  174. end
  175. end
  176. self:SeletedTabbar(self.select_index, true)
  177. self:ShowTabRedPointState()
  178. end
  179. function ArenaView:LoadSuccess()
  180. self.winCon = self:GetChild("winCon")
  181. local select_callback = function(index)
  182. self:SeletedTabbar(index)
  183. self:ShowTabRedPointState()
  184. end
  185. local closeWin_callback = function()
  186. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_PKRANK,3)
  187. if helpVo or GuideModel:getInstance().need_force_do_task then
  188. GuideModel:getInstance().need_force_do_task = false
  189. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK)
  190. end
  191. self:Close()
  192. end
  193. self.tabWindowComponent = UITabWindow.New(self.transform,self.tab_name_list,select_callback,closeWin_callback,self.background_wnd,self.winCon, UITabWindow.SizeSmallHall, false,nil,true)
  194. self.tabWindowComponent:SetTitleText("联赛")
  195. -- self.tabWindowComponent:SetBackgroundRes("default_bg_6")
  196. -- self.tabWindowComponent = TabWindowComponent.New(self.transform,"战场竞技",self.tab_name_list,1264,632,306,52,
  197. -- select_callback,closeWin_callback,Vector3(0,-5,0),self.background_wnd,"arena_asset")
  198. end
  199. function ArenaView:SeletedTabbar(index, force)
  200. local last_select_index = self.select_index or 1
  201. if self.select_index == index and not force then
  202. return
  203. end
  204. self.select_index = index
  205. if index == ArenaConst.TabId.CLOTHINGVOTE and ClothingVoteModel:getInstance().vote_stage == 0 then
  206. index = last_select_index
  207. self.select_index = index
  208. if ClothingVoteModel:getInstance().vote_round > 0 then
  209. Message.show("活动正在结算中,请稍后再来吧~")
  210. else
  211. Message.show("明日之星活动尚未开启~")
  212. end
  213. end
  214. if self.tabWindowComponent ~= nil then
  215. self.tabWindowComponent:SetTabBarIndex(index)
  216. self:SwitchBar()
  217. end
  218. end
  219. function ArenaView:GetRealTabIndex(index)
  220. return index
  221. -- for i,v in ipairs(self.show_tabs) do
  222. -- if v.index == index then
  223. -- return i
  224. -- end
  225. -- end
  226. end
  227. function ArenaView:ShowTabRedPointState()
  228. self.tabWindowComponent:ShowRedPoint(ArenaConst.TabId.PKRANK, PkRankModel:getInstance():PkRankModelCheckRedDot(false))
  229. self.tabWindowComponent:ShowRedPoint(ArenaConst.TabId.ENDLESS, EndlessModel:getInstance():CheckEndlessRedDot())
  230. self.tabWindowComponent:ShowRedPoint(ArenaConst.TabId.WASTELAND, WastelandModel:getInstance():CheckWastelandRedDot())
  231. -- local csgwar_red_data = CSGWarModel:getInstance():GetCSGWarRedData()
  232. -- local csgwar_red = csgwar_red_data.one_red or csgwar_red_data.support_red or csgwar_red_data.fight_red or csgwar_red_data.occupy_red
  233. -- self.tabWindowComponent:ShowRedPoint(ArenaConst.TabId.CSGWAR, csgwar_red)
  234. self.tabWindowComponent:ShowRedPoint(ArenaConst.TabId.CLOTHINGVOTE, ClothingVoteModel:getInstance():GetClothingVoteMainRed())
  235. end
  236. function ArenaView:SwitchBar()
  237. local id = self.tabWindowComponent:GetCurrentSelectIndex()
  238. local cfg = self:GetTabConfigById(id)
  239. if not cfg then
  240. print("[ArenaView 185]=> error !! tab cfg is nil, id: ",id)
  241. return
  242. end
  243. self.tabWindowComponent:SetUIBack(
  244. {
  245. target = self,
  246. bg1 = GameResPath.GetViewBigBg(cfg.bg),
  247. })
  248. --self.tabWindowComponent:SetBackgroundRes(cfg.bg)
  249. local chile_view = self.contaner_list[id]
  250. if not chile_view then
  251. local viewModule = cfg
  252. if viewModule then
  253. chile_view = _G[viewModule.view].New(self.winCon)
  254. self.contaner_list[id] = chile_view
  255. end
  256. end
  257. if chile_view then
  258. if id == ArenaConst.TabId.CSGWAR
  259. or id == ArenaConst.TabId.CLOTHINGVOTE
  260. then
  261. chile_view:AppendToBackContainer(self)
  262. end
  263. if chile_view.SetData then
  264. chile_view:SetData(self.skill_type,self.auto_click)
  265. if self.skill_type then --生活技能特殊处理
  266. local is_live_skill = cfg.id == 4
  267. if is_live_skill then
  268. self.skill_type = false
  269. self.auto_click = false
  270. end
  271. end
  272. end
  273. self:PopUpChild(chile_view)
  274. if id == ArenaConst.TabId.CLOTHINGVOTE then--重新打开界面后再刷一次模型
  275. chile_view:SetData()
  276. end
  277. end
  278. if id == ArenaConst.TabId.PKRANK then
  279. local model = PkRankModel.getInstance()
  280. if model.is_god_fight then
  281. model.is_god_fight = false
  282. model:Fire(PkRankModel.OPEN_GOD_VIEW)
  283. end
  284. end
  285. end
  286. function ArenaView:GetTabConfigById( id )
  287. local cfg
  288. for k,v in pairs(self.show_tabs) do
  289. if v.id == id then
  290. cfg = v
  291. break
  292. end
  293. end
  294. return cfg
  295. end