UIStarSignTipsView.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. local UIStarSignTipsView = require("UISeason/UIStarSignTipsView_Generate")
  2. local IconItemCtr = require("Common/IconItemCtr")
  3. local updateHandle
  4. local scrollRect
  5. local animSpeed = {2,1,0.5,0.2}
  6. local RewardList = {}
  7. function UIStarSignTipsView:OnAwake(data)
  8. self.controller = require("UISeason/UIStarSignTipsCtr"):new()
  9. self.controller:Init(self)
  10. self.controller:SetData(data)
  11. end
  12. function UIStarSignTipsView:AddEventListener()
  13. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  14. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ITEM_CHANGE, self, self.InitCurrency)
  15. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.DIAMOND_CHANGED, self, self.InitGold)
  16. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.STAR_SIGN_CHANGE, self, self.OnAstroReqBack)
  17. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.STAR_SIGN_INIT, self, self.OnStartInfoInit)
  18. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SEASON_EXCHANGE_NTF,self, self.OnStartScoreInit)
  19. end
  20. function UIStarSignTipsView:FillContent(data, uiBase)
  21. self.uiBase = uiBase
  22. local gameObject = self.uiBase:GetRoot()
  23. if gameObject ~= nil then
  24. self.gameObject = gameObject
  25. self.transform = gameObject.transform
  26. end
  27. self:InitGenerate(self.transform, data)
  28. self:Init()
  29. end
  30. function UIStarSignTipsView:OnStartInfoInit()
  31. local activeList = ManagerContainer.DataMgr.StarSignData:GetStarActiveListData()
  32. for i = 1, 12 do
  33. if activeList and activeList[i] then
  34. self["sign"..i].animator:Play("StarLightKeep")
  35. else
  36. self["sign"..i].animator:Play("StarLightOffKeep")
  37. end
  38. end
  39. for i = 1, 12 do
  40. self.rewardsBox["item"..i].current:SetActive(false)
  41. end
  42. self.btnAstrology.button.interactable = true
  43. self.btnGetRewards.button.interactable = true
  44. self.btnUseLucky.toggle.interactable = true
  45. local count = ManagerContainer.DataMgr.StarSignData:GetStarActiveCount()
  46. CommonUtil.SetTotalChildrenGray(self.btnAstrology,count == 12)
  47. self.btnAstrology.button.interactable = count ~= 12
  48. self:InitReward()
  49. end
  50. function UIStarSignTipsView:OnStartScoreInit(delta)
  51. if delta and delta > 0 then
  52. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam("CompetitionTip4", delta)
  53. end
  54. local curCompetitionData = ManagerContainer.DataMgr.CompetitionData:GetCurCompetitionData()
  55. self.scoreInfo.num1.text.text = tostring(curCompetitionData.comParam)
  56. local delta
  57. if curCompetitionData.nextComScore > 0 then
  58. delta = curCompetitionData.nextComScore - curCompetitionData.comParam
  59. self.scoreInfo.text2.text.text = I18N.SetLanguageValue("DscSeasonScoreNext")
  60. self.scoreInfo.num2:SetActive(true)
  61. self.scoreInfo.text2:SetActive(true)
  62. else
  63. if curCompetitionData.lastComScore > 0 then
  64. self.scoreInfo.text2.text.text = I18N.SetLanguageValue("DscSeasonScoreSecond")
  65. delta = curCompetitionData.comParam - curCompetitionData.lastComScore
  66. self.scoreInfo.num2:SetActive(true)
  67. self.scoreInfo.text2:SetActive(true)
  68. else
  69. self.scoreInfo.num2:SetActive(false)
  70. self.scoreInfo.text2:SetActive(false)
  71. end
  72. end
  73. self.scoreInfo.num2.text.text = delta
  74. end
  75. function UIStarSignTipsView:Init()
  76. self:InitData()
  77. self:InitCurrency()
  78. self:InitGold()
  79. self:InitReward()
  80. self:InitRewardList()
  81. self:OnStartScoreInit()
  82. ManagerContainer.DataMgr.StarSignData:SendStarInfoReq()
  83. if not updateHandle then
  84. updateHandle = UpdateBeat:CreateListener(self.Update, self)
  85. end
  86. UpdateBeat:AddListener(updateHandle)
  87. end
  88. function UIStarSignTipsView:InitCurrency()
  89. local num1 = CommonUtil.GetOwnResCountByItemId(202)
  90. local num2 = CommonUtil.GetOwnResCountByItemId(201)
  91. local count = ManagerContainer.DataMgr.StarSignData:GetStarActiveCount()
  92. self.currency1.number.text.text = CommonUtil.FormatNumber(num1)
  93. self.currency2.number.text.text = CommonUtil.FormatNumber(num2)
  94. self:RefreshItemNum(count)
  95. end
  96. function UIStarSignTipsView:InitGold()
  97. local num = CommonUtil.GetOwnResCountByItemId(2)
  98. self.currency3.number.text.text = CommonUtil.FormatNumber(num)
  99. end
  100. function UIStarSignTipsView:RewardMove()
  101. if not self.isMove then
  102. return
  103. end
  104. local count = ManagerContainer.DataMgr.StarSignData:GetStarActiveCount()
  105. if self.currCount > 0 then
  106. self.rewardsBox["item"..self.currCount].current:SetActive(false)
  107. end
  108. self.currCount = count
  109. self:RefreshItemNum(count)
  110. if not self:IsCanUseLuck() then
  111. self.btnUseLucky.toggle.isOn = false
  112. end
  113. if count == 0 then
  114. return
  115. end
  116. if count > 3 and count < 11 then
  117. local pos
  118. if count == 10 then
  119. pos = Vector3(-25-160*(count-3),-150,0)
  120. else
  121. pos = Vector3(-15-160*(count-3),-150,0)
  122. end
  123. self.rewardsBox.content.rectTransform.localPosition = Vector3.MoveTowards(self.rewardsBox.content.rectTransform.localPosition,pos,Time.deltaTime*300)
  124. if Vector3.Distance(self.rewardsBox.content.rectTransform.localPosition,pos) < 0.1 then
  125. self.btnAstrology.button.interactable = true
  126. self.btnGetRewards.button.interactable = true
  127. self.btnUseLucky.toggle.interactable = true
  128. self.rewardsBox.content.rectTransform.localPosition = pos
  129. self.rewardsBox["item"..count].current:SetActive(true)
  130. self.isMove = false
  131. end
  132. else
  133. self.btnAstrology.button.interactable = true
  134. self.btnGetRewards.button.interactable = true
  135. self.btnUseLucky.toggle.interactable = true
  136. self.isMove = false
  137. self.rewardsBox["item"..count].current:SetActive(true)
  138. end
  139. if count == 12 then
  140. CommonUtil.SetTotalChildrenGray(self.btnAstrology,true)
  141. self.btnAstrology.button.interactable = false
  142. end
  143. end
  144. function UIStarSignTipsView:InitReward(isrefreshPos)
  145. local count = ManagerContainer.DataMgr.StarSignData:GetStarActiveCount()
  146. self.btnGetRewards.button.interactable = not (count == 0) and not isrefreshPos
  147. CommonUtil.SetTotalChildrenGray(self.btnGetRewards,count == 0)
  148. if not self:IsCanUseLuck() then
  149. self.btnUseLucky.toggle.isOn = false
  150. end
  151. self:RefreshItemNum(count)
  152. if count == 0 then
  153. self.rewardsBox.content.rectTransform.localPosition = Vector3(0,-150,0)
  154. return
  155. end
  156. if isrefreshPos then
  157. return
  158. end
  159. if self.currCount > 0 then
  160. self.rewardsBox["item"..self.currCount].current:SetActive(false)
  161. end
  162. self.currCount = count
  163. if count == 1 or count == 2 or count == 3 then
  164. self.rewardsBox.content.rectTransform.localPosition = Vector3(0,-150,0)
  165. elseif count == 10 or count == 11 or count == 12 then
  166. self.rewardsBox.content.rectTransform.localPosition = Vector3(-25-160*7,-150,0)
  167. else
  168. self.rewardsBox.content.rectTransform.localPosition = Vector3(-15-160*(count-3),-150,0)
  169. end
  170. self.rewardsBox["item"..self.currCount].current:SetActive(true)
  171. end
  172. function UIStarSignTipsView:RefreshItemNum(count)
  173. local CompetitionDevineCfg = ManagerContainer.CfgMgr:GetCompetitionDevineCfgById(count + 1)
  174. if CompetitionDevineCfg and CompetitionDevineCfg.ItemPrice then
  175. local num = CommonUtil.GetOwnResCountByItemId(CompetitionDevineCfg.ItemPrice[1][1])
  176. local itemcost = CompetitionDevineCfg.ItemPrice[1][2]
  177. if num >= itemcost then
  178. local cfgData = ManagerContainer.CfgMgr:GetItemById(CompetitionDevineCfg.ItemPrice[1][1])
  179. CommonUtil.LoadIcon(self, cfgData.Icon, function (sprite)
  180. self.btnAstrology.image.image.sprite = sprite
  181. end)
  182. self.btnAstrology.num.text.text = itemcost
  183. else
  184. if CompetitionDevineCfg.GoldPrice then
  185. local goldnum = CommonUtil.GetOwnResCountByItemId(CompetitionDevineCfg.GoldPrice[1][1])
  186. local cfgData = ManagerContainer.CfgMgr:GetItemById(CompetitionDevineCfg.GoldPrice[1][1])
  187. CommonUtil.LoadIcon(self, cfgData.Icon, function (sprite)
  188. self.btnAstrology.image.image.sprite = sprite
  189. end)
  190. local goldcost = CompetitionDevineCfg.GoldPrice[1][2]
  191. if goldnum >= goldcost then
  192. self.btnAstrology.num.text.text = goldcost
  193. else
  194. self.btnAstrology.num.text.text = "<color=red>"..goldcost.."</color>"
  195. end
  196. else
  197. self.btnAstrology.num.text.text = I18N.SetLanguageValue("CannotUseDevinecoinNum")
  198. end
  199. end
  200. local IsCanUseLuck,CompetitionDevineCfg = self:IsCanUseLuck()
  201. if not IsCanUseLuck then
  202. self.btnUseLucky.text.text.text = I18N.SetLanguageValue("CannotUseLuckyCharmNum")
  203. self.txt.text.text = I18N.SetLanguageValue("CannotUseLuckyCharm")
  204. else
  205. self.txt.text.text = I18N.SetLanguageValue("BtnUseLucky")
  206. local num2 = CommonUtil.GetOwnResCountByItemId(CompetitionDevineCfg.LuckyPrice[1][1])
  207. local luckycost = CompetitionDevineCfg.LuckyPrice[1][2]
  208. if num2 >= luckycost then
  209. self.btnUseLucky.text.text.text = luckycost
  210. else
  211. self.btnUseLucky.toggle.isOn = false
  212. self.btnUseLucky.text.text.text = "<color=red>"..luckycost.."</color>"
  213. end
  214. end
  215. end
  216. end
  217. function UIStarSignTipsView:InitRewardList()
  218. if RewardList and #RewardList > 0 then
  219. for i = 1, #RewardList do
  220. self.rewardsBox["item"..i].num.text.text = i
  221. IconItemCtr:SetData(self, self.rewardsBox["item"..i].iconSmallItem, RewardList[i], nil, self, self.OnClickItem)
  222. end
  223. else
  224. for i = 2, 13 do
  225. local data = ManagerContainer.CfgMgr:GetCompetitionDevineCfgById(i)
  226. local reward = data and data.Rewards and data.Rewards[1]
  227. local rewardData = {cfgId = reward[1], num = reward[2] }
  228. table.insert(RewardList,rewardData)
  229. self.rewardsBox["item"..(i - 1)].num.text.text = (i - 1)
  230. IconItemCtr:SetData(self, self.rewardsBox["item"..(i - 1)].iconSmallItem, rewardData, nil, self, self.OnClickItem)
  231. end
  232. end
  233. end
  234. function UIStarSignTipsView:OnClickItem(btn,params)
  235. local logicData = params[0]
  236. ManagerContainer.LuaUIMgr:OpenTips(logicData)
  237. end
  238. function UIStarSignTipsView:InitData()
  239. self.currCount = 0
  240. self.timer = 3
  241. self.upOffset = 120
  242. self.isTurn = false
  243. self.data = {}
  244. self.btnGift:SetActive(Constant.OpenPay or false)
  245. self.scrollBox.arrowAnim.animator:Play("ArrowMove",-1,0)
  246. self.scrollBox.arrowAnim.animator.speed = 0
  247. self.fx_uistarsigntipseffect_01.uIParticle:PlayCachedParticalSystem(false)
  248. self.fx_uistarsigntipseffect_02.uIParticle:PlayCachedParticalSystem(false)
  249. self.btnAstrology.button.interactable = false
  250. self.btnGetRewards.button.interactable = false
  251. self.btnUseLucky.toggle.interactable = false
  252. self.taggetPos = nil
  253. scrollRect = self.scroll.transform
  254. for i = 1, 12 do
  255. self.rewardsBox["item"..i].current:SetActive(false)
  256. end
  257. self.stopAnim:SetActive(false)
  258. end
  259. function UIStarSignTipsView:Update()
  260. if self.isTurn then
  261. self.timer = self.timer - Time.deltaTime
  262. if self.timer > 2 then
  263. scrollRect:Translate(Vector3.down*Time.deltaTime*8)
  264. elseif self.timer > 1 then
  265. self.scrollBox.arrowAnim.animator.speed = animSpeed[2]
  266. scrollRect:Translate(Vector3.down*Time.deltaTime*6)
  267. elseif self.timer > 0 then
  268. self.fx_uistarsigntipseffect_02.uIParticle:PlayCachedParticalSystem(false)
  269. self.scrollBox.arrowAnim.animator.speed = animSpeed[3]
  270. scrollRect:Translate(Vector3.down*Time.deltaTime*3)
  271. else
  272. self.scrollBox.arrowAnim.animator.speed = animSpeed[4]
  273. scrollRect:Translate(Vector3.down*Time.deltaTime*1.5)
  274. if Vector3.Distance(scrollRect.localPosition,self.targetPos) < 15 then
  275. self:OnTurnStop()
  276. end
  277. end
  278. if scrollRect.localPosition.y <= -720 then
  279. scrollRect.localPosition = Vector3.New(0,720,0)
  280. end
  281. end
  282. self:RewardMove()
  283. end
  284. function UIStarSignTipsView:OnClickClose()
  285. if self.isTurn then
  286. self:OnTurnStop(true)
  287. end
  288. self:UIClose()
  289. end
  290. function UIStarSignTipsView:OnClickGiftShop()
  291. local IsOver = ManagerContainer.DataMgr.CompetitionData:IsOveerCurSeason()
  292. if IsOver then
  293. self:PopErrorTips('LabelOver')
  294. return
  295. end
  296. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRuneShopBT, {Enum.RuneShopType.LimitTime}, self.uiData.id)
  297. self:UIClose()
  298. end
  299. function UIStarSignTipsView:OnClickRewardsList()
  300. local IsOver = ManagerContainer.DataMgr.CompetitionData:IsOveerCurSeason()
  301. if IsOver then
  302. self:PopErrorTips('LabelOver')
  303. return
  304. end
  305. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIStarRewardsTips,RewardList)
  306. end
  307. function UIStarSignTipsView:OnClickPlayRule()
  308. local IsOver = ManagerContainer.DataMgr.CompetitionData:IsOveerCurSeason()
  309. if IsOver then
  310. self:PopErrorTips('LabelOver')
  311. return
  312. end
  313. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPlayRule, {'StarSignTitle', "StarSignDescText"})
  314. end
  315. function UIStarSignTipsView:OnClickGetRewards()
  316. local IsOver = ManagerContainer.DataMgr.CompetitionData:IsOveerCurSeason()
  317. if IsOver then
  318. self:PopErrorTips('LabelOver')
  319. return
  320. end
  321. local count = ManagerContainer.DataMgr.StarSignData:GetStarActiveCount()
  322. if count == 0 then
  323. return
  324. end
  325. local idx = RewardList[count] and RewardList[count].cfgId
  326. local cfgdata = ManagerContainer.CfgMgr:GetItemById(idx)
  327. local param
  328. if RewardList[count].num > 1 then
  329. param = cfgdata.Name.." X "..RewardList[count].num
  330. else
  331. param = cfgdata.Name
  332. end
  333. ManagerContainer.LuaUIMgr:ShowMessageBox("StarSignTip",{param},nil, self, self.OnSureGetReward)
  334. end
  335. function UIStarSignTipsView:OnSureGetReward()
  336. local IsOver = ManagerContainer.DataMgr.CompetitionData:IsOveerCurSeason()
  337. if IsOver then
  338. self:PopErrorTips('LabelOver')
  339. return
  340. end
  341. self.btnAstrology.button.interactable = true
  342. CommonUtil.SetTotalChildrenGray(self.btnAstrology,false)
  343. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_COMPETITION_STAR_CLOSE_REWARD_REQ)
  344. end
  345. function UIStarSignTipsView:OnClickSkip()
  346. self:OnTurnStop()
  347. end
  348. function UIStarSignTipsView:OnTurnStop(isPlayAnim)
  349. local target = ManagerContainer.DataMgr.StarSignData:GetStarTargetData()
  350. scrollRect.localPosition = Vector3.New(0,-720+120*target,0)
  351. self.isTurn = false
  352. self.timer = 3
  353. self.btnSkip:SetActive(false)
  354. self.scrollBox.arrowAnim.animator.speed = 0
  355. if not isPlayAnim then
  356. self.stopAnim:SetActive(true)
  357. end
  358. self.fx_uistarsigntipseffect_01.uIParticle:PlayCachedParticalSystem(false)
  359. self.fx_uistarsigntipseffect_02.uIParticle:PlayCachedParticalSystem(false)
  360. self.scrollBox.arrowAnim.animator:Play("ArrowMove",-1,0)
  361. local activeList = ManagerContainer.DataMgr.StarSignData:GetStarActiveListData()
  362. if not ManagerContainer.DataMgr.StarSignData:GetStarActiveLightData() then
  363. self["sign"..target].animator:Play("StarLightOff")
  364. else
  365. self["sign"..target].animator:Play("StarLightShow")
  366. end
  367. self.isMove = true
  368. end
  369. function UIStarSignTipsView:OnClickAstrology()
  370. local IsOver = ManagerContainer.DataMgr.CompetitionData:IsOveerCurSeason()
  371. if IsOver then
  372. self:PopErrorTips('LabelOver')
  373. return
  374. end
  375. if self:IsCanAugur() and not self.isTurn then
  376. self.btnAstrology.button.interactable = false
  377. self.btnGetRewards.button.interactable = false
  378. self.btnUseLucky.toggle.interactable = false
  379. if self.btnUseLucky.toggle.isOn then
  380. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_COMPETITION_STAR_DIVINE_REQ,{use_ticket = true})
  381. else
  382. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_COMPETITION_STAR_DIVINE_REQ,{use_ticket = false})
  383. end
  384. end
  385. end
  386. function UIStarSignTipsView:IsCanAugur()
  387. local count = ManagerContainer.DataMgr.StarSignData:GetStarActiveCount()
  388. local CompetitionDevineCfg = ManagerContainer.CfgMgr:GetCompetitionDevineCfgById(count + 1)
  389. if CompetitionDevineCfg and CompetitionDevineCfg.ItemPrice then
  390. if self:IsCanCost(CompetitionDevineCfg.ItemPrice[1]) then
  391. return true
  392. else
  393. if CompetitionDevineCfg.GoldPrice and self:IsCanCost(CompetitionDevineCfg.GoldPrice[1]) then
  394. return true
  395. else
  396. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam(CommonUtil.GetItemNotEnoughInfo(CompetitionDevineCfg.GoldPrice[1][1]))
  397. return false
  398. end
  399. end
  400. end
  401. return false
  402. end
  403. function UIStarSignTipsView:IsCanCost(CostPrice)
  404. if CostPrice then
  405. local num = CommonUtil.GetOwnResCountByItemId(CostPrice[1])
  406. if num >= CostPrice[2] then
  407. return true
  408. else
  409. return false
  410. end
  411. end
  412. return false
  413. end
  414. function UIStarSignTipsView:OnAstroReqBack()
  415. self:InitReward(true)
  416. self.isTurn = true
  417. self.timer = 3
  418. self.target = ManagerContainer.DataMgr.StarSignData:GetStarTargetData()
  419. self.targetPos = Vector3.New(0,-720+120*self.target,0)
  420. self.isSetTarget = false
  421. self.scrollBox.arrowAnim.animator.speed = animSpeed[1]
  422. self.fx_uistarsigntipseffect_01.uIParticle:PlayCachedParticalSystem(true)
  423. self.fx_uistarsigntipseffect_02.uIParticle:PlayCachedParticalSystem(true)
  424. self.stopAnim:SetActive(false)
  425. self.btnSkip:SetActive(true)
  426. end
  427. function UIStarSignTipsView:RemoveEventListener()
  428. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  429. end
  430. function UIStarSignTipsView:PopErrorTips(key)
  431. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(key)
  432. end
  433. function UIStarSignTipsView:AddUIEventListener()
  434. self.uiBase:AddButtonEventListener(self.btnClose.button,self,self.OnClickClose) --点击关闭界面
  435. self.uiBase:AddButtonEventListener(self.btnGift.button,self,self.OnClickGiftShop) --点击跳转占星商店
  436. self.uiBase:AddButtonEventListener(self.btnRewardsList.button,self,self.OnClickRewardsList) --点击奖励列表
  437. self.uiBase:AddButtonEventListener(self.btnGetRewards.button,self,self.OnClickGetRewards) --点击获取奖励
  438. self.uiBase:AddButtonEventListener(self.btnSkip.button,self,self.OnClickSkip) --点击跳过动画
  439. self.uiBase:AddButtonEventListener(self.btnPlayRule.button,self,self.OnClickPlayRule) --点击活动规则
  440. self.uiBase:AddButtonEventListener(self.btnAstrology.button,self,self.OnClickAstrology) --点击占星按钮
  441. self.btnUseLucky.toggle.onValueChanged:AddListener(function (isOn)
  442. if isOn == false then
  443. return
  444. end
  445. local count = ManagerContainer.DataMgr.StarSignData:GetStarActiveCount()
  446. local IsCanUseLuck,CompetitionDevineCfg = self:IsCanUseLuck()
  447. if IsCanUseLuck then
  448. local cfgId = CompetitionDevineCfg.LuckyPrice[1][1]
  449. local num = CommonUtil.GetOwnResCountByItemId(cfgId)
  450. if num >= CompetitionDevineCfg.LuckyPrice[1][2] then
  451. self.btnUseLucky.toggle.isOn = true
  452. else
  453. self.btnUseLucky.toggle.isOn = false
  454. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam(CommonUtil.GetItemNotEnoughInfo(cfgId))
  455. end
  456. elseif count == 12 then
  457. self.btnUseLucky.toggle.isOn = false
  458. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("StarRewardMax")
  459. else
  460. self.btnUseLucky.toggle.isOn = false
  461. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("CannotUseLuckyCharm")
  462. return
  463. end
  464. end)
  465. end
  466. function UIStarSignTipsView:IsCanUseLuck()
  467. local count = ManagerContainer.DataMgr.StarSignData:GetStarActiveCount()
  468. local CompetitionDevineCfg = ManagerContainer.CfgMgr:GetCompetitionDevineCfgById(count + 1)
  469. return CompetitionDevineCfg and CompetitionDevineCfg.LuckyPrice ~= nil,CompetitionDevineCfg
  470. end
  471. function UIStarSignTipsView:OnHide()
  472. end
  473. function UIStarSignTipsView:OnShow(data)
  474. ManagerContainer.DataMgr.StarSignData:SetData(data)
  475. end
  476. function UIStarSignTipsView:OnClose()
  477. if updateHandle ~= nil then
  478. UpdateBeat:RemoveListener(updateHandle)
  479. updateHandle = nil
  480. end
  481. self.btnUseLucky.toggle.onValueChanged:RemoveAllListeners()
  482. scrollRect = nil
  483. end
  484. function UIStarSignTipsView:OnDispose()
  485. self.controller:OnDispose()
  486. end
  487. return UIStarSignTipsView