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

128 line
3.9 KiB

  1. LightAttrItem = LightAttrItem or BaseClass(BaseItem)
  2. local LightAttrItem = LightAttrItem
  3. function LightAttrItem:__init(parent_wnd,prefab_asset,layer_name,layout_file)
  4. self.parent_wnd = parent_wnd or false -- 父容器
  5. self.prefab_asset = prefab_asset or false --预制体 如果有传进来就直接通过预制体创建对象 免去加载预制体的过程
  6. self.layer_name = layer_name or false --需要挂接特效的时候 必须设置
  7. self.base_file = "light"
  8. self.layout_file = layout_file or "LightAttrItem"
  9. self.model = FashionModel:GetInstance()
  10. self:Load()
  11. end
  12. function LightAttrItem:Load_callback()
  13. self.nodes = {
  14. "extra_text:tmp","attr_icon1:img:obj","attr_text1:tmp","bg:obj","attr_icon2:img:obj","attr_text2:tmp",
  15. "up_image1:obj","add_text2:tmp","add_text1:tmp","up_image2:obj",
  16. }
  17. self:GetChildren(self.nodes)
  18. self:AddEvents()
  19. if self.need_refreshData then
  20. self:UpdateView()
  21. end
  22. end
  23. function LightAttrItem:AddEvents( )
  24. end
  25. function LightAttrItem:UpdateView( )
  26. if self.data then
  27. local id1 = self.data.attr_id1
  28. local id2 = self.data.attr_id2
  29. local value1 = self.data.value1
  30. local value2 = self.data.value2
  31. local next_value1 = self.data.next_value1
  32. local next_value2 = self.data.next_value2
  33. self.extra_text_tmp.text = ""
  34. if id1 and value1 then
  35. local a_name,b_name = GameResPath.GetAttrIcon(id1)
  36. lua_resM:setImageSprite(self, self.attr_icon1_img, a_name, b_name,true)
  37. local _, name, _, val = WordManager:GetPropertyInfo(id1, value1)
  38. local str = string.format("%s: %s", name, val)
  39. self.attr_text1_tmp.text = str
  40. self.attr_icon1_obj:SetActive(true)
  41. else
  42. self.attr_text1_tmp.text = ""
  43. self.attr_icon1_obj:SetActive(false)
  44. end
  45. if id2 and value2 then
  46. local a_name,b_name = GameResPath.GetAttrIcon(id2)
  47. lua_resM:setImageSprite(self, self.attr_icon2_img, a_name, b_name,true)
  48. local _, name, _, val = WordManager:GetPropertyInfo(id2, value2)
  49. local str = string.format("%s: %s", name, val)
  50. self.attr_text2_tmp.text = str
  51. self.attr_icon2_obj:SetActive(true)
  52. else
  53. self.attr_text2_tmp.text = ""
  54. self.attr_icon2_obj:SetActive(false)
  55. end
  56. if next_value1 then
  57. self.up_image1_obj:SetActive(true)
  58. self.add_text1_tmp.text = HtmlColorTxt(next_value1, ColorUtil.GREEN_DARK)
  59. else
  60. self.up_image1_obj:SetActive(false)
  61. self.add_text1_tmp.text = ""
  62. end
  63. if next_value2 then
  64. self.up_image2_obj:SetActive(true)
  65. self.add_text2_tmp.text = HtmlColorTxt(next_value2, ColorUtil.GREEN_DARK)
  66. else
  67. self.up_image2_obj:SetActive(false)
  68. self.add_text2_tmp.text = ""
  69. end
  70. elseif self.special_data then
  71. local a_name,b_name = GameResPath.GetAttrIcon(self.special_data[1])
  72. lua_resM:setImageSprite(self, self.attr_icon1_img, a_name, b_name,true)
  73. local _, name, _, val = WordManager:GetPropertyInfo(self.special_data[1], self.special_data[2])
  74. local str = string.format("%s: %s", name, val)
  75. self.attr_text1_tmp.text = HtmlColorTxt(str, ColorUtil.PURPLE_DARK)
  76. self.attr_text2_tmp.text = ""
  77. if self.is_active then
  78. self.extra_text_tmp.text = ""
  79. else
  80. self.extra_text_tmp.text = HtmlColorTxt("(解锁全部染色获得)", ColorUtil.PURPLE_DARK)
  81. end
  82. self.attr_icon1_obj:SetActive(true)
  83. self.attr_icon2_obj:SetActive(false)
  84. self.up_image1_obj:SetActive(false)
  85. self.add_text1_tmp.text = ""
  86. self.up_image2_obj:SetActive(false)
  87. self.add_text2_tmp.text = ""
  88. end
  89. self.bg_obj:SetActive(not self.is_active_view)
  90. end
  91. function LightAttrItem:SetData( index, data, is_active_view )
  92. self.index = index
  93. self.data = data
  94. self.is_active_view = is_active_view or self.is_active_view
  95. if self.is_loaded then
  96. self.need_refreshData = false
  97. self:UpdateView()
  98. else
  99. self.need_refreshData = true
  100. end
  101. end
  102. function LightAttrItem:SetSpecialData( i, special_data, active )
  103. self.index = index
  104. self.special_data = special_data
  105. self.is_active = active
  106. if self.is_loaded then
  107. self.need_refreshData = false
  108. self:UpdateView()
  109. else
  110. self.need_refreshData = true
  111. end
  112. end
  113. function LightAttrItem:__delete( )
  114. end