源战役客户端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

294 satır
9.8 KiB

  1. ChildHeartTaskView = ChildHeartTaskView or BaseClass(BaseView)
  2. local ChildHeartTaskView = ChildHeartTaskView
  3. function ChildHeartTaskView:__init()
  4. self.base_file = "child"
  5. self.layout_file = "ChildHeartTaskView"
  6. self.layer_name = "UI"
  7. self.destroy_imm = true
  8. self.use_background = G_USING_BG --全屏界面默认使用这个参数
  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.fire_change_visible_event = true
  14. self.blur_activity_bg = true
  15. self.close_fog = true
  16. self.task_item_list = {} -- 同心每日任务item
  17. self.reward_item_list = {} -- 奖励item
  18. self.model = ChildModel:getInstance()
  19. self.model:ChangeHeartTaskChildSex( )
  20. self.load_callback = function ()
  21. self:LoadSuccess()
  22. self:AddEvent()
  23. end
  24. self.open_callback = function ( )
  25. self:OpenSuccess()
  26. end
  27. self.switch_callback = function(index)
  28. self:SwitchTab(index)
  29. end
  30. self.destroy_callback = function ( )
  31. self:DestroySuccess()
  32. end
  33. end
  34. function ChildHeartTaskView:Open( )
  35. --self.data = data
  36. BaseView.Open(self)
  37. end
  38. function ChildHeartTaskView:LoadSuccess()
  39. local nodes = {
  40. "taskScroll/Viewport/taskCon", "taskScroll", "rewardCon",
  41. "fillImg:img", "heartValue:txt","close:obj", "modelCon",
  42. "bg:raw", "tipDes:tmp", "modelCon2", "btn_buy:obj:img",
  43. -- "btn_buy/lb_btn_buy:tmp",
  44. "btn_buy/con_btn_buy_effect",
  45. "black_bg:obj", "black_bg/lb_price:tmp",
  46. }
  47. self:GetChildren(nodes)
  48. self:UpdateBaseView( )
  49. end
  50. function ChildHeartTaskView:UpdateBaseView( )
  51. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("child_heart_bg_1186_601"), false)
  52. self.tipDes_tmp.text = string.format("任务每日%s刷新", HtmlColorTxt( "04:00", ColorUtil.GREEN_DARK))
  53. local function bg_back_func( ... )
  54. if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  55. self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  56. end
  57. self:MoveUIToBack(self.bg_raw)
  58. end
  59. if self.background_wnd then
  60. bg_back_func()
  61. else
  62. self.bg_back_func = bg_back_func
  63. end
  64. local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
  65. self.btn_buy_obj:SetActive(open_day >= 6) -- 开服6天后开放这个
  66. self.lb_price_tmp.text = ""
  67. if open_day >= 6 then
  68. SetAnchoredPositionY(self.con_btn_buy_effect, 2.5)
  69. self:AddUIEffect("ui_effect_shouchong05_2", self.con_btn_buy_effect, self.layer_name, nil, 0.9, false,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UIBackward)
  70. end
  71. end
  72. function ChildHeartTaskView:AddEvent()
  73. local on_click = function ( click_obj )
  74. if self.close_obj == click_obj then
  75. self:Close()
  76. elseif self.btn_buy_obj == click_obj then
  77. local cur_heart_value = self.child_info.heart_link_exp or 0
  78. local buy_count = self.model:GetMaxHeartValue() - cur_heart_value
  79. if buy_count <= 0 then
  80. Message.show("同心值已满,请尽快领取奖励!")
  81. return
  82. end
  83. local price_cfg = Config.Goodsprice[260001] -- 同心值价值配在价格表
  84. local per_heart_link_price = price_cfg.price
  85. local ask_str = string.format('%s 补充 %s点 同心值?',
  86. HtmlColorTxt(buy_count * per_heart_link_price, ColorUtil.YELLOW_DARK),
  87. HtmlColorTxt(buy_count, ColorUtil.YELLOW_DARK) )
  88. local function ok_callback( )
  89. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16506, 3, 0, 0)
  90. end
  91. local function use_function( toggle_tip_data,call_fun_sum )
  92. if not self.model.recovery_toggle then
  93. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data)
  94. else
  95. call_fun_sum()
  96. end
  97. end
  98. local buy_tip_data = {
  99. gold_type = price_cfg.price_type,--货币类型
  100. cost_price = buy_count * per_heart_link_price,--消耗金额
  101. ok_callback = ok_callback,--成功
  102. togglePriceStr = ask_str,--提示语
  103. use_function = use_function,--最终调用
  104. no_need_toggle = true,
  105. }
  106. CustomActivityModel:getInstance():BuyTips(buy_tip_data)
  107. end
  108. end
  109. AddClickEvent(self.close_obj, on_click)
  110. AddClickEvent(self.btn_buy_obj, on_click)
  111. -- 更新任务
  112. local function updata_child_task_info_fun()
  113. self:UpdateTaskCon()
  114. end
  115. self.updata_child_task_info_id = self.model:Bind(ChildConst.UPDATA_CHILD_TASK_INFO, updata_child_task_info_fun)
  116. -- 更新同心值
  117. local function update_heart_link_value()
  118. self:UpdateHeartLink( )
  119. self:UpdateRewardCon( )
  120. end
  121. self.update_heart_link_value_id = self.model:Bind(ChildConst.UPDATE_HEART_LINK_VALUE, update_heart_link_value)
  122. -- 更新同心奖励状态
  123. local function update_heartlink_reward_status()
  124. self:UpdateRewardCon( )
  125. end
  126. self.update_heartlink_reward_status_id = self.model:Bind(ChildConst.UPDATE_HEARTLINK_REWARD_STATUS, update_heartlink_reward_status)
  127. end
  128. -- 更新孩子模型
  129. function ChildHeartTaskView:UpdateRoleModel( )
  130. -- local child_sex = self.model:GetHeartTaskChildSex( )
  131. SetLocalPositionX(self.modelCon, -248 + 82)
  132. SetLocalPositionX(self.modelCon2, -248 - 82)
  133. local show_figure_id = self.model:GetChildOriginalModelID(1)
  134. local res_data = {
  135. father_node = self,
  136. transform = self.modelCon,
  137. fashion_type = FuncOpenModel.TypeId.Child,
  138. figure_id = show_figure_id,
  139. ui_model_type = UIModelCommon.ModelType.BackModel,
  140. can_rotate = false,
  141. scale = 400
  142. }
  143. FuncOpenModel:getInstance():SetModelRes(res_data)
  144. local show_figure_id = self.model:GetChildOriginalModelID(2)
  145. local res_data = {
  146. father_node = self,
  147. transform = self.modelCon2,
  148. fashion_type = FuncOpenModel.TypeId.Child,
  149. figure_id = show_figure_id,
  150. ui_model_type = UIModelCommon.ModelType.BackModel,
  151. can_rotate = false,
  152. scale = 400
  153. }
  154. FuncOpenModel:getInstance():SetModelRes(res_data)
  155. end
  156. function ChildHeartTaskView:OpenSuccess()
  157. self:UpdateView()
  158. end
  159. function ChildHeartTaskView:UpdateView()
  160. self:UpdateHeartLink( )
  161. self:UpdateTaskCon()
  162. self:UpdateRewardCon()
  163. self:UpdateRoleModel( )
  164. end
  165. function ChildHeartTaskView:UpdateShowPrice( )
  166. local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
  167. local need_show = false
  168. if open_day >= 6 then
  169. local cur_heart_value = self.child_info.heart_link_exp or 0
  170. local buy_count = self.model:GetMaxHeartValue() - cur_heart_value
  171. local price_cfg = Config.Goodsprice[260001] -- 同心值价值配在价格表
  172. local per_heart_link_price = price_cfg.price
  173. if buy_count > 0 then
  174. need_show = true
  175. self.lb_price_tmp.text = WordManager:GetMoneyFaceStr( 2 ) .. HtmlColorTxt( (per_heart_link_price * buy_count), ColorUtil.YELLOW_DARK)
  176. end
  177. end
  178. self.black_bg_obj:SetActive(need_show)
  179. end
  180. -- 更新同心值
  181. function ChildHeartTaskView:UpdateHeartLink( )
  182. self.child_info = self.model:GetChildInfo()
  183. if not self.child_info then
  184. -- logWarn('=======Msh:ChildHeartTaskView.lua[67]====没有宝宝信息哦===')
  185. return
  186. end
  187. local info = self.child_info
  188. local exp = info.heart_link_exp or 0
  189. exp = Mathf.Clamp(exp, 0, self.model:GetMaxHeartValue())
  190. -- 当前同心值
  191. self.heartValue_txt.text = exp
  192. -- 同心进度条
  193. self.fillImg_img.fillAmount = exp / self.model:GetMaxHeartValue()
  194. if self.model:IsHeartValueMax() then
  195. SetImageGray(self.btn_buy_img, true)
  196. -- SetTMPSharedMaterial(self.lb_btn_buy_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
  197. else
  198. SetImageGray(self.btn_buy_img, false)
  199. -- SetTMPSharedMaterial(self.lb_btn_buy_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
  200. end
  201. self:UpdateShowPrice()
  202. end
  203. -- 每日任务
  204. function ChildHeartTaskView:UpdateTaskCon( )
  205. local ITEM_HEIGHT = 83
  206. local INTERVAL_X = 5
  207. local count = 0
  208. -- logWarn('=======Msh:ChildHeartTaskView.lua[97]=======')
  209. -- PrintTable(self.model:GetChildDailyTaskList())
  210. local index = 0
  211. for i, v in ipairs(self.model:GetChildDailyTaskList()) do
  212. if v.task_id ~= 11 then -- 11 是孩子培养任务 不需要显示
  213. index = index + 1
  214. local item = self.task_item_list[index]
  215. if item == nil then
  216. item = ChildMainTaskItem.New(self.taskCon)
  217. self.task_item_list[index] = item
  218. end
  219. item:SetData(v)
  220. -- item:SetAnchoredPosition(0, -(index - 1) * (INTERVAL_X + ITEM_HEIGHT))
  221. end
  222. end
  223. -- SetSizeDeltaY(self.taskCon, index * (INTERVAL_X + ITEM_HEIGHT))
  224. end
  225. -- 同心阶段奖励
  226. function ChildHeartTaskView:UpdateRewardCon( )
  227. --local reward_list = self.model:GetHeartRewardData( )
  228. local FILLIMG_WIDTH = GetSizeDeltaX(self.fillImg)
  229. local PER_WIDTH = FILLIMG_WIDTH / self.model:GetMaxHeartValue()
  230. local click_callback = function (reward_id)
  231. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16539, 1, reward_id)
  232. end
  233. for heart_value, data in pairsByKeys(self.model:GetChildLinkHeartInfo()) do
  234. local item = self.reward_item_list[heart_value]
  235. if item == nil then
  236. item = ChildHeartRewardItem.New(self.rewardCon)
  237. self.reward_item_list[heart_value] = item
  238. end
  239. item:SetData(data, click_callback)
  240. item:SetAnchoredPosition( heart_value * PER_WIDTH, 0)
  241. end
  242. end
  243. function ChildHeartTaskView:SwitchTab( index )
  244. end
  245. function ChildHeartTaskView:DestroySuccess( )
  246. for i,v in pairs(self.task_item_list) do
  247. v:DeleteMe()
  248. end
  249. for i,v in pairs(self.reward_item_list) do
  250. v:DeleteMe()
  251. end
  252. if self.updata_child_task_info_id then
  253. self.model:UnBind(self.updata_child_task_info_id)
  254. self.updata_child_task_info_id = nil
  255. end
  256. if self.update_heart_link_value_id then
  257. self.model:UnBind(self.update_heart_link_value_id)
  258. self.update_heart_link_value_id = nil
  259. end
  260. if self.update_heartlink_reward_status_id then
  261. self.model:UnBind(self.update_heartlink_reward_status_id)
  262. self.update_heartlink_reward_status_id = nil
  263. end
  264. self:ClearUIEffect(self.con_btn_buy_effect)
  265. end