源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

775 line
30 KiB

  1. GuildSceneWarView = GuildSceneWarView or BaseClass(BaseView)
  2. local GuildSceneWarView = GuildSceneWarView
  3. function GuildSceneWarView:__init()
  4. self.base_file = "guildScene"
  5. self.layout_file = "GuildSceneWarView"
  6. self.layer_name = "Main"
  7. self.destroy_imm = true
  8. self.change_scene_close = false
  9. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  10. self.need_show_money = false --是否要显示顶部的金钱栏
  11. self.is_in_pick = false --当前的采集状态
  12. self.item_list = {}
  13. self.show_left_time_tip = false
  14. self.show_exit_time_tip = false
  15. self.wait_to_collect = false
  16. self.init_exit_btn = false
  17. self.project_cd_time = 0
  18. self.model = GuildModel:getInstance()
  19. self.load_callback = function ()
  20. self:LoadSuccess()
  21. self:AddEvent()
  22. end
  23. self.open_callback = function ( )
  24. self:UpdateView()
  25. end
  26. self.destroy_callback = function ( )
  27. self:DestroySuccess()
  28. end
  29. end
  30. function GuildSceneWarView:Open( )
  31. BaseView.Open(self)
  32. end
  33. function GuildSceneWarView:LoadSuccess()
  34. local nodes = {
  35. "left_info_con/data_con/exitBtn:obj",
  36. "rightIconCon/rankBtn:obj",
  37. "left_info_con/data_con/collect_info_con/my_score:tmp",
  38. "left_info_con/data_con/collect_info_con/leftTime:tmp",
  39. "left_info_con/data_con/collect_info_con/reward_scroll_collect",
  40. "left_info_con/data_con/collect_info_con/reward_scroll_collect/Viewport/reward_con_collect",
  41. "left_info_con/data_con/collect_info_con/boss_hp_percentage:tmp",
  42. "left_info_con/data_con/collect_info_con/boss_hp_r:img",
  43. "left_info_con/data_con/collect_info_con/boss_hp_r_bg:img",
  44. "left_info_con/data_con/collect_info_con/big_time:tmp",
  45. "left_info_con/data_con/collect_info_con/small_time:tmp",
  46. "broadcast_root/broadcast_bg:obj",
  47. "broadcast_root/broadcast_text:tmp",
  48. "broadcast_root:obj",
  49. "left_info_con/data_con/collect_info_con/escort_boss_1:obj",
  50. "left_info_con/data_con/collect_info_con/escort_boss_2:obj",
  51. "left_info_con/data_con/collect_info_con/escort_small_1:obj",
  52. "left_info_con/data_con/collect_info_con/escort_small_2:obj",
  53. "left_info_con/data_con/collect_info_con/escort_big_1:obj",
  54. "left_info_con/data_con/collect_info_con/escort_big_2:obj",
  55. "left_info_con/data_con/collect_info_con/boss_tips:tmp",
  56. "left_info_con/data_con/collect_info_con/boss_name:tmp",
  57. "rightIconCon:obj",
  58. "left_info_con:obj",
  59. "left_info_con/data_con/collect_info_con",
  60. "left_info_con/data_con/collect_info_con/reward_scroll_collect/Viewport/reward_con_collect/finish:obj",
  61. "left_info_con/data_con/collect_info_con/guide_tip_1/guide_tip_text_1:tmp",
  62. "left_info_con/data_con/collect_info_con/guide_tip_1:obj",
  63. "func_btn_con/find_boss_btn:obj",
  64. "func_btn_con/find_escort_btn:obj:img",
  65. "func_btn_con/escorting_text:tmp",
  66. "func_btn_con:obj",
  67. "func_btn_con/boss_state:img",
  68. "func_btn_con/protect_btn:obj",
  69. "func_btn_con/protect_btn/protect_cd_img:img",
  70. "func_btn_con/protect_btn/protect_cd_time:tmp",
  71. "func_btn_con/boss_tips_root:obj",
  72. "func_btn_con/boss_tips_root/lb_boss_tips:tmp",
  73. "left_info_con/data_con/collect_info_con/escort_small_2/escort_small_2_text:tmp",
  74. "left_info_con/data_con/collect_info_con/escort_big_2/escort_big_2_text:tmp",
  75. }
  76. self:GetChildren(nodes)
  77. --设置sceneView的自适应
  78. self.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight)
  79. SetAnchoredPosition(self.transform, 0, 0)
  80. self.boss_hp_r_img.gameObject:SetActive(false)
  81. self.boss_hp_r_bg_img.gameObject:SetActive(false)
  82. self.boss_hp_percentage_tmp.gameObject:SetActive(false)
  83. self.boss_name_tmp.gameObject:SetActive(false)
  84. self:ChangeUiPosition()
  85. --进场的时候,提示引导
  86. self:StartGuideAction()
  87. --护盾时间
  88. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40513)
  89. end
  90. function GuildSceneWarView:AddEvent()
  91. local function onBtnClickHandler(target)
  92. if target == self.exitBtn_obj then
  93. self.model:Fire(GuildModel.LEAVE_GUILD_WAR_SCENE)
  94. elseif target == self.rankBtn_obj then
  95. self.model:GuildWarSetRankList()
  96. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40504)
  97. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40505)
  98. self.model:Fire(GuildModel.OPEN_GUILD_WAR_RANK_VIEW)
  99. elseif target == self.escort_big_1_obj or target == self.escort_big_2_obj then
  100. if not self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.BigRice) then
  101. --如果没有精粮就不显示护送中了
  102. self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.Boss)
  103. return
  104. end
  105. self:StopActionGuideTipsAction(false)
  106. self:UpdatePickInfo(true)
  107. elseif target == self.find_escort_btn_obj then
  108. self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.SmallRice)
  109. self:StopActionGuideTipsAction(false)
  110. self:UpdatePickInfo(true)
  111. elseif target == self.escort_small_1_obj or target == self.escort_small_2_obj then
  112. if not self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.MiddleRice) then
  113. --如果没有中粮就不显示护送中了
  114. self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.Boss)
  115. return
  116. end
  117. self:StopActionGuideTipsAction(false)
  118. self:UpdatePickInfo(true)
  119. elseif target == self.escort_boss_1_obj or target == self.escort_boss_2_obj or target == self.find_boss_btn_obj then
  120. Scene.Instance:CancelClickTarget(nil, true)
  121. self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.Boss)
  122. self:StopActionGuideTipsAction(false)
  123. elseif target == self.protect_btn_obj then
  124. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40514)
  125. end
  126. end
  127. AddClickEvent(self.exitBtn_obj,onBtnClickHandler)
  128. AddClickEvent(self.rankBtn_obj,onBtnClickHandler)
  129. AddClickEvent(self.escort_boss_1_obj,onBtnClickHandler)
  130. AddClickEvent(self.escort_boss_2_obj,onBtnClickHandler)
  131. AddClickEvent(self.escort_big_1_obj,onBtnClickHandler)
  132. AddClickEvent(self.escort_big_2_obj,onBtnClickHandler)
  133. AddClickEvent(self.escort_small_1_obj,onBtnClickHandler)
  134. AddClickEvent(self.escort_small_2_obj,onBtnClickHandler)
  135. AddClickEvent(self.find_boss_btn_obj,onBtnClickHandler)
  136. AddClickEvent(self.find_escort_btn_obj,onBtnClickHandler)
  137. AddClickEvent(self.protect_btn_obj,onBtnClickHandler)
  138. self.exitBtn_obj:SetActive(false)
  139. local function delay_init( ... )
  140. if self._use_delete_method then return end
  141. if not self.init_exit_btn then--初始退出exit_btn_pos这个是任务背景的长度
  142. self.init_exit_btn = true
  143. local function call_back( ... )
  144. self.model:Fire(GuildModel.LEAVE_GUILD_WAR_SCENE)
  145. end
  146. local data = {call_back = call_back, pos = {x = 198,y = 280}}
  147. GlobalEventSystem:Fire(EventName.SHOW_EXIT_BTN_STATE,data)
  148. end
  149. end
  150. setTimeout(delay_init,0.5)
  151. --百团对话监听
  152. local function onUpdateScroe( )
  153. self:UpdateScore()
  154. end
  155. self:BindEvent(self.model, GuildModel.GUILD_WAR_UPDATE_SCROE, onUpdateScroe)
  156. --基本信息刷新
  157. local function onUpdaeBaseInfo()
  158. self:UpdateScore()
  159. self:UpdateTime()
  160. end
  161. self:BindEvent(self.model, GuildModel.GUILD_WAR_BASE_INFO, onUpdaeBaseInfo)
  162. --百团对话监听
  163. local function onCheckGuildWarnpc(npc_type_id )
  164. self.model:GuideWarGiveInPick(npc_type_id)
  165. end
  166. self:BindEvent(GlobalEventSystem, DialogueModel.CLICK_OK, onCheckGuildWarnpc)
  167. --boss更新刷新
  168. local function onUdateBossInfo(npc_type_id)
  169. self:UpdateCountInfo()
  170. end
  171. self:BindEvent(self.model, GuildModel.GUILD_WAR_BOSS_BORN, onUdateBossInfo)
  172. self:BindEvent(self.model, GuildModel.GUILD_WAR_BOSS_DIE, onUdateBossInfo)
  173. --怪物添加
  174. local function onMonsterUpdateAdd(monster_id, monster_vo)
  175. if monster_vo.type_id == GuildModel.GuildWarTarget.Boss then
  176. self:UpdateBossInfo(true, monster_vo)
  177. self:ShowRefreshBossTipsAnimation()
  178. end
  179. self:UpdateCountInfo()
  180. end
  181. self:BindEvent(GlobalEventSystem, SceneEventType.MONSTER_VO_ADD, onMonsterUpdateAdd)
  182. --进场boss已经刷新了,提示一下
  183. local function boss_refresh_func()
  184. if self._use_delete_method then return end
  185. local boss_num = self.model:GuideWarGetTargetNum(GuildModel.GuildWarTarget.Boss)
  186. if boss_num > 0 then
  187. self:ShowRefreshBossTipsAnimation()
  188. end
  189. end
  190. setTimeout(boss_refresh_func,1)
  191. --怪物移除
  192. local function onMonsterUpdateRemove(monster_id, monster_type_id, monster_vo)
  193. if monster_vo.type_id == GuildModel.GuildWarTarget.Boss then
  194. self:UpdateBossInfo(false, monster_vo)
  195. end
  196. self:UpdateCountInfo()
  197. end
  198. self:BindEvent(GlobalEventSystem, SceneEventType.MONSTER_VO_REMOVE, onMonsterUpdateRemove)
  199. --百团对话监听
  200. local function onBroadcast(module_id, id)
  201. if module_id == 405 then
  202. local config = Config.Languageextra
  203. local key = module_id .. "@" .. id
  204. if config[key] and config[key].content then
  205. self:UpdateBroadCast(config[key].content)
  206. end
  207. end
  208. end
  209. self:BindEvent(SocialityModel:getInstance(), SocialityModel.BROADCAST_MIDDLE_MESSAGE, onBroadcast)
  210. --更新右上角活动图标状态
  211. local function changeFunc(is_hide)
  212. self.rightIconCon_obj:SetActive(is_hide)
  213. end
  214. self:BindEvent(GlobalEventSystem, EventName.CHANGE_RIGHT_TIP_ICON, changeFunc)
  215. --适配刘海屏
  216. local function onOrientationChange()
  217. self:ChangeUiPosition()
  218. end
  219. self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  220. --采集状态变化
  221. local function onUpdaePickInfo()
  222. local find_way_state = AutoFightManager:getInstance():GetAutoFindWayState()
  223. local fight_state = AutoFightManager:getInstance():GetAutoFightState()
  224. if fight_state then
  225. self:UpdatePickInfo(false)
  226. elseif find_way_state then
  227. --不处理
  228. else
  229. local function delay_fun( ... )
  230. local main_role = Scene.Instance.main_role
  231. if not main_role then
  232. self:UpdatePickInfo(false)
  233. return
  234. end
  235. if main_role:IsInState(PoseState.COLLECT) then
  236. self:UpdatePickInfo(true)
  237. else
  238. local find_way_state = AutoFightManager:getInstance():GetAutoFindWayState()
  239. if not find_way_state then
  240. self:UpdatePickInfo(false)
  241. end
  242. end
  243. end
  244. TimeManager.GetInstance():StartDalayTime("GuildSceneWarViewonUpdaePickInfo",0.5,delay_fun)
  245. end
  246. end
  247. self:BindEvent(GlobalEventSystem, AutoFightManager.CHANGE_AUTO_FIGHT_STATE, onUpdaePickInfo)
  248. self:BindEvent(GlobalEventSystem, AutoFightManager.CHANGE_AUTO_FIND_WAY_STATE, onUpdaePickInfo)
  249. local function onCancelCollect()
  250. self:UpdatePickInfo(false)
  251. end
  252. self:BindEvent(GlobalEventSystem, EventName.CANCEL_TO_COLLECT, onCancelCollect)
  253. local function onStartCollect()
  254. self:UpdatePickInfo(true)
  255. end
  256. self:BindEvent(GlobalEventSystem, EventName.START_TO_COLLECT, onStartCollect)
  257. self:BindEvent(self.model, GuildModel.GUILD_WAR_START_COLLECT, onStartCollect)
  258. local function onReliveSuccess(i_type)
  259. --出生地复活
  260. if i_type == 3 then
  261. EventSystem.Fire(GlobalEventSystem,EventName.STOPAUTOFIGHT, false, true)
  262. self.wait_to_collect = true
  263. else
  264. EventSystem.Fire(GlobalEventSystem,EventName.STOPAUTOFIGHT, false, true)
  265. self.wait_to_collect = false
  266. end
  267. end
  268. self:BindEvent(GlobalEventSystem, EventName.RELIVE_SUCC, onReliveSuccess)
  269. --复活动画播放完成
  270. local function onReviveEndEvent()
  271. if self.wait_to_collect then
  272. self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.SmallRice)
  273. self:UpdatePickInfo(true)
  274. self.wait_to_collect = false
  275. else
  276. --起来只停自动战斗
  277. end
  278. end
  279. self:BindEvent(GlobalEventSystem, EventName.REVIVE_END_EVENT, onReviveEndEvent)
  280. --场景落地动画结束,开始采集
  281. local function onDoFlyShoeEffectFinishDown()
  282. self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.SmallRice)
  283. self:UpdatePickInfo(true)
  284. end
  285. self:BindEvent(GlobalEventSystem, SceneEventType.DO_FLYSHOE_EFFECT_FINISH_DOWN, onDoFlyShoeEffectFinishDown)
  286. --更新护盾
  287. local function onProject()
  288. self:UpdateProjectGroup()
  289. end
  290. self:BindEvent(self.model, GuildModel.GUILD_WAR_PROJECT, onProject)
  291. --对话提示框
  292. local function hide_dance_eff_node()
  293. self.left_info_con_obj:SetActive(false)
  294. end
  295. local function show_dance_eff_node()
  296. self.left_info_con_obj:SetActive(true)
  297. end
  298. self:BindEvent(GlobalEventSystem, EventName.START_COM_DIALOGUE_SHOW_ANIM, hide_dance_eff_node)
  299. self:BindEvent(GlobalEventSystem, EventName.FINISHED_COM_DIALOGUE_SHOW_ANIM, show_dance_eff_node)
  300. self:BindLittleMove(self.left_info_con, BaseView.LittleMoveDir.Left, 222)
  301. self:BindLittleMove(self.func_btn_con, BaseView.LittleMoveDir.Bottom, 192)
  302. self:BindLittleMove(self.rightIconCon, BaseView.LittleMoveDir.Right, -60)
  303. -- 主界面聊天展开事件
  304. self:BindMainUIExpandEvent( self.func_btn_con )
  305. self:UpdatePickInfo(false)
  306. end
  307. function GuildSceneWarView:UpdateView()
  308. self:UpdateScore()
  309. self:UpdateTime()
  310. self:UpdateCountInfo()
  311. self:UpdateBossInfo(true)
  312. end
  313. function GuildSceneWarView:DestroySuccess( )
  314. if self.timer then
  315. GlobalTimerQuest:CancelQuest(self.timer)
  316. self.timer = nil
  317. end
  318. if self.boss_timer then
  319. GlobalTimerQuest:CancelQuest(self.boss_timer)
  320. self.boss_timer = nil
  321. end
  322. if self.boss_vo and self.boss_vo_id then
  323. self.boss_vo:UnBind(self.boss_vo_id)
  324. self.boss_vo_id = nil
  325. end
  326. if self.broadcast_timer then
  327. GlobalTimerQuest:CancelQuest(self.broadcast_timer)
  328. self.broadcast_timer = nil
  329. end
  330. if self.delay_timer then
  331. GlobalTimerQuest:CancelQuest(self.delay_timer)
  332. self.delay_timer = nil
  333. end
  334. for k,n in ipairs(self.item_list) do
  335. n:SetIsFixSize(true)
  336. UIObjPool:PushItem(UIObjPool.UIType.AwardItem, n)
  337. end
  338. self.item_list = {}
  339. if self.delay_guide_tips_timer then
  340. GlobalTimerQuest:CancelQuest(self.delay_guide_tips_timer)
  341. self.delay_guide_tips_timer = nil
  342. end
  343. self:StopActionGuideTipsAction(false)
  344. self:StopPrjectCdTimer()
  345. self:StopRefreshBossTipsAnimation(true)
  346. --关闭计时界面
  347. CommonController.Instance:Fire(EventName.OPEN_SPECIALTIPVIEW, false)
  348. GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP, nil, false)
  349. GlobalEventSystem:Fire(EventName.HIDE_EXIT_BTN_STATE)
  350. end
  351. function GuildSceneWarView:UpdateScore( )
  352. local score = self.model.guild_war_info.score or 0
  353. local reward_list, is_finish,next_score = self.model:GuildWarGetRewardByScroe(score, true)
  354. reward_list = reward_list or {}
  355. self.my_score_tmp.text = score .. "/" .. next_score
  356. for i, v in ipairs(self.item_list) do
  357. v:SetVisible(false)
  358. end
  359. for ii,vv in ipairs(reward_list) do
  360. local show_item = self.item_list[ii]
  361. if not show_item then
  362. show_item = UIObjPool:PopItem(UIObjPool.UIType.AwardItem, self.reward_con_collect)
  363. show_item:SetIsFixSize(false)
  364. show_item:SetItemSize(50,50)
  365. self.item_list[ii] = show_item
  366. show_item:SetAnchoredPosition(60*(ii-1) + 3, -6)
  367. self.finish:SetSiblingIndex(#self.item_list + 1)
  368. end
  369. local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(vv[1], vv[2])
  370. local goodVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
  371. show_item:SetIsFixSize(false)
  372. show_item:SetItemSize(50,50)
  373. if goodVo then
  374. show_item:SetData(goodVo.type_id, vv[3] , goodVo.color, nil, lock)
  375. end
  376. show_item:SetVisible(true)
  377. if is_finish then
  378. SetAnchoredPositionX(self.finish, #reward_list == 1 and 28 or (#reward_list > 2 and 88 or 58 ))
  379. end
  380. show_item:SetGray(is_finish)
  381. end
  382. SetSizeDeltaX(self.reward_con_collect, 63 * #reward_list)
  383. self.finish_obj:SetActive(is_finish)
  384. end
  385. function GuildSceneWarView:UpdateTime()
  386. if self.timer then
  387. GlobalTimerQuest:CancelQuest(self.timer)
  388. self.timer = nil
  389. end
  390. self.end_time = self.model.guild_war_info.end_time or TimeUtil:getServerTime()
  391. local function timer_func()
  392. local left_time = self.end_time - TimeUtil:getServerTime()
  393. if left_time and left_time > 0 then
  394. self:ShowExitTime(left_time)
  395. self.leftTime_tmp.text = TimeUtil:timeConvert8(left_time)
  396. if self.is_in_pick then
  397. self.is_in_pick = self.is_in_pick + 1
  398. if self.is_in_pick > 3 then
  399. self.is_in_pick = 1
  400. end
  401. self.escorting_text_tmp.text = self.is_in_pick == 1 and (".") or (self.is_in_pick == 2 and ".." or "...")
  402. else
  403. self.escorting_text_tmp.text = ""
  404. end
  405. else
  406. self.escorting_text_tmp.text = ""
  407. self.leftTime_tmp.text = "00:00"
  408. if self.timer then
  409. GlobalTimerQuest:CancelQuest(self.timer)
  410. self.timer = nil
  411. end
  412. end
  413. end
  414. if not self.timer then
  415. self.timer = GlobalTimerQuest:AddPeriodQuest(timer_func, 1)
  416. end
  417. timer_func()
  418. end
  419. function GuildSceneWarView:UpdateCountInfo()
  420. local big_time = self.model:GuideWarGetTargetNum(GuildModel.GuildWarTarget.BigRice)
  421. local middle_time = self.model:GuideWarGetTargetNum(GuildModel.GuildWarTarget.MiddleRice)
  422. self.escort_small_2_text_tmp.text = middle_time == 0 and "<color=#2cf86f><u>击杀BOSS刷新</u></color>" or "<color=#2cf86f><u>前往护送</u></color>"
  423. self.escort_big_2_text_tmp.text = big_time == 0 and "<color=#2cf86f><u>击杀BOSS刷新</u></color>" or "<color=#2cf86f><u>前往护送</u></color>"
  424. self.big_time_tmp.text = string.format("剩余: %s", HtmlColorTxt(tostring(big_time), "#2cf86f"))
  425. self.small_time_tmp.text = string.format("剩余: %s", HtmlColorTxt(tostring(middle_time), "#2cf86f"))
  426. end
  427. function GuildSceneWarView:UpdateBossInfo(is_add, boss_vo)
  428. self.boss_vo = self.model:GuideWarGetBossVo() or boss_vo
  429. if self.boss_vo and self.boss_vo_id then
  430. self.boss_vo:UnBind(self.boss_vo_id)
  431. self.boss_vo_id = nil
  432. end
  433. if self.boss_timer then
  434. GlobalTimerQuest:CancelQuest(self.boss_timer)
  435. self.boss_timer = nil
  436. end
  437. if self.boss_vo and is_add then
  438. if self.delay_timer then
  439. GlobalTimerQuest:CancelQuest(self.delay_timer)
  440. self.delay_timer = nil
  441. end
  442. --self.escort_boss_2_obj:SetActive(true)
  443. self.boss_hp_r_img.gameObject:SetActive(true)
  444. self.boss_hp_r_bg_img.gameObject:SetActive(true)
  445. self.boss_hp_percentage_tmp.gameObject:SetActive(true)
  446. self.boss_name_tmp.gameObject:SetActive(true)
  447. self.boss_name_tmp.text = string.format("结晶守卫%s", HtmlColorTxt("(前往击杀)", ColorUtil.GREEN_DARK))
  448. self.boss_hp_percentage_tmp.text = ""
  449. self.boss_tips_tmp.gameObject:SetActive(false)
  450. lua_resM:setImageSprite(self,self.boss_state_img,"guildScene_asset", "guild_war_boss_live", true)
  451. local function func_update_hp()
  452. local percent = self.boss_vo.hp / self.boss_vo.maxHp
  453. self.boss_hp_r_img.fillAmount = percent
  454. self.boss_hp_percentage_tmp.text = math.ceil(percent * 100) .. "%"
  455. end
  456. self.boss_vo_id = self.boss_vo:BindOne("hp", func_update_hp)
  457. func_update_hp()
  458. else
  459. --当boss找不到的时候,延时1秒,在更新信息栏,因为有时候,安全区复活boss第一时间没生成,会闪一下
  460. if self.delay_timer then
  461. GlobalTimerQuest:CancelQuest(self.delay_timer)
  462. self.delay_timer = nil
  463. end
  464. local function delay_func()
  465. self.escort_boss_2_obj:SetActive(false)
  466. self.boss_hp_r_img.gameObject:SetActive(false)
  467. self.boss_hp_r_bg_img.gameObject:SetActive(false)
  468. self.boss_name_tmp.gameObject:SetActive(false)
  469. self.boss_hp_percentage_tmp.gameObject:SetActive(false)
  470. self.boss_tips_tmp.gameObject:SetActive(true)
  471. self.boss_tips_tmp.text = ""
  472. local idx = 0
  473. self.next_boss_born_time, idx = self.model:GuildWarGetNextBossBornTime()
  474. if self.next_boss_born_time > 0 then
  475. local function boss_timer_func()
  476. local left_time = self.next_boss_born_time - TimeUtil:getServerTime()
  477. --print(">>>>>>>> self.next_boss_born_time222 ", left_time)
  478. if left_time and left_time > 0 then
  479. self:ShowLiveTime(left_time)
  480. lua_resM:setImageSprite(self,self.boss_state_img,"guildScene_asset", "guild_war_boss_death", true)
  481. self.boss_tips_tmp.text = "刷新时间:" .. HtmlColorTxt(TimeUtil:timeConvert8(left_time) , "#2cf86f")
  482. else
  483. lua_resM:setImageSprite(self,self.boss_state_img,"guildScene_asset", "guild_war_boss_live", true)
  484. if self.boss_timer then
  485. GlobalTimerQuest:CancelQuest(self.boss_timer)
  486. self.boss_timer = nil
  487. end
  488. self.show_left_time_tip = false
  489. self.boss_tips_tmp.text = ""
  490. end
  491. end
  492. if not self.boss_timer then
  493. self.boss_timer = GlobalTimerQuest:AddPeriodQuest(boss_timer_func, 1)
  494. end
  495. boss_timer_func()
  496. else
  497. lua_resM:setImageSprite(self,self.boss_state_img,"guildScene_asset", "guild_war_boss_death", true)
  498. self.boss_tips_tmp.text = string.format("结晶守卫\n%s", HtmlColorTxt("已击杀" , ColorUtil.RED_DARK))
  499. end
  500. end
  501. if not self.delay_timer then
  502. self.delay_timer = GlobalTimerQuest:AddPeriodQuest(delay_func, 1, 0)
  503. end
  504. end
  505. end
  506. function GuildSceneWarView:UpdateBroadCast(str)
  507. if self.broadcast_timer then
  508. GlobalTimerQuest:CancelQuest(self.broadcast_timer)
  509. self.broadcast_timer = nil
  510. end
  511. local left_time = 6
  512. self.broadcast_root_obj:SetActive(true)
  513. self.broadcast_text_tmp.text = str
  514. function broadcast_timer_func( )
  515. left_time = left_time - 1
  516. if left_time > 0 then
  517. else
  518. if self.broadcast_timer then
  519. GlobalTimerQuest:CancelQuest(self.broadcast_timer)
  520. self.broadcast_timer = nil
  521. end
  522. self.broadcast_root_obj:SetActive(false )
  523. self.broadcast_text_tmp.text = ""
  524. end
  525. end
  526. if not self.broadcast_timer then
  527. self.broadcast_timer = GlobalTimerQuest:AddPeriodQuest(broadcast_timer_func, 1)
  528. end
  529. broadcast_timer_func()
  530. end
  531. function GuildSceneWarView:ChangeUiPosition( )
  532. SetAnchoredPositionX(self.left_info_con, 222 + ClientConfig.iphone_x_offset_left)
  533. end
  534. function GuildSceneWarView:StartGuideAction( )
  535. self.action_breath_light = ActionBreathLight.New()
  536. self.action_breath_light:Init(self.guide_tip_1)
  537. self.guide_tip_1_obj:SetActive(true)
  538. self.guide_tip_text_1_tmp.text = string.format("运送结晶可获得%s,\n击败BOSS有%s!",HtmlColorTxt("积分" , "#fdffc2"), HtmlColorTxt("大量积分" , "#fdffc2"))
  539. if self.delay_guide_tips_timer then
  540. GlobalTimerQuest:CancelQuest(self.delay_guide_tips_timer)
  541. self.delay_guide_tips_timer = nil
  542. end
  543. local delay_func = function()
  544. self:StopActionGuideTipsAction(false)
  545. end
  546. self.delay_guide_tips_timer = GlobalTimerQuest:AddDelayQuest(delay_func, 10)
  547. end
  548. function GuildSceneWarView:StopActionGuideTipsAction(visible)
  549. visible = visible or false
  550. self.guide_tip_1_obj:SetActive(visible)
  551. if self.action_breath_light then
  552. self.action_breath_light:DeleteMe()
  553. self.action_breath_light = false
  554. end
  555. if self.delay_guide_tips_timer then
  556. GlobalTimerQuest:CancelQuest(self.delay_guide_tips_timer)
  557. self.delay_guide_tips_timer = nil
  558. end
  559. end
  560. function GuildSceneWarView:UpdatePickInfo(state)
  561. local b = state
  562. self.is_in_pick = b == true and 0 or false
  563. self.escorting_text_tmp.text = ""
  564. lua_resM:setImageSprite(self,self.find_escort_btn_img,"guildScene_asset", b and "guild_war_escorting_btn" or "guild_war_escort_btn", true)
  565. end
  566. function GuildSceneWarView:ShowLiveTime(time)
  567. if time > 30 then
  568. return
  569. end
  570. if self.show_left_time_tip then
  571. return
  572. end
  573. self.show_left_time_tip = true
  574. local special_tip_data = {
  575. type = SpecialTipType.Timer2,
  576. sepeical_str = "结晶守卫降临 %s",
  577. show_time = time,
  578. }
  579. CommonController.Instance:Fire(EventName.OPEN_SPECIALTIPVIEW, special_tip_data)
  580. end
  581. function GuildSceneWarView:ShowExitTime(time)
  582. if time > 15 then
  583. return
  584. end
  585. if self.show_exit_time_tip then
  586. return
  587. end
  588. self.show_exit_time_tip = true
  589. local data = {
  590. time = time,
  591. time_str = "秒后",
  592. exit_desc = "自动退出战场",
  593. }
  594. GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP, data, true)
  595. end
  596. function GuildSceneWarView:UpdateProjectGroup()
  597. local cd_time = self.model.guild_war_info.cd_time or 0
  598. local cur_time = TimeUtil:getServerTime()
  599. self:StopPrjectCdTimer()
  600. if cd_time == 0 or cur_time >= cd_time then
  601. self.project_cd_time = 0
  602. self.protect_cd_time_tmp.text = ""
  603. self.protect_cd_img_img.fillAmount = 1
  604. else
  605. local time = cd_time - cur_time
  606. if not self.skill_max_cd_time then
  607. local cfg = Config.Guildwarkv
  608. self.skill_max_cd_time = tonumber(cfg["skill_cd"].value_content)
  609. end
  610. self.protect_cd_img_img.fillAmount = 1 - (time / self.skill_max_cd_time)
  611. self.project_cd_time = time
  612. local delay_func = function ()
  613. self.project_cd_time = self.project_cd_time - 1
  614. if self.project_cd_time <= 0 then
  615. self:UpdateProjectGroup()
  616. return
  617. end
  618. self.protect_cd_time_tmp.text = self.project_cd_time
  619. end
  620. self.protect_cd_time_tmp.text = self.project_cd_time
  621. if not self.project_timer then
  622. self.project_timer = GlobalTimerQuest:AddPeriodQuest(delay_func, 1)
  623. end
  624. self.tween_project_cd = TweenLite.to(self, self.protect_cd_img_img,TweenLite.UiAnimationType.FILLAMOUNT, 1, time)
  625. end
  626. end
  627. function GuildSceneWarView:StopPrjectCdTimer()
  628. if self.project_timer then
  629. GlobalTimerQuest:CancelQuest(self.project_timer)
  630. self.project_timer = nil
  631. end
  632. if self.tween_project_cd then
  633. TweenLite.Stop(self.tween_project_cd)
  634. self.tween_project_cd = nil
  635. end
  636. end
  637. function GuildSceneWarView:ShowRefreshBossTipsAnimation( )
  638. self:StartRefreshBossTipsAnimation()
  639. local left_time = 11
  640. local function left_tips_timer_func()
  641. left_time = left_time - 1
  642. if left_time <= 0 then
  643. self:StopRefreshBossTipsAnimation(true)
  644. end
  645. end
  646. if not self.boss_tips_delay_timer then
  647. self.boss_tips_delay_timer = GlobalTimerQuest:AddPeriodQuest(left_tips_timer_func, 1)
  648. end
  649. left_tips_timer_func()
  650. end
  651. function GuildSceneWarView:StartRefreshBossTipsAnimation( )
  652. self:StopRefreshBossTipsAnimation()
  653. self.boss_tips_root_obj:SetActive(true)
  654. local call_fun = function ()
  655. local function onCompleted()
  656. self:StartRefreshBossTipsAnimation()
  657. end
  658. self.boss_tips_tween_id1 = TweenLite.to(self, self.boss_tips_root.transform,TweenLite.UiAnimationType.ANCHORED_POS,Vector2(0, 10 - 5), 0.5, onCompleted)
  659. end
  660. local onDelay = function( )
  661. self.boss_tips_tween_id2 = TweenLite.to(self, self.boss_tips_root.transform,TweenLite.UiAnimationType.ANCHORED_POS,Vector2(0, 10 + 5), 0.5, call_fun)
  662. end
  663. self.arrow_boss_timer_delay_id = setTimeout(onDelay, 0.01)
  664. end
  665. function GuildSceneWarView:StopRefreshBossTipsAnimation(stop_delay_timer)
  666. self.boss_tips_root_obj:SetActive(false)
  667. if self.boss_tips_tween_id1 then
  668. TweenLite.Stop(self.boss_tips_tween_id1)
  669. self.boss_tips_tween_id1 = nil
  670. end
  671. if self.boss_tips_tween_id2 then
  672. TweenLite.Stop(self.boss_tips_tween_id2)
  673. self.boss_tips_tween_id2 = nil
  674. end
  675. if self.arrow_boss_timer_delay_id then
  676. GlobalTimerQuest:CancelQuest(self.arrow_boss_timer_delay_id)
  677. self.arrow_boss_timer_delay_id = nil
  678. end
  679. if stop_delay_timer then
  680. if self.boss_tips_delay_timer then
  681. GlobalTimerQuest:CancelQuest(self.boss_tips_delay_timer)
  682. self.boss_tips_delay_timer = nil
  683. end
  684. end
  685. end