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

81 lines
2.6 KiB

  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 藏宝图系统限时商店界面(收纳商品)
  4. -- *>
  5. TreasureMapStorageShopView = TreasureMapStorageShopView or BaseClass(BaseView)
  6. local TreasureMapStorageShopView = TreasureMapStorageShopView
  7. function TreasureMapStorageShopView:__init()
  8. self.base_file = "treasureMap"
  9. self.layout_file = "TreasureMapShopView"
  10. self.layer_name = "UI"
  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.load_callback = function ()
  17. self:LoadSuccess()
  18. self:AddEvent()
  19. end
  20. self.open_callback = function ( )
  21. self:UpdateView()
  22. end
  23. self.destroy_callback = function ( )
  24. self:DestroySuccess()
  25. end
  26. end
  27. function TreasureMapStorageShopView:Open( )
  28. --self.data = data
  29. BaseView.Open(self)
  30. end
  31. function TreasureMapStorageShopView:LoadSuccess()
  32. local nodes = {
  33. "win_bg:raw", "close_btn:obj",
  34. "item_scroll", "item_scroll/Viewport/item_con",
  35. }
  36. self:GetChildren(nodes)
  37. lua_resM:setOutsideRawImage(self, self.win_bg_raw, GameResPath.GetViewBigBg("tm_shop_bg"))
  38. -- 使用的是原先的商城界面,改成类名方便搜索 --
  39. self.transform.name = "TreasureMapStorageShopView"
  40. end
  41. function TreasureMapStorageShopView:AddEvent()
  42. local function click_event(target)
  43. if target == self.close_btn_obj then
  44. self:Close()
  45. end
  46. end
  47. AddClickEvent(self.close_btn_obj, click_event)
  48. end
  49. function TreasureMapStorageShopView:UpdateView()
  50. -- 获取数据之前,剔除掉过期的商品
  51. self.data = self.model:GetTreasureMapStorageShopData(true)
  52. self.shop_item_creator = self.shop_item_creator or self:AddUIComponent(UI.ItemListCreator)
  53. local info = {
  54. data_list = self.data,
  55. item_con = self.item_con,
  56. scroll_view = self.item_scroll,
  57. item_class = TreasureMapStorageShopItem,
  58. item_width = 171,
  59. item_height = 240,
  60. start_x = 6.5,
  61. start_y = -4,
  62. space_x = 29,
  63. space_y = 2,
  64. create_frequency = 0.01,
  65. alignment = UnityEngine.TextAnchor.UpperLeft,
  66. on_update_item = function(item, i, v)
  67. item:SetData(v)
  68. end,
  69. }
  70. self.shop_item_creator:UpdateItems(info)
  71. end
  72. function TreasureMapStorageShopView:DestroySuccess( )
  73. end