源战役客户端
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

117 líneas
4.1 KiB

hace 4 semanas
  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 藏宝图奖池预览界面
  4. -- *>
  5. TreasureMapRewardPreviewView = TreasureMapRewardPreviewView or BaseClass(BaseView)
  6. local TreasureMapRewardPreviewView = TreasureMapRewardPreviewView
  7. function TreasureMapRewardPreviewView:__init()
  8. self.base_file = "treasureMap"
  9. self.layout_file = "TreasureMapRewardPreviewView"
  10. self.layer_name = "Activity"
  11. self.destroy_imm = true
  12. self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置
  13. self.hide_maincancas = false --全屏界面需要隐藏主UI
  14. self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
  15. self.model = TreasureMapModel:getInstance()
  16. self.cur_index = 1
  17. self.load_callback = function ()
  18. self:LoadSuccess()
  19. self:AddEvent()
  20. end
  21. self.open_callback = function ( )
  22. self:SwitchTab(self.cur_index)
  23. end
  24. self.destroy_callback = function ( )
  25. self:DestroySuccess()
  26. end
  27. end
  28. function TreasureMapRewardPreviewView:Open(index)
  29. self.cur_index = index or self.cur_index
  30. BaseView.Open(self)
  31. end
  32. function TreasureMapRewardPreviewView:LoadSuccess()
  33. local nodes = {
  34. "win_bg:raw", "close_btn:obj",
  35. "item_scroll",
  36. "item_scroll/Viewport/item_con",
  37. -- 页签1
  38. "tab_con/tab1:obj",
  39. "tab_con/tab1/tab1_selected:obj",
  40. "tab_con/tab1/tab1_name:tmp",
  41. "tab_con/tab1/tab1_name_sel:tmp",
  42. -- 页签2
  43. "tab_con/tab2:obj",
  44. "tab_con/tab2/tab2_selected:obj",
  45. "tab_con/tab2/tab2_name:tmp",
  46. "tab_con/tab2/tab2_name_sel:tmp",
  47. "tip_con/tip_icon:obj",
  48. }
  49. self:GetChildren(nodes)
  50. lua_resM:setOutsideRawImage(self, self.win_bg_raw, GameResPath.GetViewBigBg("tm_preview_bg"))
  51. end
  52. function TreasureMapRewardPreviewView:AddEvent()
  53. local function click_event(target)
  54. if target == self.close_btn_obj then
  55. self:Close()
  56. elseif target == self.tab1_obj then
  57. self:SwitchTab(1)
  58. elseif target == self.tab2_obj then
  59. self:SwitchTab(2)
  60. elseif target == self.tip_icon_obj then -- 查看概率
  61. UIToolTipMgr:getInstance():AppendLuckyProbTips(424, self.cur_index, 1)
  62. end
  63. end
  64. AddClickEvent(self.close_btn_obj, click_event)
  65. AddClickEvent(self.tab1_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
  66. AddClickEvent(self.tab2_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
  67. AddClickEvent(self.tip_icon_obj, click_event)
  68. end
  69. function TreasureMapRewardPreviewView:SwitchTab(index)
  70. self.cur_index = index
  71. self.tab1_selected_obj:SetActive(self.cur_index == 1)
  72. self.tab2_selected_obj:SetActive(self.cur_index == 2)
  73. self.tab1_name_tmp.text = self.cur_index == 1 and "" or "普通藏宝图"
  74. self.tab1_name_sel_tmp.text = self.cur_index == 1 and "普通藏宝图" or ""
  75. self.tab2_name_tmp.text = self.cur_index == 2 and "" or "高级藏宝图"
  76. self.tab2_name_sel_tmp.text = self.cur_index == 2 and "高级藏宝图" or ""
  77. self:UpdateView()
  78. end
  79. function TreasureMapRewardPreviewView:UpdateView()
  80. -- 获取藏宝图奖励数据
  81. local data = self.model:GetTreasureMapRewardPreviewData(self.cur_index)
  82. self.reward_item_creator = self.reward_item_creator or self:AddUIComponent(UI.ItemListCreator)
  83. local info = {
  84. data_list = data,
  85. scroll_view = self.item_scroll,
  86. item_con = self.item_con,
  87. obj_pool_type = UIObjPool.UIType.AwardItem,
  88. item_width = 62,
  89. item_height = 62,
  90. start_x = 8,
  91. start_y = -6.5,
  92. space_x = 16,
  93. space_y = 16,
  94. create_frequency = 0.01,
  95. is_scroll_back_on_update = true,
  96. alignment = UnityEngine.TextAnchor.UpperLeft,
  97. on_update_item = function(item, i, v)
  98. local typeId, lock = GoodsModel:getInstance():GetMappingTypeId(v.rewards[1], v.rewards[2])
  99. item:SetData(typeId, v.rewards[3], nil, nil, lock)
  100. item:SetItemSize(62, 62)
  101. end,
  102. }
  103. self.reward_item_creator:UpdateItems(info)
  104. end
  105. function TreasureMapRewardPreviewView:DestroySuccess( )
  106. end