源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

621 linhas
26 KiB

  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 跨服社团排行玩法场景界面
  4. -- *>
  5. GuildCSGRSceneView = GuildCSGRSceneView or BaseClass(BaseView)
  6. local GuildCSGRSceneView = GuildCSGRSceneView
  7. function GuildCSGRSceneView:__init()
  8. self.base_file = "guildCSGR"
  9. self.layout_file = "GuildCSGRSceneView"
  10. self.layer_name = "Main"
  11. self.destroy_imm = true
  12. self.use_background = false --全屏界面默认使用这个参数,非全屏界面自行设置
  13. self.change_scene_close = false --是否切换场景时关闭(弹出界面使用)
  14. self:AddPreLoadList("guildCSGR", {"GuildCSGRSceneRankItem"})
  15. self.init_exit_btn = false
  16. self.trigger_collect_guide = false -- 是否触发了采集引导
  17. self.tab_index = 1 -- 选项卡index
  18. self.auto_switch_tab = {} -- 记录强制切换过页签
  19. self.collect_cfg_data = nil -- 战场采集物配置信息
  20. self.boss_position = nil -- 战场boss坐标
  21. self.info_list = {} -- 右侧信息节点
  22. self.had_show_collect_dialogue = false -- 是否已经显示了左侧采集对话小窗
  23. self.had_show_assult_dialogue = false -- 是否已经显示了左侧围攻对话小窗
  24. self.had_show_boss_alert = false -- 是否弹出过boss预警
  25. self.info_rank_item = {} -- 右侧信息节点中的排行节点
  26. self.rank_data = {} -- 服务端推送的排行信息
  27. self.extra_con_type = 1 -- 额外信息内容类型 1:采集物 2:排行榜
  28. self.rightIcon_tween = {} -- 右上角动画列表
  29. -- 采集阶段参数
  30. self.auto_collect = false -- 第二阶段中是否自动采集
  31. self.model = GuildModel:getInstance()
  32. self.scene = Scene.Instance
  33. self.load_callback = function ()
  34. self:LoadSuccess()
  35. self:AddEvent()
  36. -- 请求采集相关信息
  37. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41003)
  38. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41004)
  39. -- 请求排行相关信息
  40. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41006)
  41. end
  42. self.open_callback = function ( )
  43. self:UpdateView()
  44. self:ShowInfoCon(not MainUIModel:getInstance():GetDialogueActionFlag(), true)
  45. end
  46. self.destroy_callback = function ( )
  47. self:DestroySuccess()
  48. end
  49. end
  50. function GuildCSGRSceneView:Open( )
  51. --self.data = data
  52. BaseView.Open(self)
  53. end
  54. function GuildCSGRSceneView:LoadSuccess()
  55. local nodes = {
  56. "con:img:cg",
  57. "rank_btn:obj",
  58. -- 最右侧信息节点
  59. -- 选项卡
  60. "con/tab_con/tab_selected:obj:img",
  61. "con/tab_con/tab_1_lb:obj:tmp",
  62. "con/tab_con/tab_2_lb:obj:tmp",
  63. -- 采集相关
  64. -- "con/collect_scroll:obj",
  65. -- "con/collect_scroll/Viewport/collect_con",
  66. "con/collect_con:obj",
  67. "con/collect_con/collect_tip:tmp",
  68. "con/collect_con/collect_effect_con",
  69. -- 排行相关
  70. "con/rank_con:obj",
  71. "con/rank_con/boss_click:obj",
  72. "con/rank_con/boss_hp:img",
  73. "con/rank_con/r_item_node",
  74. "con/rank_con/r_my_rank:tmp",
  75. "con/rank_con/boss_name:tmp",
  76. "con/rank_con/boss_hp_pec:tmp",
  77. "con/rank_con/other_data_click_tip:obj",
  78. -- 额外信息节点
  79. "con/other_con:obj",
  80. "con/other_con/close_btn:obj", -- 额外信息节点关闭按钮
  81. "con/other_con/buff_con",
  82. "con/other_con/other_desc:tmp",
  83. -- 活动结束时间
  84. "con/event_time:tmp",
  85. -- 功能按钮
  86. "func_btn_con",
  87. "func_btn_con/func_btn_collect:obj:img",
  88. "func_btn_con/func_btn_call:obj",
  89. "func_btn_con/func_btn_assult:obj",
  90. "func_btn_con/func_btn_collect/func_btn_collect_lb:tmp",
  91. "func_btn_con/func_btn_call/func_btn_call_lb:tmp",
  92. "func_btn_con/func_btn_assult/func_btn_assult_lb:tmp",
  93. }
  94. self:GetChildren(nodes)
  95. lua_resM:setOutsideImageSprite(self, self.con_img, GameResPath.GetViewBigBg("common_right_top_img2"))
  96. -- 绑定到退出按钮应该有的位置上去
  97. GlobalEventSystem:Fire(EventName.MOVE_NODE_EXIT_CON, self.rank_btn, self.transform, "rank_btn", 1)
  98. -- 提前设置一次文本
  99. self.func_btn_collect_lb_tmp.text = "采集物资"
  100. self.func_btn_call_lb_tmp.text = "召唤社员"
  101. self.func_btn_assult_lb_tmp.text = "进攻图腾"
  102. -- 设置界面大小和位置
  103. SetSizeDelta(self.transform, 0, 0)
  104. -- 设置刘海屏offset
  105. if ClientConfig.iphone_x_model then
  106. -- self.transform.offsetMin = Vector2(ClientConfig.iphone_x_offset_left,0)
  107. -- self.transform.offsetMax = Vector2(-ClientConfig.iphone_x_offset_right,0)
  108. end
  109. -- 隐藏额外信息界面
  110. self.other_con_obj:SetActive(false)
  111. if not self.init_exit_btn then
  112. self.init_exit_btn = true
  113. local function call_back( ... )
  114. local function ok( ... )
  115. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41002, 1)
  116. end
  117. local ask_str = "是否确定退出当前场景?"
  118. Alert.show(ask_str,Alert.Type.Two,ok,nil,"确定","取消")
  119. end
  120. local data = {call_back = call_back, pos = {x = 202, y = 277}} -- pos 为左侧侧边栏的长度
  121. GlobalEventSystem:Fire(EventName.SHOW_EXIT_BTN_STATE, data)
  122. end
  123. -- 添加采集引导
  124. GuideController.Instance:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE, 410000000)
  125. end
  126. function GuildCSGRSceneView:AddEvent()
  127. local function click_event(target)
  128. if target == self.tab_1_lb_obj then -- 选项卡1
  129. self:SwitchCSGRDataTab(1)
  130. elseif target == self.tab_2_lb_obj then -- 选项卡2
  131. self:SwitchCSGRDataTab(2)
  132. elseif target == self.rank_btn_obj then -- 排行榜按钮
  133. self.model:Fire(GuildModel.OPEN_CSGR_RANK_VIEW, true)
  134. elseif target == self.close_btn_obj then -- 关闭额外信息界面
  135. self.other_con_obj:SetActive(false)
  136. elseif target == self.boss_click_obj or target == self.func_btn_assult_obj then -- 阶段2要前往boss
  137. self:CSGRFindWayToBoss()
  138. elseif target == self.func_btn_collect_obj then
  139. self:OnCollectBtnClick(not self.auto_collect)
  140. elseif target == self.func_btn_call_obj then -- 呼叫社团成员
  141. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 40064, 410)
  142. elseif target == self.other_data_click_tip_obj then -- 弹出额外信息小窗
  143. self.other_con_obj:SetActive(true)
  144. end
  145. end
  146. AddClickEvent(self.tab_1_lb_obj, click_event)
  147. AddClickEvent(self.tab_2_lb_obj, click_event)
  148. AddClickEvent(self.rank_btn_obj, click_event)
  149. AddClickEvent(self.close_btn_obj, click_event)
  150. AddClickEvent(self.boss_click_obj, click_event)
  151. AddClickEvent(self.func_btn_assult_obj, click_event)
  152. AddClickEvent(self.func_btn_collect_obj, click_event)
  153. AddClickEvent(self.func_btn_call_obj, click_event)
  154. AddClickEvent(self.other_data_click_tip_obj, click_event)
  155. -- local function onOrientationChange()
  156. -- if self.transform then
  157. -- if ClientConfig.iphone_x_model then
  158. -- -- self.transform.offsetMin = Vector2(ClientConfig.iphone_x_offset_left,0)
  159. -- -- self.transform.offsetMax = Vector2(-ClientConfig.iphone_x_offset_right,0)
  160. -- end
  161. -- end
  162. -- end
  163. -- self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)--位置适配
  164. local function hide_dialogue_cur_xy_node()--隐藏当前和对话框重叠位置的节点
  165. self:ShowInfoCon(false)
  166. end
  167. local function show_dialogue_cur_xy_node()--显示当前和对话框重叠位置的节点
  168. self:ShowInfoCon(true)
  169. end
  170. self:BindEvent(GlobalEventSystem, EventName.START_COM_DIALOGUE_SHOW_ANIM, hide_dialogue_cur_xy_node)
  171. self:BindEvent(GlobalEventSystem, EventName.FINISHED_COM_DIALOGUE_SHOW_ANIM, show_dialogue_cur_xy_node)
  172. -- 活动跨阶段更新
  173. local function update_event_data(event_type)
  174. if not event_type or event_type == GuildEventType.GuildCSGR then
  175. self.event_data = self.model:GetGuildEventByType(GuildEventType.GuildCSGR)
  176. self:UpdateInfoShowCon()
  177. self:UpdateEventCountdown()
  178. end
  179. end
  180. self:BindEvent(self.model, GuildModel.UPDATE_GUILD_EVENT_BY_TYPE, update_event_data)
  181. -- 更新采集数据
  182. local function update_collect_buff()
  183. self:UpdateCSGRStatusTips()
  184. end
  185. self:BindEvent(self.model, GuildModel.UPDATE_CSGR_BF_RES, update_collect_buff)
  186. -- 更新排行数据
  187. local function update_rank_data(vo)
  188. self.rank_data = vo
  189. -- 先更新最右侧的展示内容
  190. self:UpdateRankItem()
  191. end
  192. self:BindEvent(self.model, GuildModel.UPDATE_CSGR_SCENE_DMG_RANK, update_rank_data)
  193. local function update_boss_hp(monsterHp, maxHp, percentage)
  194. self:UpdateBossHp(monsterHp, maxHp, percentage)
  195. end
  196. self:BindEvent(self.model, GuildModel.UPDATE_CSGR_BOSS_HP, update_boss_hp)
  197. -- 绑定界面移动动画
  198. self:BindLittleMove(self.con, BaseView.LittleMoveDir.Left, 1.5)
  199. self:BindLittleMove(self.func_btn_con, BaseView.LittleMoveDir.Bottom, 147.5)
  200. -- 主界面聊天展开事件
  201. self:BindMainUIExpandEvent( self.func_btn_con )
  202. end
  203. function GuildCSGRSceneView:UpdateView()
  204. self.event_data = self.model:GetGuildEventByType(GuildEventType.GuildCSGR)
  205. self:UpdateBasicData()
  206. -- 默认切换到页签1
  207. self:SwitchCSGRDataTab(1)
  208. -- 更新排行信息
  209. self:UpdateRankItem()
  210. -- 修改展示的内容
  211. self:UpdateInfoShowCon()
  212. -- 加载活动倒计时
  213. self:UpdateEventCountdown()
  214. -- 更新采集物信息
  215. self:UpdateCollectionItem()
  216. end
  217. -- 加载一些基础信息
  218. function GuildCSGRSceneView:UpdateBasicData( )
  219. self.collect_tip_tmp.text = "采集物资,提升社团整体增益"
  220. self.other_desc_tmp.text = "进攻图腾,社团伤害排名越高,奖励越好"
  221. local mon_id = Config.Campwarkv["boss_id"].val
  222. self.boss_name_tmp.text = Trim(ConfigItemMgr.Instance:GetMonsterDataItem(mon_id).name)
  223. end
  224. -- 切换页签表现
  225. function GuildCSGRSceneView:SwitchCSGRDataTab(tab_index)
  226. self.tab_index = tab_index
  227. self.tab_1_lb_tmp.color = ColorUtil:ConvertHexToRGBColor(self.tab_index == 1 and "FFFFFF" or "9EB3CF")
  228. self.tab_2_lb_tmp.color = ColorUtil:ConvertHexToRGBColor(self.tab_index == 2 and "FFFFFF" or "9EB3CF")
  229. SetAnchoredPosition(self.tab_selected, self.tab_index == 1 and -49 or 49, 0)
  230. self.collect_con_obj:SetActive(self.tab_index == 1)
  231. self.rank_con_obj:SetActive(self.tab_index == 2)
  232. end
  233. -- 更新顶部横幅
  234. function GuildCSGRSceneView:UpdateCSGRStatusTips( )
  235. if self.event_data then
  236. -- 确定阶段
  237. local is_waiting = self.event_data.status == 1
  238. local is_collecting = self.event_data.status == 2
  239. local is_assulting = self.event_data.status == 3
  240. -- 更新横幅
  241. if is_waiting then -- 候场阶段
  242. local show_time = self.event_data.next_time - TimeUtil:getServerTime()
  243. local str = "备战入场时间 %s"
  244. local special_tip_data = {
  245. type = SpecialTipType.Timer2,
  246. sepeical_str = str,
  247. need_flash = false,
  248. show_time = show_time > 0 and show_time or 0,
  249. belong_key = "guildCSGR",
  250. }
  251. CommonController.Instance:Fire(EventName.OPEN_SPECIALTIPVIEW, special_tip_data)
  252. elseif is_collecting then -- 采集阶段
  253. local next_time = self.model:GetCSGRBattlefieldResRefreshTime()
  254. local str = next_time and next_time ~= 0
  255. and "下一批物资刷新%s"
  256. or "物资采集阶段剩余%s"
  257. -- 如果存在next_time不等于0的情况则代表还有下一轮的刷新,否则横幅调整为采集阶段的剩余时间
  258. local stage_end_time = next_time and next_time ~= 0 and next_time or self.event_data.next_time
  259. local special_tip_show_time = next_time and next_time ~= 0 and 10 or 30
  260. local function delay_special_tip_func()
  261. local left_time = stage_end_time - TimeUtil:getServerTime()
  262. if left_time <= special_tip_show_time then -- 倒计时剩下n秒才弹出采集刷新横幅 或 采集阶段刷新横幅
  263. local special_tip_data = {
  264. type = SpecialTipType.Timer2,
  265. sepeical_str = str,
  266. need_flash = false,
  267. show_time = left_time,
  268. belong_key = "guildCSGR",
  269. }
  270. CommonController.Instance:Fire(EventName.OPEN_SPECIALTIPVIEW, special_tip_data)
  271. self:ClearDelaySpecialTipId()
  272. end
  273. end
  274. self:ClearDelaySpecialTipId()
  275. self.delay_special_tip_id = GlobalTimerQuest:AddPeriodQuest(delay_special_tip_func, 0.2, -1)
  276. -- 采集引导
  277. if not self.trigger_collect_guide then
  278. self:AddGuideToCollectBtn()
  279. self.trigger_collect_guide = true
  280. end
  281. -- 左侧对话tips
  282. if not self.had_show_collect_dialogue then
  283. local dialogue_data = {
  284. head_type = 1000 + RoleManager.Instance.mainRoleInfo.career,
  285. desc = "物资采集开始了!采集的越多,社团增益越强!",
  286. head_name = "战场指挥官",
  287. hide_time = 5,
  288. dalay_time = 0.1,
  289. is_task_type = false,
  290. }
  291. GlobalEventSystem:Fire(EventName.SHOW_COM_DIALOGUE_SHOW_VIEW, dialogue_data)
  292. self.had_show_collect_dialogue = true
  293. end
  294. elseif is_assulting then
  295. -- 左侧对话tips
  296. if not self.had_show_assult_dialogue then
  297. local dialogue_data = {
  298. head_type = 1000 + RoleManager.Instance.mainRoleInfo.career,
  299. desc = "图腾降临了!对图腾伤害越高奖励越丰富!",
  300. head_name = "战场指挥官",
  301. hide_time = 5,
  302. dalay_time = 0.1,
  303. is_task_type = false,
  304. }
  305. GlobalEventSystem:Fire(EventName.SHOW_COM_DIALOGUE_SHOW_VIEW, dialogue_data)
  306. self.had_show_assult_dialogue = true
  307. end
  308. if not self.had_show_boss_alert then
  309. CommonController.Instance:Fire(EventName.OPEN_BOSS_ALERT_VIEW, true, 41000)
  310. self.had_show_boss_alert = true
  311. end
  312. if self.show_delay_id then
  313. GlobalTimerQuest:CancelQuest(self.show_delay_id)
  314. self.show_delay_id = nil
  315. end
  316. if self.auto_delete_delay_id then
  317. self:DeleteGuideToCollectBtn()
  318. end
  319. local function delay_exit_tip_func()
  320. local left_time = self.event_data.next_time - TimeUtil:getServerTime()
  321. -- if left_time <= 15 then -- 倒计时剩下15秒弹出退出场景
  322. if left_time <= 0 then -- 活动结束后,倒计时自动退出场景
  323. local exit_tips_data = {
  324. time = 15,
  325. time_str = "秒后",
  326. exit_desc = "自动退出战场",
  327. call_back = function()
  328. if SceneManager:getInstance():IsGuildCSGRScene() then
  329. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41002, 1)
  330. end
  331. end,
  332. }
  333. GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP, exit_tips_data)
  334. self:ClearDelayExitTipId()
  335. end
  336. end
  337. self:ClearDelayExitTipId()
  338. self.delay_exit_tip_id = GlobalTimerQuest:AddPeriodQuest(delay_exit_tip_func, 0.2, -1)
  339. delay_exit_tip_func()
  340. else
  341. CommonController.Instance:Fire(EventName.CLOSE_SPECIALTIPVIEW)
  342. end
  343. end
  344. end
  345. function GuildCSGRSceneView:ClearDelaySpecialTipId( )
  346. if self.delay_special_tip_id then
  347. GlobalTimerQuest:CancelQuest(self.delay_special_tip_id)
  348. self.delay_special_tip_id = nil
  349. end
  350. end
  351. function GuildCSGRSceneView:ClearDelayExitTipId( )
  352. if self.delay_exit_tip_id then
  353. GlobalTimerQuest:CancelQuest(self.delay_exit_tip_id)
  354. self.delay_exit_tip_id = nil
  355. end
  356. end
  357. -- 更新排行信息
  358. function GuildCSGRSceneView:UpdateRankItem( )
  359. local data, item
  360. local empty_tb = {is_empty = true}
  361. -- 加载前3的伤害排行
  362. for i = 1, 3 do
  363. -- 计算输出百分比需要跟第一名进行输出总量对比,所以每条列表数据都需要加上第一名的输出
  364. item = self.info_rank_item[i]
  365. if not item then
  366. item = GuildCSGRSceneRankItem.New(self.r_item_node)
  367. self.info_rank_item[i] = item
  368. end
  369. data = self.rank_data and self.rank_data.hurt_rank and self.rank_data.hurt_rank[i] or empty_tb,
  370. item:SetAnchoredPosition(0, (1-i) * 28.5 - 2.5)
  371. item:SetData(data, i)
  372. end
  373. -- 加载自己社团的排行
  374. self.r_my_rank_tmp.text = self.rank_data.my_guild_rank and self.rank_data.my_guild_rank ~= 0
  375. and string.format("我的社团:<color=%s>第%s名</color>", ColorUtil.GREEN_DARK, self.rank_data.my_guild_rank)
  376. or string.format("我的社团:<color=%s>未上榜</color>", ColorUtil.RED_DARK)
  377. end
  378. -- 根据当前的活动阶段调整展示右侧信息节点
  379. function GuildCSGRSceneView:UpdateInfoShowCon( )
  380. if self.event_data then
  381. -- 确定阶段
  382. local is_waiting = self.event_data.status == 1
  383. local is_collecting = self.event_data.status == 2
  384. local is_assulting = self.event_data.status == 3
  385. if not is_waiting and not is_collecting and not is_assulting then return end
  386. -- 显示或隐藏功能按钮
  387. self.func_btn_call_obj:SetActive(true) -- 召唤社员默认显示
  388. self.func_btn_collect_obj:SetActive(not is_assulting)
  389. self.func_btn_assult_obj:SetActive(is_assulting)
  390. self:SortFuncBtnPosition()
  391. if is_collecting then
  392. if not self.auto_switch_tab[1] then
  393. self:SwitchCSGRDataTab(1)
  394. self.auto_switch_tab[1] = true
  395. end
  396. self:OnCollectBtnClick(true)
  397. end
  398. if is_assulting then
  399. if not self.auto_switch_tab[2] then
  400. self:SwitchCSGRDataTab(2)
  401. self.auto_switch_tab[2] = true
  402. end
  403. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT) -- 进入围攻阶段就打开自动战斗
  404. self:UpdateBossHp(self.model:GetCSGRCurBossHp())
  405. end
  406. -- 围攻首领阶段才弹出排行按钮
  407. self.rank_btn_obj:SetActive(is_assulting)
  408. -- 更新界面顶部横幅内容
  409. self:UpdateCSGRStatusTips()
  410. end
  411. end
  412. -- 更新活动剩余倒计时
  413. function GuildCSGRSceneView:UpdateEventCountdown( )
  414. if self.event_data then
  415. local left_time
  416. local is_collecting = self.event_data.status == 2
  417. local is_assulting = self.event_data.status == 3
  418. -- 除了最终阶段,其他阶段都使用next_time作为阶段的倒计时
  419. local end_time = is_assulting and self.event_data.end_time or self.event_data.next_time
  420. local function countdown_func()
  421. left_time = end_time - TimeUtil:getServerTime()
  422. left_time = left_time > 0 and left_time or 0
  423. self.event_time_tmp.text = string.format("%s剩余时间:<color=%s>%s</color>",
  424. is_collecting and "采集" or "进攻",
  425. ColorUtil.GREEN_DARK, TimeUtil:convertTimeWithoutHour(left_time))
  426. if left_time <= 0 then
  427. self:ClearCountdownFuncId()
  428. end
  429. end
  430. self:ClearCountdownFuncId()
  431. self.countdown_func_id = GlobalTimerQuest:AddPeriodQuest(countdown_func, 0.5, -1)
  432. end
  433. end
  434. function GuildCSGRSceneView:ClearCountdownFuncId( )
  435. if self.countdown_func_id then
  436. GlobalTimerQuest:CancelQuest(self.countdown_func_id)
  437. self.countdown_func_id = nil
  438. end
  439. end
  440. -- 更新采集物信息
  441. function GuildCSGRSceneView:UpdateCollectionItem( )
  442. self.collect_cfg_data = self.model:GetCSGRCollectCfg()
  443. -- 右侧信息采集节点的采集物item节点
  444. self.collection_item_creator = self.collection_item_creator or self:AddUIComponent(UI.ItemListCreator)
  445. local info = {
  446. data_list = self.collect_cfg_data,
  447. item_con = self.collect_effect_con,
  448. scroll_view = self.collect_effect_con,
  449. item_class = GuildCSGRSceneCollectionItem,
  450. item_height = 31,
  451. create_frequency = 0.01,
  452. alignment = UnityEngine.TextAnchor.UpperLeft,
  453. on_update_item = function(item, i, v)
  454. item:SetData(v, true)
  455. end,
  456. }
  457. self.collection_item_creator:UpdateItems(info)
  458. -- 额外信息的buff展示item
  459. self.buff_item_creator = self.buff_item_creator or self:AddUIComponent(UI.ItemListCreator)
  460. local info = {
  461. data_list = self.collect_cfg_data,
  462. item_con = self.buff_con,
  463. scroll_view = self.buff_con,
  464. item_class = GuildCSGRSceneCollectionItem,
  465. item_height = 31,
  466. create_frequency = 0.01,
  467. alignment = UnityEngine.TextAnchor.UpperLeft,
  468. on_update_item = function(item, i, v)
  469. item:SetData(v, false)
  470. end,
  471. }
  472. self.buff_item_creator:UpdateItems(info)
  473. end
  474. -- 自动寻路前往boss坐标并自动挂机
  475. function GuildCSGRSceneView:CSGRFindWayToBoss( )
  476. if self.event_data and self.event_data.status == 3 then
  477. self.boss_position = self.boss_position or stringtotable(Config.Campwarkv["boss_position"].val)[1]
  478. if self.boss_position then
  479. local function call_back()
  480. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
  481. end
  482. local findVo = FindVo.New()
  483. findVo.type = FindVo.POINT
  484. findVo.x = self.boss_position[1] / SceneObj.LogicRealRatio.x
  485. findVo.y = self.boss_position[2] / SceneObj.LogicRealRatio.y
  486. findVo.sceneId = SceneManager:getInstance():GetSceneId()
  487. findVo.call_back = call_back
  488. GlobalEventSystem:Fire(EventName.FIND, findVo)
  489. end
  490. end
  491. end
  492. -- 更新boss血量信息
  493. function GuildCSGRSceneView:UpdateBossHp(monsterHp, maxHp, percentage)
  494. self.boss_hp_img.fillAmount = percentage
  495. self.boss_hp_pec_tmp.text = string.format("%.1f%%", percentage * 100)
  496. end
  497. function GuildCSGRSceneView:SortFuncBtnPosition( )
  498. local btn_list = {}
  499. if self.func_btn_assult_obj.activeSelf then
  500. btn_list[#btn_list + 1] = self.func_btn_assult
  501. end
  502. if self.func_btn_collect_obj.activeSelf then
  503. btn_list[#btn_list + 1] = self.func_btn_collect
  504. end
  505. if self.func_btn_call_obj.activeSelf then
  506. btn_list[#btn_list + 1] = self.func_btn_call
  507. end
  508. for i, v in ipairs(btn_list) do
  509. SetAnchoredPosition(v, (i-#btn_list/2)* 120 - 60, 5.5 + 4)
  510. end
  511. end
  512. function GuildCSGRSceneView:AddGuideToCollectBtn()
  513. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.GUILD_CSGR_COLLECT, 1)
  514. if not helpVo then return end
  515. local help_type = helpVo.help_type
  516. local step = helpVo.step
  517. local button = self.func_btn_collect_obj
  518. if not button then return end
  519. local function call_back()
  520. end
  521. -- 延时打开,防止按钮在动画中没有定对位置
  522. local function delay_show( )
  523. GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, self.transform, call_back, helpVo, self.layout_file)
  524. -- 自动销毁
  525. if not self.auto_delete_delay_id then
  526. local function delay_delete( )
  527. self:DeleteGuideToCollectBtn()
  528. end
  529. self.auto_delete_delay_id = setTimeout(delay_delete, 5)
  530. end
  531. end
  532. if not self.show_delay_id then
  533. self.show_delay_id = setTimeout(delay_show, 1.5)
  534. end
  535. end
  536. function GuildCSGRSceneView:DeleteGuideToCollectBtn( )
  537. -- 销毁引导表现
  538. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.GUILD_CSGR_COLLECT, 1)
  539. if helpVo then
  540. if helpVo.step == 1 then
  541. GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
  542. end
  543. end
  544. if self.auto_delete_delay_id then
  545. GlobalTimerQuest:CancelQuest(self.auto_delete_delay_id)
  546. self.auto_delete_delay_id = nil
  547. end
  548. end
  549. function GuildCSGRSceneView:OnCollectBtnClick(auto_collect)
  550. self:DeleteGuideToCollectBtn()
  551. if self.event_data and self.event_data.status == 2 and self.collect_cfg_data then
  552. self.auto_collect = auto_collect
  553. self.func_btn_collect_lb_tmp.text = self.auto_collect and "采集物资中..." or "采集物资"
  554. self.model:UpdateCSGRAutoCollectFlag(self.auto_collect)
  555. end
  556. end
  557. function GuildCSGRSceneView:ShowInfoCon(show, force)
  558. local target_alpha = show and 1 or 0
  559. if force then
  560. self.con_cg.alpha = target_alpha
  561. else
  562. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.con)
  563. local function action_alpha_callback(percent)
  564. self.con_cg.alpha = show and percent or (1 - percent)
  565. end
  566. local action_alpha = cc.CustomUpdate.New(0.3, action_alpha_callback)
  567. cc.ActionManager:getInstance():addAction(action_alpha, self.con)
  568. end
  569. end
  570. function GuildCSGRSceneView:DestroySuccess( )
  571. GlobalEventSystem:Fire(EventName.HIDE_EXIT_BTN_STATE) -- 隐藏
  572. -- GlobalEventSystem:Fire(EventName.MOVE_NODE_EXIT_CON, self.exit_btn, self.transform, "exit_btn", 2)
  573. GlobalEventSystem:Fire(EventName.MOVE_NODE_EXIT_CON, self.rank_btn, self.transform, "rank_btn", 2)
  574. for k, v in pairs(self.info_rank_item) do
  575. v:DeleteMe()
  576. v = nil
  577. end
  578. self.info_rank_item = nil
  579. self:ClearDelaySpecialTipId()
  580. self:ClearDelayExitTipId()
  581. self:ClearCountdownFuncId()
  582. if self.auto_delete_delay_id then
  583. GlobalTimerQuest:CancelQuest(self.auto_delete_delay_id)
  584. self.auto_delete_delay_id = nil
  585. end
  586. if self.show_delay_id then
  587. GlobalTimerQuest:CancelQuest(self.show_delay_id)
  588. self.show_delay_id = nil
  589. end
  590. GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP, nil, false)
  591. CommonController.Instance:Fire(EventName.CLOSE_SPECIALTIPVIEW)
  592. end