源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

492 行
24 KiB

  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 圣物系统数据寻宝界面
  4. -- *>
  5. PsionicDrawView = PsionicDrawView or BaseClass(BaseItem)
  6. local PsionicDrawView = PsionicDrawView
  7. local math_random = math.random
  8. local cc = cc
  9. local SetAnchoredPositionY = SetAnchoredPositionY
  10. function PsionicDrawView:__init(parent_wnd,prefab_asset,layer_name)
  11. self.base_file = "psionic"
  12. self.layout_file = "PsionicDrawView"
  13. self.parent_wnd = parent_wnd
  14. self.layer_name = layer_name
  15. self.model = PsionicModel:getInstance()
  16. self.goods_model = GoodsModel:getInstance()
  17. -- 抽卡消耗缓存
  18. self.cost_cache = {
  19. [PsionicConst.DrawPoolType.Normal] = {},
  20. [PsionicConst.DrawPoolType.Deep] = {}
  21. }
  22. -- 简化代码用
  23. self.pool_type_str = {
  24. [PsionicConst.DrawPoolType.Normal] = "normal",
  25. [PsionicConst.DrawPoolType.Deep] = "deep"
  26. }
  27. self.anim_item_list = {} -- 参与动画的节点
  28. self:Load()
  29. end
  30. function PsionicDrawView:SetVisible(state, force_hide)
  31. local function visible_callback()
  32. BaseItem.SetVisible(self, state, force_hide)
  33. end
  34. if state then
  35. visible_callback()
  36. self:StartTransCGAlphaAnim(true)
  37. else
  38. lua_resM:clearRoleMode(self)
  39. self:StartTransCGAlphaAnim(false, visible_callback)
  40. end
  41. end
  42. function PsionicDrawView:Load_callback()
  43. local nodes = {
  44. -- 普通寻宝
  45. "normal_cost_icon1:img", "normal_cost_icon2:img",
  46. "normal_one_btn:obj", "normal_ten_btn:obj",
  47. "normal_cost1:tmp", "normal_cost2:tmp",
  48. "normal_free_time:tmp",
  49. "normal_one_red:obj", "normal_ten_red:obj",
  50. "normal_model_con:obj:raw",
  51. "normal_draw_tip:tmp",
  52. "normal_tip_btn:obj",
  53. -- 深度寻宝
  54. "deep_cost_icon1:img", "deep_cost_icon2:img",
  55. "deep_one_btn:obj", "deep_ten_btn:obj",
  56. "deep_cost1:tmp", "deep_cost2:tmp",
  57. "deep_free_time:tmp",
  58. "deep_one_red:obj", "deep_ten_red:obj",
  59. "deep_first_tip:obj",
  60. "deep_model_con:obj:raw",
  61. "deep_draw_tip:tmp",
  62. "deep_tip_btn:obj",
  63. }
  64. self:GetChildren(nodes)
  65. self.transform_cg = self.transform:GetComponent(typeof(UnityEngine.CanvasGroup))
  66. self.normal_draw_tip_tmp.text = string.format("必得极品<color=%s>紫色品质</color>圣物", ColorUtil.PURPLE_DARK)
  67. self.deep_draw_tip_tmp.text = string.format("必得极品<color=%s>橙色品质</color>圣物", ColorUtil.ORANGE_DARK)
  68. SetLocalPositionZ(self.normal_tip_btn, -2000)
  69. SetLocalPositionZ(self.deep_tip_btn, -2000)
  70. -- 获取浮动节点
  71. for i = 1, 8 do
  72. self.anim_item_list[i] = self:GetChild("anim_con/anim_item"..i)
  73. end
  74. self:AddEvents()
  75. self:StartTransCGAlphaAnim(true)
  76. self:UpdateView()
  77. self:CreateRewardsAnim()
  78. self:UpdateRedByPoolType(PsionicConst.DrawPoolType.Normal)
  79. self:UpdateRedByPoolType(PsionicConst.DrawPoolType.Deep)
  80. end
  81. function PsionicDrawView:AddEvents( )
  82. local function click_event(target)
  83. if target == self.normal_one_btn_obj then -- 普通单抽
  84. self:OnDrawBtnClick(PsionicConst.DrawPoolType.Normal, PsionicConst.DrawNumType.OneDraw)
  85. elseif target == self.normal_ten_btn_obj then -- 普通十连
  86. self:OnDrawBtnClick(PsionicConst.DrawPoolType.Normal, PsionicConst.DrawNumType.TenDraw)
  87. elseif target == self.deep_one_btn_obj then -- 深度单抽
  88. self:OnDrawBtnClick(PsionicConst.DrawPoolType.Deep, PsionicConst.DrawNumType.OneDraw)
  89. elseif target == self.deep_ten_btn_obj then -- 深度十连抽
  90. self:OnDrawBtnClick(PsionicConst.DrawPoolType.Deep, PsionicConst.DrawNumType.TenDraw)
  91. elseif target == self.normal_tip_btn_obj then -- 普通池奖励展示
  92. self.model:Fire(PsionicConst.OPEN_DRAW_PREVIEW_VIEW, true, PsionicConst.DrawPoolType.Normal)
  93. elseif target == self.deep_tip_btn_obj then -- 深度池奖励展示
  94. self.model:Fire(PsionicConst.OPEN_DRAW_PREVIEW_VIEW, true, PsionicConst.DrawPoolType.Deep)
  95. end
  96. end
  97. AddClickEvent(self.normal_one_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  98. AddClickEvent(self.normal_ten_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  99. AddClickEvent(self.deep_one_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  100. AddClickEvent(self.deep_ten_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  101. AddClickEvent(self.normal_tip_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  102. AddClickEvent(self.deep_tip_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  103. local function update_dig_data(pool_type, opty_type) -- 抽卡结果需要指定类型,其他的情况则刷新整个界面
  104. if pool_type and opty_type then
  105. if pool_type == PsionicConst.DrawPoolType.Normal then
  106. self:UpdateDrawCostDataByType(PsionicConst.DrawPoolType.Normal)
  107. self:UpdateNormalFreeTimer(PsionicConst.DrawPoolType.Normal)
  108. elseif pool_type == PsionicConst.DrawPoolType.Deep then
  109. self:UpdateDrawCostDataByType(PsionicConst.DrawPoolType.Deep)
  110. self:UpdateNormalFreeTimer(PsionicConst.DrawPoolType.Deep)
  111. end
  112. else
  113. self:UpdateView()
  114. end
  115. end
  116. self:BindEvent(self.model, PsionicConst.UPDATE_DIG_DATA, update_dig_data)
  117. local function update_draw_red(pool_type)
  118. self:UpdateRedByPoolType(pool_type)
  119. end
  120. self:BindEvent(self.model, PsionicConst.UPDATE_DATADIG_RED_BY_TYPE, update_draw_red)
  121. -- 通过更新红点的方式更新抽奖道具表现
  122. local function update_draw_items(tab_id)
  123. if tab_id and tab_id == PsionicConst.TabId.PDataDig then
  124. self:UpdateDrawCostDataByType(PsionicConst.DrawPoolType.Normal)
  125. self:UpdateDrawCostDataByType(PsionicConst.DrawPoolType.Deep)
  126. end
  127. end
  128. self:BindEvent(self.model, PsionicConst.UPDATE_RED_BY_TABID, update_draw_items)
  129. end
  130. function PsionicDrawView:StartTransCGAlphaAnim(show, close_callback)
  131. if not self.is_loaded then return end
  132. self:StopTransCFAlphaAnim()
  133. local target_alpha = show and 1 or 0
  134. self.transform_cg.interactable = false
  135. if show then
  136. self:UpdateDrawModel(PsionicConst.DrawPoolType.Normal)
  137. self:UpdateDrawModel(PsionicConst.DrawPoolType.Deep)
  138. end
  139. local function alpha_anim_callback()
  140. if show then
  141. self.transform_cg.interactable = true
  142. end
  143. end
  144. -- 关闭回调覆盖
  145. if not show and close_callback then
  146. alpha_anim_callback = close_callback
  147. end
  148. self.alpha_anim_id = TweenLite.to(self, self.transform_cg, TweenLite.UiAnimationType.ALPHA_ALL, target_alpha, 0.2, alpha_anim_callback)
  149. end
  150. function PsionicDrawView:StopTransCFAlphaAnim( )
  151. if self.alpha_anim_id then
  152. TweenLite.Stop(self.alpha_anim_id)
  153. self.alpha_anim_id = nil
  154. end
  155. end
  156. function PsionicDrawView:UpdateView( )
  157. -- 加载普通寻宝配置
  158. self.normal_cfg = Config.Nucleonpool[1]
  159. -- 加载深度寻宝配置
  160. self.deep_cfg = Config.Nucleonpool[2]
  161. self:UpdateDrawCostDataByType(PsionicConst.DrawPoolType.Normal)
  162. self:UpdateDrawCostDataByType(PsionicConst.DrawPoolType.Deep)
  163. self:UpdateNormalFreeTimer(PsionicConst.DrawPoolType.Normal)
  164. self:UpdateNormalFreeTimer(PsionicConst.DrawPoolType.Deep)
  165. end
  166. function PsionicDrawView:UpdateDrawModel(pool_type)
  167. local pt = self.pool_type_str[pool_type]
  168. local data = {
  169. father_node = self,
  170. transform = self[pt.."_model_con"],
  171. fashion_type = FuncOpenModel.TypeId.OtherGoods,
  172. figure_id = PsionicConst.DrawShowModel[pool_type],
  173. scale = 300,
  174. can_rotate = false,
  175. action_name_list = {"idle"},
  176. position = Vector3(0, -130, 0),
  177. rotate = Vector3(15,180,0),
  178. ui_model_type = UIModelCommon.ModelType.Model,
  179. }
  180. FuncOpenModel:getInstance():SetModelRes(data)
  181. end
  182. -- 新版调整 根据池子类型不同,直接更新对应池子的消耗物品信息,并缓存每种情况所需要的花费
  183. function PsionicDrawView:UpdateDrawCostDataByType(pool_type)
  184. local cfg_data = pool_type == PsionicConst.DrawPoolType.Normal and self.normal_cfg or self.deep_cfg
  185. local pt = self.pool_type_str[pool_type]
  186. local pool_data = self.model:GetPsionicDigData(pool_type)
  187. -- 当前是否能免费
  188. local can_free = pool_data and pool_data.remain > 0 and pool_data.rtime - TimeUtil:getServerTime() < 0 or false
  189. -- 获取抽奖券数
  190. local single_ticket_num = self.goods_model:GetTypeGoodsNum(cfg_data.one)
  191. local ten_ticket_num = self.goods_model:GetTypeGoodsNum(cfg_data.ten)
  192. local one_cost = stringtotable(cfg_data.cost)[1]
  193. local ten_cost = stringtotable(cfg_data.pay)[1]
  194. -- 单抽券价格
  195. local single_ticket_price = tonumber(one_cost[3])
  196. local single_ticket_price_type = tonumber(one_cost[1])
  197. local one_cost_icon_asset, one_cost_icon_name = WordManager:GetCommonMoneyIcon(single_ticket_price_type)
  198. local ten_cost_icon_asset, ten_cost_icon_name = WordManager:GetCommonMoneyIcon(ten_cost[1])
  199. if pool_type == PsionicConst.DrawPoolType.Normal then -- 普通池子默认展示红钻,有单抽券时显示单抽券
  200. -- 单抽
  201. -- 没有抽奖券的情况
  202. if can_free then
  203. lua_resM:setImageSprite(self, self[pt .. "_cost_icon1_img"], "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
  204. self[pt .. "_cost1_tmp"].text = "免费"
  205. self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {free = true} -- 免费,可以直接抽
  206. -- 有抽奖券,则加载为抽奖券的图标
  207. elseif single_ticket_num > 0 then
  208. lua_resM:setImageSprite(self, self[pt .. "_cost_icon1_img"], "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
  209. self[pt .. "_cost1_tmp"].text = string.format("<color=%s>%s</color>/1",
  210. single_ticket_num > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
  211. single_ticket_num)
  212. self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {goods_id = cfg_data.one} -- 构造数据,扣除道具
  213. else -- 显示为钻石付费
  214. lua_resM:setImageSprite(self, self[pt .. "_cost_icon1_img"], one_cost_icon_asset, one_cost_icon_name, true)
  215. self[pt .. "_cost1_tmp"].text = single_ticket_price
  216. self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {price_type = single_ticket_price_type, cost = single_ticket_price} -- 构造数据,扣除金额
  217. end
  218. -- 十连
  219. -- 有十连券,则加载为十连券的图标
  220. if ten_ticket_num > 0 then
  221. lua_resM:setImageSprite(self, self[pt .. "_cost_icon2_img"], "psionic_asset", "psionic_dig_icon"..pool_type.."_2", true)
  222. self[pt .. "_cost2_tmp"].text = string.format("<color=%s>%s</color>/1", ColorUtil.GREEN_DARK, ten_ticket_num)
  223. self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {goods_id = cfg_data.ten} -- 构造数据,表现为扣除道具
  224. -- 有单抽券,则加载为单抽券,并显示出所需个数相关表现
  225. elseif single_ticket_num > 0 then
  226. lua_resM:setImageSprite(self, self[pt .. "_cost_icon2_img"], "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
  227. self[pt .. "_cost2_tmp"].text = string.format("<color=%s>%s</color>/9",
  228. single_ticket_num >= 9 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
  229. single_ticket_num)
  230. if single_ticket_num >= 9 then -- 单抽券数量足够,表现为扣除道具
  231. self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {goods_id = cfg_data.one} -- 构造数据,表现为扣除道具
  232. else -- 单抽不足,算出差价,表现为补齐单抽
  233. local need_cost = single_ticket_price * (9 - single_ticket_num)
  234. self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {price_type = single_ticket_price_type, cost = need_cost} -- 构造数据,扣除金额
  235. end
  236. -- 普通池子没抽奖券展示红钻
  237. else
  238. lua_resM:setImageSprite(self, self[pt .. "_cost_icon2_img"], ten_cost_icon_asset, ten_cost_icon_name, true)
  239. local need_cost = single_ticket_price * 9
  240. self[pt .. "_cost2_tmp"].text = need_cost
  241. self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {price_type = single_ticket_price_type, cost = need_cost} -- 构造数据,表现为扣除金额
  242. end
  243. else -- 高级池子默认展示道具
  244. -- 单抽
  245. lua_resM:setImageSprite(self, self[pt .. "_cost_icon1_img"], "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
  246. -- 免费单抽
  247. if can_free then
  248. self[pt .. "_cost1_tmp"].text = "免费"
  249. self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {free = true} -- 构造数据,表现为扣除金额
  250. -- 有抽奖券,则加载为抽奖券的图标
  251. else
  252. self[pt .. "_cost1_tmp"].text = string.format("<color=%s>%s</color>/1",
  253. single_ticket_num > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
  254. single_ticket_num)
  255. if single_ticket_num > 0 then
  256. self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {goods_id = cfg_data.one} -- 构造数据,扣除道具
  257. else
  258. self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {price_type = single_ticket_price_type, cost = single_ticket_price} -- 构造数据,扣除金额
  259. end
  260. end
  261. -- 十连
  262. -- 有十连券,就展示十连券的表现
  263. if ten_ticket_num > 0 then
  264. lua_resM:setImageSprite(self, self[pt .. "_cost_icon2_img"], "psionic_asset", "psionic_dig_icon"..pool_type.."_2", true)
  265. self[pt .. "_cost2_tmp"].text = string.format("<color=%s>%s</color>/1", ColorUtil.GREEN_DARK, ten_ticket_num)
  266. self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {goods_id = cfg_data.ten} -- 构造数据,表现为扣除道具
  267. -- 有单抽券,则加载为单抽券,并显示出所需个数相关表现
  268. else
  269. lua_resM:setImageSprite(self, self[pt .. "_cost_icon2_img"], "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
  270. self[pt .. "_cost2_tmp"].text = string.format("<color=%s>%s</color>/9",
  271. single_ticket_num >= 9 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
  272. single_ticket_num)
  273. if single_ticket_num >= 9 then -- 单抽券满足
  274. self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {goods_id = cfg_data.one} -- 构造数据,表现为扣除道具
  275. else
  276. local need_cost = single_ticket_price * (9 - single_ticket_num)
  277. self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {price_type = single_ticket_price_type, cost = need_cost} -- 构造数据,扣除金额
  278. end
  279. end
  280. end
  281. end
  282. function PsionicDrawView:UpdateNormalFreeTimer(pool_type)
  283. local pool_data = self.model:GetPsionicDigData(pool_type)
  284. local cfg_data = pool_type == PsionicConst.DrawPoolType.Normal and self.normal_cfg or self.deep_cfg
  285. local tmp_component = pool_type == PsionicConst.DrawPoolType.Normal and self.normal_free_time_tmp or self.deep_free_time_tmp
  286. if pool_data and cfg_data then
  287. self:ClearFreeTimerByType(pool_type)
  288. -- 今日免费次数
  289. if pool_data.remain > 0 then
  290. -- 免费文本额外内容
  291. local extra_str = string.format("(<color=%s>%s</color>/%s)", ColorUtil.GREEN_DARK, pool_data.remain, cfg_data.free)
  292. if pool_data.rtime <= TimeUtil:getServerTime() then -- 已经过了冷却时间
  293. tmp_component.text = string.format("本日免费%s", extra_str)
  294. else
  295. local function free_timer()
  296. local left_time = pool_data.rtime - TimeUtil:getServerTime()
  297. if left_time > 0 then
  298. tmp_component.text = string.format("%s后免费%s", TimeUtil:convertTime(left_time), extra_str)
  299. else
  300. tmp_component.text = string.format("本日免费%s", extra_str)
  301. self:UpdateDrawCostDataByType(pool_type) -- 更新单抽花费信息
  302. self:ClearFreeTimerByType(pool_type)
  303. end
  304. end
  305. self["free_timer_id" .. pool_type] = GlobalTimerQuest:AddPeriodQuest(free_timer, 0.5, -1)
  306. free_timer()
  307. end
  308. else
  309. tmp_component.text = "今日免费次数已用完"
  310. end
  311. -- 终生免费相关
  312. if pool_type == PsionicConst.DrawPoolType.Deep then
  313. self.deep_first_tip_obj:SetActive(pool_data.isfirst == 0)
  314. end
  315. end
  316. end
  317. function PsionicDrawView:ClearFreeTimerByType(pool_type)
  318. if self["free_timer_id" .. pool_type] then
  319. GlobalTimerQuest:CancelQuest(self["free_timer_id" .. pool_type])
  320. self["free_timer_id" .. pool_type] = nil
  321. end
  322. end
  323. -- 创建画面中的奖励浮动动画
  324. function PsionicDrawView:CreateRewardsAnim( )
  325. local function create_anim(index, node)
  326. cc.ActionManager:getInstance():removeAllActionsFromTarget(node)
  327. local node_pos = node.anchoredPosition
  328. -- 获取配置
  329. local anim_cfg = PsionicConst.DrawAnimData[index]
  330. -- 随机抽取一个进度百分数和方向,然后从这个百分数开始播动画,制造错乱的感觉
  331. local random_percentage = math_random(200, 800) * 0.001
  332. local dir = math_random(0, 10) > 5 -- true为初始朝上,否则朝下
  333. local pos_offset = (anim_cfg.end_pos - anim_cfg.start_pos)
  334. local pos_offset_per = pos_offset * random_percentage
  335. -- 设置起点
  336. SetAnchoredPositionY(node, (dir and anim_cfg.start_pos or anim_cfg.end_pos) + (dir and pos_offset_per or -pos_offset_per))
  337. local function begin_action_up_func(percent)
  338. SetAnchoredPositionY(node, anim_cfg.start_pos + (percent * (1 - random_percentage) + random_percentage) * pos_offset)
  339. end
  340. local function begin_action_down_func(percent)
  341. SetAnchoredPositionY(node, anim_cfg.end_pos - (percent * (1 - random_percentage) + random_percentage) * pos_offset)
  342. end
  343. -- 从随机点到目标点的动画
  344. local action1 = cc.CustomUpdate.New(anim_cfg.anim_time * (1 - random_percentage), dir and begin_action_up_func or begin_action_down_func)
  345. -- 循环动画
  346. local function action_begin_func()
  347. local function action_up_func(percent)
  348. SetAnchoredPositionY(node, anim_cfg.start_pos + percent * pos_offset)
  349. end
  350. local function action_down_func(percent)
  351. SetAnchoredPositionY(node, anim_cfg.end_pos - percent * pos_offset)
  352. end
  353. cc.ActionManager:getInstance():removeAllActionsFromTarget(node)
  354. local action_up = cc.CustomUpdate.New(anim_cfg.anim_time, action_up_func)
  355. local action_down = cc.CustomUpdate.New(anim_cfg.anim_time, action_down_func)
  356. local action_rep
  357. if dir then -- 初始方向是朝上的,循环动画就要从向下开始
  358. action_rep = cc.RepeatForever.New(cc.Sequence.New(action_down, action_up))
  359. else
  360. action_rep = cc.RepeatForever.New(cc.Sequence.New(action_up, action_down))
  361. end
  362. cc.ActionManager:getInstance():addAction(action_rep, node)
  363. end
  364. local action_begin = cc.Sequence.New(action1, cc.CallFunc.New(action_begin_func))
  365. cc.ActionManager:getInstance():addAction(action_begin, node)
  366. end
  367. for k, v in ipairs(self.anim_item_list) do
  368. create_anim(k, v)
  369. end
  370. end
  371. -- 抽奖按钮点击逻辑 pool_type:奖池类型 opty:次数类型
  372. -- 消耗顺序:免费次数(单抽)> 单抽/十连券 > 红钻/彩钻
  373. function PsionicDrawView:OnDrawBtnClick(pool_type, opty)
  374. local cost_data = self.cost_cache[pool_type][opty]
  375. if not cost_data then return end
  376. local price_asset, price_icon, price_color
  377. local price_type, cost_price
  378. local priceText = ""
  379. local insufficientText = nil
  380. local special_icon_data = nil
  381. local cfg_data = pool_type == PsionicConst.DrawPoolType.Normal and self.normal_cfg or self.deep_cfg
  382. local function ok_callback()
  383. self.model:Fire(PsionicConst.REQUEST_CCMD_EVENT, 13911, pool_type, opty)
  384. end
  385. if cost_data.free then -- 免费抽,直接冲
  386. ok_callback()
  387. return
  388. end
  389. local cost_goods_name = self.goods_model:getGoodsName(cfg_data.one, true)
  390. -- 使用抽奖券的情况,提示后直接使用
  391. if cost_data.goods_id then
  392. special_icon_data = true
  393. price_asset = "psionic_asset"
  394. price_icon = "psionic_dig_icon" .. pool_type .. "_" .. opty
  395. price_type = 0
  396. if cost_data.goods_id == cfg_data.one then -- 单抽券需要区分抽奖次数,十连券每次消耗1张
  397. cost_price = opty == PsionicConst.DrawNumType.TenDraw and 9 or 1
  398. else
  399. cost_price = 1
  400. end
  401. price_color = self.goods_model:GetGoodsColor(cost_data.goods_id)
  402. priceText = string.format("<color=%s>%s</color> %s %s寻宝%s次?", price_color, cost_price, cost_goods_name,
  403. pool_type == PsionicConst.DrawPoolType.Deep and "深度" or "普通",
  404. opty == PsionicConst.DrawNumType.TenDraw and 10 or 1)
  405. else -- 需要使用钻石补足的情况
  406. price_type = cost_data.price_type
  407. cost_price = cost_data.cost
  408. price_asset, price_icon = WordManager:GetCommonMoneyIcon(price_type)
  409. -- price_color = WordManager.GetGoodsColor(pool_type == PsionicConst.DrawPoolType.Deep and 4 or 3)
  410. price_color = ColorUtil.YELLOW_DARK
  411. if pool_type == PsionicConst.DrawPoolType.Deep then -- 统一用抽奖券表现
  412. insufficientText = string.format("%s 不足", cost_goods_name)
  413. priceText = string.format("<color=%s>%s</color> 补齐 %s %s寻宝%s次?", price_color, cost_price, cost_goods_name,
  414. pool_type == PsionicConst.DrawPoolType.Deep and "深度" or "普通",
  415. opty == PsionicConst.DrawNumType.TenDraw and 10 or 1)
  416. else
  417. priceText = string.format("<color=%s>%s</color> %s寻宝%s次?", price_color, cost_price,
  418. pool_type == PsionicConst.DrawPoolType.Deep and "深度" or "普通",
  419. opty == PsionicConst.DrawNumType.TenDraw and 10 or 1)
  420. end
  421. end
  422. local function use_function( toggle_tip_data, call_fun_sum )
  423. if not self.model._dont_check_psionic_draw_tip[pool_type] then
  424. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data)
  425. else
  426. call_fun_sum()
  427. end
  428. end
  429. local data = {
  430. insufficientText = insufficientText,
  431. special_icon_data = special_icon_data,
  432. gold_type = price_type,
  433. cost_price = cost_price,
  434. ok_callback = ok_callback,
  435. togglePriceStr = priceText,
  436. use_function = use_function,
  437. toggle_function = function(flag)
  438. self.model._dont_check_psionic_draw_tip[pool_type] = flag
  439. end,
  440. }
  441. CustomActivityModel:getInstance():BuyTips(data)
  442. end
  443. function PsionicDrawView:UpdateRedByPoolType(pool_type)
  444. local pt = self.pool_type_str[pool_type]
  445. local red_cache = self.model:GetPsionicDataDigPoolRedCache(pool_type)
  446. local single_red, ten_red
  447. if red_cache then
  448. single_red = red_cache.free_red or red_cache.single_red or false
  449. ten_red = red_cache.ten_red or false
  450. end
  451. self[pt.."_one_red_obj"]:SetActive(single_red)
  452. self[pt.."_ten_red_obj"]:SetActive(ten_red)
  453. end
  454. function PsionicDrawView:__delete( )
  455. self:ClearFreeTimerByType(PsionicConst.DrawPoolType.Normal)
  456. self:ClearFreeTimerByType(PsionicConst.DrawPoolType.Deep)
  457. self:StopTransCFAlphaAnim()
  458. -- 销毁动画
  459. for k, v in pairs(self.anim_item_list) do
  460. cc.ActionManager:getInstance():removeAllActionsFromTarget(v)
  461. end
  462. end