源战役客户端
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.

188 lines
6.1 KiB

  1. EscortResultView = EscortResultView or BaseClass(BaseView)
  2. local EscortResultView = EscortResultView
  3. function EscortResultView:__init()
  4. self.base_file = "escort"
  5. self.layout_file = "EscortResultView"
  6. self.layer_name = "UI"
  7. self.destroy_imm = true
  8. self.use_background = true --全屏界面默认使用这个参数
  9. --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  10. self.change_scene_close = true
  11. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  12. self.need_show_money = false --是否要显示顶部的金钱栏
  13. self.click_bg_toClose = true
  14. self.model = EscortModel:getInstance()
  15. self.left_time = 10
  16. self.escort_reward_item = {}
  17. self.load_callback = function ()
  18. self:LoadSuccess()
  19. self:AddEvent()
  20. end
  21. self.open_callback = function ( )
  22. self:OpenSuccess()
  23. end
  24. self.switch_callback = function(index)
  25. self:SwitchTab(index)
  26. end
  27. self.destroy_callback = function ( )
  28. self:DestroySuccess()
  29. end
  30. end
  31. function EscortResultView:Open(data)
  32. self.data = data
  33. BaseView.Open(self)
  34. end
  35. function EscortResultView:LoadSuccess()
  36. local nodes = {
  37. "bg:raw","bg2:raw","title:raw","reward_con", "tip_text:tmp", "time_text:tmp", "type_text:tmp",
  38. "ok_btn:obj", "cancel_btn:obj","bg3:raw",
  39. }
  40. self:GetChildren(nodes)
  41. end
  42. function EscortResultView:AddEvent()
  43. local function on_click( target )
  44. if target == self.ok_btn_obj then
  45. if self.can_continue then
  46. self:ClickBtn()
  47. else
  48. self.model:FlyToNpc()
  49. self:Close()
  50. end
  51. elseif target == self.cancel_btn_obj then
  52. if self.can_continue then
  53. else
  54. self.model:FlyToNpc()
  55. end
  56. self:Close()
  57. end
  58. end
  59. AddClickEvent(self.ok_btn_obj, on_click)
  60. AddClickEvent(self.cancel_btn_obj, on_click)
  61. end
  62. function EscortResultView:OpenSuccess()
  63. self:UpdateView()
  64. self:UpdateLeftTime()
  65. end
  66. function EscortResultView:UpdateView()
  67. if self.data.result == 1 then
  68. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("com_result_bg_1124_549"), false)
  69. lua_resM:setOutsideRawImage(self, self.bg2_raw, GameResPath.GetEscortImage("escort_result_type1"), true)
  70. lua_resM:setOutsideRawImage(self, self.title_raw, GameResPath.GetEscortImage("escort_win"), true)
  71. lua_resM:setOutsideRawImage(self, self.bg3_raw, GameResPath.GetDungeonImage("dun_result_win_bg1"), true)
  72. self.type_text_tmp.text = string.format("完美外送获得%s", HtmlColorTxt("完美奖励", "#fdffc2"))
  73. SetTMPSharedMaterial(self.type_text_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeTitle)
  74. else
  75. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("com_result_bg_lose_1124_549"), false)
  76. lua_resM:setOutsideRawImage(self, self.bg3_raw, GameResPath.GetDungeonImage("dun_result_default_bg1"), true)
  77. lua_resM:setOutsideRawImage(self, self.bg2_raw, GameResPath.GetEscortImage("escort_result_type3"), true)
  78. self.type_text_tmp.text = string.format("超时外送获得%s", HtmlColorTxt("超时奖励", "#f558ff"))
  79. lua_resM:setOutsideRawImage(self, self.title_raw, GameResPath.GetEscortImage("escort_fail"), false)
  80. SetTMPSharedMaterial(self.type_text_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkBlueTitle)
  81. end
  82. self:UpdateReward()
  83. local left_time = self.model:GetMaxEscortTimes() - self.model:GetEscortTimes()
  84. self.cancel_btn_obj:SetActive(true)
  85. if left_time > 0 then
  86. self.can_continue = true
  87. self.tip_text_tmp.text = string.format("剩余 %s 次外送任务,是否继续?", HtmlColorTxt(left_time, ColorUtil.GREEN_DARK))
  88. else
  89. self.can_continue = false
  90. self.cancel_btn_obj:SetActive(false)
  91. self.tip_text_tmp.text = "今日外送次数已满"
  92. SetAnchoredPositionX(self.ok_btn, 218)
  93. SetAnchoredPositionX(self.time_text, 218)
  94. end
  95. end
  96. function EscortResultView:DestroySuccess( )
  97. -- self.model:Fire(EscortConst.CHANGE_SCENE)
  98. if self.escort_timer_id then
  99. GlobalTimerQuest:CancelQuest(self.escort_timer_id)
  100. self.escort_timer_id = nil
  101. end
  102. for i,v in ipairs(self.escort_reward_item) do
  103. UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v)
  104. end
  105. self.escort_reward_item = {}
  106. end
  107. function EscortResultView:UpdateLeftTime( )
  108. local function onExitTimer()
  109. if self.left_time > 0 then
  110. self.time_text_tmp.text = string.format("%s秒后自动继续",HtmlColorTxt(self.left_time, ColorUtil.GREEN_DARK))
  111. else
  112. GlobalTimerQuest:CancelQuest(self.escort_timer_id)
  113. self.escort_timer_id = nil
  114. self:ClickBtn()
  115. end
  116. self.left_time = self.left_time - 1
  117. end
  118. self.escort_timer_id = GlobalTimerQuest:AddPeriodQuest(onExitTimer, 1, -1)
  119. onExitTimer()
  120. end
  121. function EscortResultView:UpdateReward( )
  122. local lv = RoleManager.Instance.mainRoleInfo.level
  123. local vip_ratio = 0
  124. local vip = RoleManager.Instance.mainRoleInfo.vip_flag
  125. if Config.Vipprivilege[vip.."@8"] then
  126. vip_ratio = Config.Vipprivilege[vip.."@8"].value
  127. end
  128. local cfg_exp = Config.Convoyexp
  129. local convoy_exp = 0
  130. for i,v in pairsByKeys(cfg_exp) do
  131. if v.lv_low <= lv and lv <= v.lv_high then
  132. convoy_exp = v.convoy_exp
  133. break
  134. end
  135. end
  136. local total_data = {}
  137. local cfg_data = Config.Convoyobject[self.data.object_id]
  138. local data = stringtotable(cfg_data.award)
  139. local double_ratio = self.model:CurTimeIsDouble() and 2 or 1
  140. local exp_num1 = convoy_exp * cfg_data.stage_one_ratio/100
  141. if self.data.result == 1 then
  142. exp_num1 = convoy_exp * cfg_data.stage_one_ratio/100
  143. elseif self.data.result == 2 then
  144. exp_num1 = convoy_exp * cfg_data.overdue_ratio/100 * cfg_data.stage_one_ratio/100
  145. end
  146. if self.model:CurTimeIsDouble() or self.model.last_double_escort == 1 then
  147. exp_num1 = exp_num1 *2
  148. end
  149. local exp_data = {
  150. [1] = 0,
  151. [2] = EscortConst.EXP_TPYE_ID,
  152. [3] = exp_num1
  153. }
  154. table.insert(data, exp_data)
  155. for ii,vv in ipairs(data) do
  156. local item = self.escort_reward_item[ii]
  157. if not item then
  158. item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.reward_con)
  159. item:SetItemSize(84,84)
  160. item:SetNumForceShow(true)
  161. if #data == 2 then
  162. item:SetPosition((ii-1)*90, 0)
  163. else
  164. item:SetPosition(50, 0)
  165. end
  166. self.escort_reward_item[ii] = item
  167. end
  168. item:SetData(vv[2],vv[3])
  169. end
  170. end
  171. function EscortResultView:ClickBtn( )
  172. if self.can_continue then
  173. self.model:FlyToNpc()
  174. else
  175. self.model:FlyToNpc()
  176. end
  177. self:Close()
  178. end