KLLuckyTurnTablePanel.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. ---@class KLLuckyTurnTablePanel:UIKmlLuaPanelBase
  2. ---@field view KLLuckyTurnTablePanelView
  3. local KLLuckyTurnTablePanel = class(UIKmlLuaPanelBase)
  4. local this = KLLuckyTurnTablePanel
  5. function this:AsyncLoadUI()
  6. end
  7. ---创建时调用一次
  8. function this:Init()
  9. self.ItemPos = {}
  10. self.ShowCount = 16
  11. self.speed = 0.02
  12. self.IsSkip = InfoManager.luckyTurnTableInfo.IsSkip
  13. self.LuckyTurnTableItemList = {}
  14. self.IsAnimation = false
  15. self.CurSelectCountPosIndex = 1--当前停留的位置
  16. self.ShowItemList = {}
  17. self.oneCost = nil
  18. self.tenCost = nil
  19. self.bigListItemList = {}---大奖展示
  20. self.received = nil
  21. self.CountRewardList = {} ---次数奖励
  22. self.CountRewardTbl = {}
  23. self.totalCount = 0
  24. self.ShowBigBigTbl = nil
  25. GUI:SetActive(self.view.rewardShow, true)
  26. GUI:SetActive(self.view.getShow, false)
  27. self:InitCountRewardList()
  28. GUI:setScale(self.view.GetShowText,0.5)
  29. end
  30. function this:InitCountRewardList()
  31. GUI:DataListInitData(self.view.Reward_list, function()
  32. return table.count(self.CountRewardTbl)
  33. end, function()
  34. local item = GUI:UIPanel_Open("dev/outui/OperateActivity/Item/KLTurnTableGetAward/KLTurnTableGetAwardItem", self.view.Reward_list, self, nil, true)
  35. if not self.CountRewardItemList then
  36. self.CountRewardItemList = {}
  37. end
  38. local kmlCtrl = item.view.root
  39. self.CountRewardItemList[kmlCtrl] = item
  40. return kmlCtrl
  41. end, function()
  42. end, function(realIndex, kmlCtrl)
  43. local luaIndex = realIndex + 1
  44. local item = self.CountRewardItemList[kmlCtrl]
  45. local CountRewardTbl = self.CountRewardTbl
  46. if CountRewardTbl then
  47. item:UpDataUI(CountRewardTbl[luaIndex], luaIndex, self.totalCount, self.received, self.curTurnTbl.id)
  48. end
  49. end)
  50. end
  51. ---界面显示时调用一次
  52. function this:Show()
  53. for i = 1, self.ShowCount do
  54. self.ItemPos[i] = GUI:GetChildById(self.view.table, tostring(i))
  55. end
  56. self.careerId = SL:GetMetaValue(EMetaVarGetKey.JOB)
  57. end
  58. ---创建或者刷新界面数据时调用
  59. function this:Refresh()
  60. GUI:Text_setString(self.view.freeTime, "")
  61. self.groupId = InfoManager.mainOperateActivityInfo.NowOperateActivityMainGroup
  62. self.curTurnTbl = InfoManager.luckyTurnTableInfo:GetTurnTableDataByActivityId(self.groupId)
  63. if self.curTurnTbl then
  64. self.oneCost = self.curTurnTbl.oneCost
  65. self.tenCost = self.curTurnTbl.manyCost
  66. self:ShowCostItemCount()
  67. self:BtnTextUpdata()
  68. self:ShowRewardItem(self.curTurnTbl.reward)
  69. self:ShowBigReward(self.curTurnTbl.id)
  70. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MAIN_ACTIVE_INFO, { subType = EOperateActivityActivityType.luckyTurnTable, mainGroup = self.groupId })
  71. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TURNTABLE_REWARD_COUNT_INFO, { id = self.curTurnTbl.id })
  72. end
  73. end
  74. ---显示玩家寻宝券数量
  75. function this:ShowCostItemCount()
  76. local allCount = self:GetCoinCount(self.oneCost[1])
  77. GUI:Text_setString(self.view.ModelCount, GUIUtil.FormatNumber(tostring(allCount)))
  78. GUI:Item_setItemId(self.view.xunbaoquanModel, self.oneCost[1])
  79. GUI:Item_setItemId(self.view.OnecostModel, self.oneCost[1])
  80. GUI:Item_setItemId(self.view.TenCostModel, self.oneCost[1])
  81. GUI:setScale(self.view.xunbaoquanModel, 0.5)
  82. GUI:setScale(self.view.OnecostModel, 0.5)
  83. GUI:setScale(self.view.TenCostModel, 0.5)
  84. end
  85. function this:GetCoinCount(coinId)
  86. if coinId == 10050001 then
  87. --绑钻
  88. return SL:GetBagItemCount(coinId) + SL:GetBagItemCount(10040001)
  89. else
  90. return SL:GetBagItemCount(coinId)
  91. end
  92. end
  93. function this:BtnTextUpdata()
  94. local needNum1 = self.oneCost[2] - self:GetCoinCount(self.oneCost[1])
  95. local needNum2 = self.tenCost[3] - self:GetCoinCount(self.tenCost[2])
  96. if needNum1 > 0 then
  97. GUI:Text_setString(self.view.oneBtnTextCount, self:ReturnRichTextByColorAndText(EColor[EGradColor.red], "X" .. self.oneCost[2]))
  98. else
  99. GUI:Text_setString(self.view.oneBtnTextCount, self:ReturnRichTextByColorAndText(EColor[EGradColor.green], "X" .. self.oneCost[2]))
  100. end
  101. if needNum2 > 0 then
  102. GUI:Text_setString(self.view.tenBtnTextCount, self:ReturnRichTextByColorAndText(EColor[EGradColor.red], "X" .. self.tenCost[3]))
  103. else
  104. GUI:Text_setString(self.view.tenBtnTextCount, self:ReturnRichTextByColorAndText(EColor[EGradColor.green], "X" .. self.tenCost[3]))
  105. end
  106. if self.IsFree then
  107. --免费
  108. GUI:SetActive(self.view.FreeRedDot, true)
  109. GUI:SetActive(self.view.oneBtnImage, false)
  110. GUI:Text_setString(self.view.oneBtnTextCount, self:ReturnRichTextByColorAndText(EColor[EGradColor.green], "免费"))
  111. else
  112. GUI:SetActive(self.view.FreeRedDot, false)
  113. GUI:SetActive(self.view.oneBtnImage, true)
  114. if needNum1 > 0 then
  115. GUI:Text_setString(self.view.oneBtnTextCount, self:ReturnRichTextByColorAndText(EColor[EGradColor.red], "X" .. self.oneCost[2]))
  116. else
  117. GUI:Text_setString(self.view.oneBtnTextCount, self:ReturnRichTextByColorAndText(EColor[EGradColor.green], "X" .. self.oneCost[2]))
  118. end
  119. end
  120. local allCount = self:GetCoinCount(self.oneCost[1])
  121. GUI:Text_setString(self.view.ModelCount, GUIUtil.FormatNumber(tostring(allCount)))
  122. end
  123. ---奖励展示16个
  124. function this:ShowRewardItem(groupId)
  125. ---@type cfg_turntable_reward_column[]
  126. local turnRewardTbl = SL:GetConfigTable("cfg_turntable_reward")
  127. for i, v in pairs(turnRewardTbl) do
  128. if v.group == groupId and (v.condition == "" or ConditionManager.Check4D(v.condition)) then
  129. if self.LuckyTurnTableItemList[v.order] == nil then
  130. local LuckyTurnTableItem = GUI:UIPanel_Open("dev/outui/OperateActivity/Item/KLLuckyTurnTable/KLLuckyTurnTableItem", self.ItemPos[v.order], self, nil, true)
  131. self.LuckyTurnTableItemList[v.order] = LuckyTurnTableItem
  132. end
  133. self.LuckyTurnTableItemList[v.order]:UpDataUI(v)
  134. self.LuckyTurnTableItemList[v.order]:InitCount(v.num)
  135. if v.type == 1 then
  136. self.ShowBigBigTbl = v
  137. end
  138. end
  139. end
  140. end
  141. ---显示中间大奖
  142. function this:ShowBigReward(groupId)
  143. local bigList = InfoManager.luckyTurnTableInfo:GetTurnTableBigListByActivityId(groupId)
  144. for i, v in pairs(bigList) do
  145. if self.bigListItemList[i] == nil then
  146. local BigTurnTableItem = GUI:UIPanel_Open("dev/outui/OperateActivity/Item/KLTurnTableAward/KLTurnTableAwardItem", self.view.rewardShowGrid, self, nil, true)
  147. self.bigListItemList[i] = BigTurnTableItem
  148. end
  149. self.bigListItemList[i]:UpDataUI(v, i, self.totalCount, self.received, self.curTurnTbl.id)
  150. end
  151. end
  152. ---注册UI事件和服务器消息
  153. function this:RegistEvents()
  154. GUI:AddOnClickEvent(self.view.OneBtn, self, self.OneBtnOnclick)
  155. GUI:AddOnClickEvent(self.view.TenBtn, self, self.TenBtnOnclick)
  156. GUI:AddOnClickEvent(self.view.oddsBtn, self, self.oddsBtn)
  157. GUI:SetToggleOnValueChange(self.view.SkipToggle, self, self.SkipToggleOnclick)
  158. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_MAIN_ACTIVE_INFO, self.RES_MAIN_ACTIVE_INFO, self)-- 响应抽奖界面
  159. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_TURNTABLE_RAFFLE_FREE_TIME, self.RES_TURNTABLE_RAFFLE_FREE_TIME, self)-- 响应抽奖免费时间
  160. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_TURNTABLE_RAFFLE_REWARD_IDS, self.RES_TURNTABLE_RAFFLE_REWARD_IDS, self)-- 响应转盘抽奖奖励id列表
  161. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_TURNTABLE_RAFFLE_REWARD_COUNT_INFO, self.RES_TURNTABLE_RAFFLE_REWARD_COUNT_INFO, self)-- 响应转盘抽奖奖励id列表
  162. --SL:RegisterLUAEvent(LUA_EVENT_BAG_CHANGE_AFTER, self.LUA_EVENT_BAG_CHANGE_AFTER, self)
  163. --SL:RegisterLUAEvent(LUA_EVENT_MONEYCHANGE, self.LUA_EVENT_BAG_CHANGE_AFTER, self)
  164. end
  165. function this:LUA_EVENT_BAG_CHANGE_AFTER(_, message)
  166. if message then
  167. self:BtnTextUpdata()
  168. end
  169. end
  170. function this:RES_TURNTABLE_RAFFLE_REWARD_COUNT_INFO(_, message)
  171. if message then
  172. for id, value in pairs(message) do
  173. if next(self.LuckyTurnTableItemList) then
  174. ---刷新剩余次数
  175. for _, showList in pairs(self.LuckyTurnTableItemList) do
  176. if showList.data.id == tonumber(id) then
  177. local reCount = showList.data.num - tonumber(value)
  178. showList:InitCount(reCount)
  179. end
  180. end
  181. end
  182. if self.ShowBigBigTbl and self.ShowBigBigTbl.id == tonumber(id) then
  183. local reCount = self.ShowBigBigTbl.num - tonumber(value)
  184. if reCount > 0 then
  185. GUI:SetActive(self.view.GetShowText,true)
  186. else
  187. GUI:SetActive(self.view.GetShowText,false)
  188. end
  189. end
  190. end
  191. end
  192. end
  193. function this:oddsBtn()
  194. local helpCfg = SL:GetConfig("cfg_rule_text", 301, "id")
  195. if helpCfg then
  196. SL:CommonStrTipsMessage({ title = helpCfg.menutxt, str = helpCfg.location })
  197. end
  198. end
  199. function this:RES_TURNTABLE_RAFFLE_FREE_TIME(_, message)
  200. if message then
  201. self:ShowFreeTime(tonumber(message.nextFreeTime))
  202. --self.IsFree = message.isFree
  203. end
  204. end
  205. function this:RES_MAIN_ACTIVE_INFO(_, message)
  206. -----面板信息
  207. if message and next(message.turntableRaffleActive) then
  208. self.totalCount = 0
  209. self.received = {}
  210. --GUI:Toggle_setIsOn(self.view.SkipToggle, self.IsSkip)
  211. if self.curTurnTbl then
  212. local curTurnTblId = tostring(self.curTurnTbl.id)
  213. self.totalCount = message.turntableRaffleActive[curTurnTblId].total--抽奖总次数
  214. local canFree = message.turntableRaffleActive[curTurnTblId].canFree--可否免费抽奖
  215. local freeTime = message.turntableRaffleActive[curTurnTblId].freeTime--下次免费抽奖开启时间戳
  216. local count = message.turntableRaffleActive[curTurnTblId].count--累加次数 前端忽略
  217. self.received = message.turntableRaffleActive[curTurnTblId].received--已经领取过的奖励id cfg_turntable_extra表id
  218. local skipAnimation = message.turntableRaffleActive[curTurnTblId].skipAnimation--是否跳过动画
  219. self.IsFree = canFree
  220. if self.ShowBigBigTbl then
  221. local showTimes = self.ShowBigBigTbl.guarantees - self.totalCount
  222. if showTimes > 0 then
  223. GUI:Text_setString(self.view.GetShowText, "<color=#e6e600>还剩" .. showTimes .. "抽必得</color><color=#ff8a00>极品大奖</color>")
  224. GUI:setPosition(self.view.rewardShowGrid,0,-12)
  225. else
  226. GUI:setPosition(self.view.rewardShowGrid,0,0)
  227. end
  228. end
  229. GUI:Text_setString(self.view.NowTimeText, tostring(self.totalCount))
  230. if skipAnimation == 0 then
  231. self.IsSkip = false
  232. elseif skipAnimation == 1 then
  233. self.IsSkip = true
  234. end
  235. if self.IsAnimation then
  236. end
  237. GUI:Toggle_setIsOn(self.view.SkipToggle, self.IsSkip)
  238. self:ShowFreeTime(tonumber(freeTime))
  239. self:ShowTime(InfoManager.mainOperateActivityInfo:GetOADJSTimeBySubType(EOperateActivityActivityType.luckyTurnTable) * 1000 + Time.GetServerTime())
  240. self:BtnTextUpdata()
  241. self.CountRewardTbl = InfoManager.luckyTurnTableInfo:GetTurnTableAwardListByActivityId(curTurnTblId)
  242. GUI:DataListUpdateData(self.view.Reward_list)
  243. self:ShowBigReward(self.curTurnTbl.id)
  244. for i, v in pairs(self.CountRewardTbl) do
  245. if not InfoManager.luckyTurnTableInfo:IsGetReceived(v.id, self.received) then
  246. if i == 1 then
  247. break
  248. end
  249. GUI:SetScrollView_scrollpos(self.view.scrollview1, (i - 1) / (table.count(self.CountRewardTbl) - 3)+0.05)
  250. break
  251. end
  252. end
  253. end
  254. end
  255. end
  256. function this:ShowTime(endTime)
  257. local len = (endTime - Time.GetServerTime()) // 1000 + 1
  258. if len > 0 then
  259. self.Timer = SL:Schedule(self.Timer, 0, 1, len, function()
  260. local timeText = endTime - Time.GetServerTime()
  261. if timeText <= 21600000 then
  262. GUI:Text_setString(self.view.reTime, "<color=#FF4F47>剩余时间:" .. GUIUtil.FormatTimeHMSD_S(timeText // 1000) .. "</color>")
  263. else
  264. GUI:Text_setString(self.view.reTime, "<color=#5DE367>剩余时间:" .. GUIUtil.FormatTimeHMSD_S(timeText // 1000) .. "</color>")
  265. end
  266. if timeText <= 0 then
  267. GUI:Text_setString(self.view.freeTime, "")
  268. return
  269. end
  270. end)
  271. end
  272. end
  273. function this:ShowFreeTime(endTime)
  274. local len = (endTime - Time.GetServerTime()) // 1000 + 1
  275. if len > 0 then
  276. self.FreeTimer = SL:Schedule(self.FreeTimer, 0, 1, len, function()
  277. local timeText = endTime - Time.GetServerTime()
  278. GUI:Text_setString(self.view.freeTime, "<color=#5DE367>" .. GUIUtil.FormatTimeHMSD_S(timeText // 1000) .. "</color>" .. "后免费")
  279. if timeText <= 0 then
  280. self.IsFree = true
  281. self:BtnTextUpdata()
  282. GUI:Text_setString(self.view.freeTime, "")
  283. return
  284. end
  285. end)
  286. end
  287. end
  288. function this:SkipToggleOnclick(kmlCtrl, eventData, args)
  289. if args[1] then
  290. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_CHANGE_SKIP_ANIMATION, { skipAnimation = 1, id = self.curTurnTbl.id })
  291. else
  292. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_CHANGE_SKIP_ANIMATION, { skipAnimation = 0, id = self.curTurnTbl.id })
  293. end
  294. self.IsSkip = args[1]
  295. InfoManager.luckyTurnTableInfo.IsSkip = args[1]
  296. end
  297. function this:OneBtnOnclick(control)
  298. if self.IsAnimation then
  299. return
  300. end
  301. if self.IsFree then
  302. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TURNTABLE_RAFFLE_DRAWING, { id = self.curTurnTbl.id, isFree = self.IsFree, times = 1 })
  303. return
  304. end
  305. local needNum1 = self.oneCost[2] - self:GetCoinCount(self.oneCost[1])
  306. if needNum1 > 0 then
  307. SL:CommonItemGetPath(nil, self.oneCost[1])
  308. return
  309. end
  310. if needNum1 <= 0 then
  311. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TURNTABLE_RAFFLE_DRAWING, { id = self.curTurnTbl.id, times = 1 })
  312. end
  313. end
  314. function this:TenBtnOnclick(control)
  315. if self.IsAnimation then
  316. return
  317. end
  318. local needNum2 = self.tenCost[3] - self:GetCoinCount(self.tenCost[2])
  319. if needNum2 > 0 then
  320. SL:CommonItemGetPath(nil, self.tenCost[2])
  321. return
  322. end
  323. if needNum2 <= 0 then
  324. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TURNTABLE_RAFFLE_DRAWING, { id = self.curTurnTbl.id, times = self.tenCost[1] })
  325. end
  326. end
  327. function this:RES_TURNTABLE_RAFFLE_REWARD_IDS(id, message)
  328. if message then
  329. local rewardIdList = {}
  330. for i, v in pairs(message) do
  331. local index = tonumber(i)
  332. for id, count in pairs(v) do
  333. rewardIdList[index] = tonumber(id)
  334. end
  335. end
  336. if self.IsSkip then
  337. self:NoAnimation(rewardIdList)
  338. else
  339. self:AnimationShow(rewardIdList)
  340. end
  341. end
  342. end
  343. ---计算步数结果
  344. function this:StepCount(oldIndex, newIndex)
  345. local step = 0
  346. if newIndex > oldIndex then
  347. --最终位置大于初始位置
  348. step = newIndex - oldIndex
  349. elseif newIndex < oldIndex then
  350. --最终位置小于初始位置
  351. step = newIndex + self.ShowCount - oldIndex
  352. else
  353. --位置相等 在转一圈
  354. step = self.ShowCount
  355. end
  356. return step
  357. end
  358. function this:FindOrderById(rewardList)
  359. local List = {}
  360. for i, v in pairs(rewardList) do
  361. local tbl = SL:GetConfig("cfg_turntable_reward", tonumber(v))
  362. local order = tbl.order
  363. local index = tonumber(i)
  364. List[index] = order
  365. end
  366. return List
  367. end
  368. --抽奖动画
  369. function this:AnimationShow(EndSelectCountPosIndexList)
  370. local rewardList = self:FindOrderById(EndSelectCountPosIndexList)
  371. if self.timer then
  372. Coroutine.Stop(self.timer)
  373. self.timer = nil
  374. end
  375. local step = 0
  376. local ListLen = #rewardList
  377. local oldIndex = self.CurSelectCountPosIndex
  378. local StepList = {}
  379. local itemList = {}
  380. for i, newIndex in pairs(rewardList) do
  381. step = step + self:StepCount(oldIndex, newIndex)
  382. oldIndex = newIndex
  383. StepList[i] = step
  384. end
  385. for i, Index in pairs(EndSelectCountPosIndexList) do
  386. local items = SL:GetConfig("cfg_turntable_reward", tonumber(Index)).item
  387. for _, v in pairs(items) do
  388. if v[1] == self.careerId then
  389. local tbl = {
  390. cfgId = v[2],
  391. count = v[3]
  392. }
  393. table.insert(itemList, tbl)
  394. end
  395. end
  396. end
  397. self.timer = Coroutine.Start(function()
  398. self.IsAnimation = true
  399. GUI:SetActive(self.view.rewardShow, false)
  400. GUI:SetActive(self.view.getShow, true)
  401. local CircleCount = self.ShowCount * 2 + step
  402. local count = 0
  403. local StepListIndex = 1
  404. local firstCircle = 0
  405. local itemIndex = 0
  406. local nowIndex = self.CurSelectCountPosIndex
  407. while CircleCount > 0 do
  408. if firstCircle == 0 then
  409. self:ShowPointSelect(nowIndex)
  410. nowIndex = nowIndex + 1
  411. if nowIndex > 16 then
  412. nowIndex = nowIndex - 16
  413. end
  414. if nowIndex == self.CurSelectCountPosIndex then
  415. firstCircle = firstCircle + 1
  416. end
  417. Coroutine.Wait(self.speed / 2)
  418. else
  419. self.CurSelectCountPosIndex = (self.CurSelectCountPosIndex + 1) % self.ShowCount
  420. if self.CurSelectCountPosIndex == 0 then
  421. self.CurSelectCountPosIndex = self.ShowCount
  422. end
  423. self:ShowPointSelect(self.CurSelectCountPosIndex)
  424. CircleCount = CircleCount - 1
  425. count = count + 1
  426. if count == StepList[StepListIndex] + self.ShowCount * 2 then
  427. --展示奖品
  428. itemIndex = itemIndex + 1
  429. self:ShowGetRewardItem(EndSelectCountPosIndexList[StepListIndex], itemIndex)
  430. StepListIndex = StepListIndex + 1
  431. firstCircle = 0
  432. nowIndex = self.CurSelectCountPosIndex
  433. Coroutine.Wait(0.5)
  434. else
  435. if StepList[StepListIndex] + self.ShowCount * 2 - count < 5 and table.count(EndSelectCountPosIndexList) == 1 then
  436. Coroutine.Wait(self.speed + (5 - (StepList[StepListIndex] + self.ShowCount * 2 - count)) * self.speed * 10)
  437. else
  438. Coroutine.Wait(self.speed)
  439. end
  440. end
  441. end
  442. end
  443. self.CurSelectCountPosIndex = rewardList[ListLen]
  444. self.IsAnimation = false
  445. Coroutine.Wait(0.2)
  446. self:AnimationEnd()
  447. self:ShowGetItem(itemList)
  448. end)
  449. end
  450. --无抽奖动画
  451. function this:NoAnimation(EndSelectCountPosIndexList)
  452. local rewardList = self:FindOrderById(EndSelectCountPosIndexList)
  453. local step = 0
  454. local ListLen = #rewardList
  455. local oldIndex = self.CurSelectCountPosIndex
  456. local StepList = {}
  457. local itemList = {}
  458. for i, newIndex in pairs(rewardList) do
  459. step = step + self:StepCount(oldIndex, newIndex)
  460. oldIndex = newIndex
  461. StepList[i] = step
  462. end
  463. for i, Index in pairs(EndSelectCountPosIndexList) do
  464. local items = SL:GetConfig("cfg_turntable_reward", tonumber(Index)).item
  465. for _, v in pairs(items) do
  466. if v[1] == self.careerId then
  467. local tbl = {
  468. cfgId = v[2],
  469. count = v[3]
  470. }
  471. table.insert(itemList, tbl)
  472. end
  473. end
  474. end
  475. self.IsAnimation = true
  476. GUI:SetActive(self.view.rewardShow, false)
  477. GUI:SetActive(self.view.getShow, true)
  478. local CircleCount = self.ShowCount * 2 + step
  479. local count = 0
  480. local StepListIndex = 1
  481. local itemIndex = 0
  482. while CircleCount > 0 do
  483. self.CurSelectCountPosIndex = (self.CurSelectCountPosIndex + 1) % self.ShowCount
  484. if self.CurSelectCountPosIndex == 0 then
  485. self.CurSelectCountPosIndex = self.ShowCount
  486. end
  487. CircleCount = CircleCount - 1
  488. count = count + 1
  489. if count == StepList[StepListIndex] + self.ShowCount * 2 then
  490. --展示奖品
  491. itemIndex = itemIndex + 1
  492. self:ShowGetRewardItem(EndSelectCountPosIndexList[StepListIndex], itemIndex)
  493. StepListIndex = StepListIndex + 1
  494. end
  495. end
  496. self.CurSelectCountPosIndex = rewardList[ListLen]
  497. self:ShowPointSelect(self.CurSelectCountPosIndex)
  498. self.IsAnimation = false
  499. self:AnimationEnd()
  500. self:ShowGetItem(itemList)
  501. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TURNTABLE_REWARD_COUNT_INFO, { id = self.curTurnTbl.id })
  502. end
  503. ---动画结束后调用
  504. function this:AnimationEnd()
  505. GUI:SetActive(self.view.rewardShow, true)
  506. GUI:SetActive(self.view.getShow, false)
  507. self:HideAllGetItem()
  508. end
  509. --隐藏所有的获得奖励
  510. function this:HideAllGetItem()
  511. for _, v in pairs(self.ShowItemList) do
  512. GUI:SetActive(v, false)
  513. end
  514. end
  515. --展示获得的奖励
  516. function this:ShowGetRewardItem(index, itemIndex)
  517. local tblId = index
  518. local ShowItemTbl = SL:GetConfig("cfg_turntable_reward", tonumber(tblId))
  519. for _, showList in pairs(self.LuckyTurnTableItemList) do
  520. if showList.data.id == tonumber(tblId) then
  521. showList:SetReTimes()
  522. end
  523. end
  524. for k, v in pairs(ShowItemTbl.item) do
  525. if v[1] and v[1] == self.careerId then
  526. local data = {
  527. itemid = v[2],
  528. mfixsize = "80,80",
  529. tips = "1",
  530. width = "80",
  531. height = "80",
  532. itemcustomcount = v[3]
  533. }
  534. if not self.ShowItemList[itemIndex] then
  535. self.ShowItemList[itemIndex] = nil
  536. end
  537. if self.ShowItemList[itemIndex] then
  538. GUI:Item_UpdataData(self.ShowItemList[itemIndex], data)
  539. else
  540. self.ShowItemList[itemIndex] = GUI:Item_Create(self.view.GetShowGrid, data)
  541. end
  542. GUI:AddOnClickEvent(self.ShowItemList[itemIndex], self, function()
  543. SL:OpenTips(nil, data.itemid)
  544. end)
  545. GUI:SetActive(self.ShowItemList[itemIndex], true)
  546. end
  547. end
  548. end
  549. --选定可抽取的奖励
  550. function this:ShowPointSelect(index)
  551. for i, v in pairs(self.LuckyTurnTableItemList) do
  552. if i == index then
  553. self.LuckyTurnTableItemList[i]:ShowSelect()
  554. else
  555. self.LuckyTurnTableItemList[i]:HideSelect()
  556. end
  557. end
  558. end
  559. function this:ShowGetItem(itemList)
  560. GUI:UIPanel_Open("dev/outui/OperateActivity/Panel/KLCommonGainItemShow/KLCommonGainItemShowPanel", nil, self, { reward = itemList })
  561. end
  562. -- 根据rgb和文本返回富文本
  563. function this:ReturnRichTextByColorAndText(color, text)
  564. return '<color=' .. color .. '>' .. text .. "</color>"
  565. end
  566. function this:Hide()
  567. if self.timer then
  568. Coroutine.Stop(self.timer)
  569. self.timer = nil
  570. end
  571. self.CurSelectCountPosIndex = 1--当前停留的位置
  572. end
  573. function this:Close()
  574. self:Hide()
  575. for _, v in pairs(self.LuckyTurnTableItemList) do
  576. GUI:UIPanel_Close(nil, v)
  577. end
  578. for _, v in pairs(self.bigListItemList) do
  579. GUI:UIPanel_Close(nil, v)
  580. end
  581. for _, v in pairs(self.CountRewardList) do
  582. GUI:UIPanel_Close(nil, v)
  583. end
  584. if self.FreeTimer then
  585. SL:UnSchedule(self.FreeTimer)
  586. end
  587. self.FreeTimer = nil
  588. if self.Timer then
  589. SL:UnSchedule(self.Timer)
  590. end
  591. self.Timer = nil
  592. if self.TimerPos then
  593. SL:UnSchedule(self.TimerPos)
  594. end
  595. self.TimerPos = nil
  596. self.ItemList = nil
  597. end
  598. return this