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

85 line
2.4 KiB

  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 招财猫活动抽奖节点
  4. -- *>
  5. FortuneCatRollItem = FortuneCatRollItem or BaseClass(BaseItem)
  6. local FortuneCatRollItem = FortuneCatRollItem
  7. function FortuneCatRollItem:__init(parent_wnd,prefab_asset,layer_name)
  8. self.base_file = "fortuneCat"
  9. self.layout_file = "FortuneCatRollItem"
  10. self.parent_wnd = parent_wnd
  11. self.layer_name = layer_name
  12. -- self.is_selected = false
  13. self.model = FortuneCatModel:getInstance()
  14. self.icon_pos = {
  15. [1] = Vector2(-3, -25),
  16. [2] = Vector2(0, -30),
  17. [3] = Vector2(3, -25),
  18. [4] = Vector2(4, -27),
  19. [5] = Vector2(0, -25),
  20. [6] = Vector2(0, -18),
  21. [7] = Vector2(0, -25),
  22. [8] = Vector2(0, -20),
  23. }
  24. self:Load()
  25. end
  26. function FortuneCatRollItem:Load_callback()
  27. local nodes = {
  28. "times_bg_special:obj",
  29. "icon:img",
  30. "times:tmp",
  31. "times_special:tmp",
  32. }
  33. self:GetChildren(nodes)
  34. self:AddEvents()
  35. if self.need_refreshData then
  36. self:UpdateView()
  37. end
  38. end
  39. function FortuneCatRollItem:AddEvents( )
  40. end
  41. function FortuneCatRollItem:SetData( data, index )
  42. self.data = data
  43. self.index = index
  44. self.sort = self.data.sort
  45. if self.is_loaded then
  46. self.need_refreshData = false
  47. self:UpdateView()
  48. else
  49. self.need_refreshData = true
  50. end
  51. end
  52. function FortuneCatRollItem:UpdateView( )
  53. -- 倍率后端返回的数值放大了100倍,这里要乘以0.01
  54. local is_special = self.data.mult >= 150
  55. -- 不同倍率下使用不同的节点表现内容
  56. self.times_tmp.text = not is_special and string.format("x%s倍", 0.01 * self.data.mult) or ""
  57. self.times_special_tmp.text = is_special and string.format("x%s倍", 0.01 * self.data.mult) or ""
  58. self.times_bg_special_obj:SetActive(is_special)
  59. lua_resM:setImageSprite(self, self.icon_img, "fortuneCat_asset", "fc_reward_icon" .. self.index, true)
  60. local icon_pos = self.icon_pos[self.index]
  61. SetAnchoredPosition(self.icon, icon_pos.x, icon_pos.y)
  62. end
  63. function FortuneCatRollItem:SetSelected(is_selected)
  64. -- self.is_selected = is_selected
  65. -- if self.is_loaded then
  66. -- if self.selected_obj.activeSelf ~= self.is_selected then
  67. -- self.selected_obj:SetActive(self.is_selected)
  68. -- end
  69. -- end
  70. end
  71. function FortuneCatRollItem:__delete( )
  72. end