源战役客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

96 rindas
3.2 KiB

pirms 1 mēnesi
  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 本国团战右侧信息采集物信息item
  4. -- *>
  5. GuildCSGRSceneCollectionItem = GuildCSGRSceneCollectionItem or BaseClass(BaseItem)
  6. local GuildCSGRSceneCollectionItem = GuildCSGRSceneCollectionItem
  7. function GuildCSGRSceneCollectionItem:__init(parent_wnd,prefab_asset,layer_name)
  8. self.base_file = "guildCSGR"
  9. self.layout_file = "GuildCSGRSceneCollectionItem"
  10. self.parent_wnd = parent_wnd
  11. self.layer_name = layer_name
  12. self.model = GuildModel:getInstance()
  13. self:Load()
  14. end
  15. function GuildCSGRSceneCollectionItem:Load_callback()
  16. local nodes = {
  17. "buff_icon:img",
  18. "effect_lb:tmp",
  19. -- "cur_num:tmp",
  20. -- "left_num:tmp",
  21. }
  22. self:GetChildren(nodes)
  23. self:AddEvents()
  24. if self.need_refreshData then
  25. self:UpdateBasicData()
  26. self:UpdateView()
  27. end
  28. end
  29. function GuildCSGRSceneCollectionItem:AddEvents( )
  30. local function click_event(target)
  31. if not self.can_click then return end
  32. if target == self.gameObject then
  33. if self.attr_icon then
  34. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41008, self.attr_icon)
  35. end
  36. end
  37. end
  38. AddClickEvent(self.gameObject, click_event)
  39. -- 更新采集数据
  40. local function update_collect_buff()
  41. self:UpdateView()
  42. end
  43. self:BindEvent(self.model, GuildModel.UPDATE_CSGR_BF_RES, update_collect_buff)
  44. end
  45. function GuildCSGRSceneCollectionItem:SetData( data, can_click )
  46. self.data = data
  47. self.can_click = can_click
  48. self.attr_icon = data[1]
  49. self.attr_id = data[2]
  50. self.attr_cfg_val = data[3]
  51. if self.is_loaded then
  52. self.need_refreshData = false
  53. self:UpdateBasicData()
  54. self:UpdateView()
  55. else
  56. self.need_refreshData = true
  57. end
  58. end
  59. function GuildCSGRSceneCollectionItem:UpdateBasicData( )
  60. if self.data then
  61. lua_resM:setImageSprite(self, self.buff_icon_img, "guildCSGR_asset", "csgr_attr_"..self.attr_icon, true)
  62. end
  63. end
  64. function GuildCSGRSceneCollectionItem:UpdateView( )
  65. if self.data then
  66. -- 场景资源数据
  67. local res_data = self.model:GetCSGRBattlefieldRes(self.attr_icon)
  68. -- local left_num = res_data and res_data.num or 0
  69. -- 社团buff资源数据
  70. local buff_data = self.model:GetCSGRCollectBuffs(self.attr_icon)
  71. -- local attr_name = WordManager:GetProperties(self.attr_id)
  72. local attr_name = GuildModel.CSGRAttrName[self.attr_id]
  73. local attr_val = WordManager:GetPropertyValue(self.attr_id, self.attr_cfg_val * (buff_data and buff_data.num or 0))
  74. self.effect_lb_tmp.text = string.format("%s加成:<color=%s>%s</color>",
  75. attr_name, ColorUtil.GREEN_DARK, attr_val)
  76. -- self.effect_lb_tmp.text = string.format("%s <color=%s>+%s</color>", attr_name, ColorUtil.GREEN_DARK, attr_val)
  77. -- self.cur_num_tmp.text = string.format("社团总采集数:<color=%s>%s</color>", ColorUtil.GREEN_DARK, buff_data and buff_data.num or 0)
  78. -- self.left_num_tmp.text = string.format("剩余:<color=%s>%s</color>",
  79. -- left_num > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK, left_num)
  80. end
  81. end
  82. function GuildCSGRSceneCollectionItem:__delete( )
  83. end