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

128 lines
4.0 KiB

  1. SoulPowerChargeView = SoulPowerChargeView or BaseClass(BaseView)
  2. local SoulPowerChargeView = SoulPowerChargeView
  3. function SoulPowerChargeView:__init()
  4. self.base_file = "soulPower"
  5. self.layout_file = "SoulPowerChargeView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.change_scene_close = true
  10. self.hide_maincancas = true --是否隐藏主界面
  11. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  12. self.need_show_money = false --是否要显示顶部的金钱栏
  13. self.blur_activity_bg = true
  14. self.use_show_anim = true
  15. self.use_hide_anim = true
  16. self.jump_close = true
  17. self.model = SoulPowerModel:getInstance()
  18. self.load_callback = function ()
  19. self:LoadSuccess()
  20. self:AddEvent()
  21. end
  22. self.open_callback = function ( )
  23. self:OpenSuccess()
  24. end
  25. self.destroy_callback = function ( )
  26. self:DestroySuccess()
  27. end
  28. end
  29. function SoulPowerChargeView:Open(sp_grade, sp_lv)
  30. self.sp_grade = sp_grade
  31. self.sp_lv = sp_lv
  32. BaseView.Open(self)
  33. end
  34. function SoulPowerChargeView:LoadSuccess()
  35. local nodes = {
  36. "bg:raw",
  37. "close:obj",
  38. "confirmBtn:obj",
  39. "chargeTip:tmp",
  40. "leftTime:tmp",
  41. "costNum:tmp",
  42. }
  43. self:GetChildren(nodes)
  44. lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("tips_comm_bg6"))
  45. end
  46. function SoulPowerChargeView:AddEvent()
  47. local on_click = function ( click_obj )
  48. if self.close_obj == click_obj then
  49. self:Close()
  50. elseif self.confirmBtn_obj == click_obj then
  51. if not self.left_time then return end
  52. if self.left_time < 60 then
  53. Message.show("您即将完成充能,无需快速充能!")
  54. else
  55. self:DoCharge()
  56. end
  57. end
  58. end
  59. AddClickEvent(self.close_obj, on_click)
  60. AddClickEvent(self.confirmBtn_obj, on_click)
  61. local update_soul_power_left_time = function()
  62. if not self.is_loaded then return end
  63. self:UpdateLeftTime()
  64. end
  65. self:BindEvent(self.model, SoulPowerConst.UPDATE_SOUL_POWER_LEFT_TIME, update_soul_power_left_time)
  66. end
  67. function SoulPowerChargeView:DoCharge( )
  68. local function ok_callback( ... )
  69. self.model:Fire(SoulPowerConst.REQUEST_CCMD_EVENT,14403)
  70. self:Close()
  71. end
  72. local function toggle_function( flag )
  73. self.model._charge_no_double_check = flag
  74. end
  75. local function use_function( toggle_tip_data,call_fun_sum )
  76. if not self.model._charge_no_double_check and self.need_cost ~= 0 then
  77. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data)
  78. else
  79. call_fun_sum()
  80. end
  81. end
  82. local buy_tip_data = {
  83. gold_type = 1,--货币类型
  84. cost_price = self.need_cost,--消耗金额
  85. ok_callback = ok_callback,--成功
  86. toggle_function = toggle_function,--多选
  87. togglePriceStr = string.format("<#fdffc2>%s</color> 完成充能",self.need_cost),--提示语
  88. use_function = use_function,--最终调用
  89. }
  90. CustomActivityModel:getInstance():BuyTips(buy_tip_data)
  91. end
  92. function SoulPowerChargeView:OpenSuccess()
  93. local sp_grade_condition_cfg = self.model:GetSoulPowerGradeCfgByGrade(self.sp_grade) --当前阶数的额外配置
  94. self.chargeTip_tmp.text = string.format("当前正在充能 <#fdffc2>%s%s层</color>", Trim(sp_grade_condition_cfg.name), self.sp_lv+1)
  95. self:UpdateLeftTime()
  96. end
  97. function SoulPowerChargeView:UpdateLeftTime( )
  98. local time_head, time_tail = self.model:GetSoulPowerTimeHeadTail()
  99. local next_lv_total_time = self.model:GetSoulPowerNextLvNeedTotalTime(self.sp_grade, self.sp_lv)
  100. self.left_time = time_tail - next_lv_total_time - TimeUtil:getServerTime()
  101. if self.left_time < 0 then self.left_time = 0 end
  102. self.leftTime_tmp.text = string.format("剩余时间:<color=#2CF86F>%s</color>",TimeUtil:timeConvert(self.left_time, "hh:mm:ss"))
  103. --充能:剩余时间小于60s时不给充, 充能需求 彩钻 * 向上取整(剩余秒数/300),即5分钟1彩钻
  104. self.need_cost = math.ceil(self.left_time/300)
  105. self.costNum_tmp.text = string.format("确认消耗 %s<#2CF86F>%s</color> 直接完成充能吗?", WordManager:GetMoneyFaceStr(1), self.need_cost)
  106. end
  107. function SoulPowerChargeView:DestroySuccess( )
  108. end