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

76 lines
2.0 KiB

  1. LightAttrItemThree = LightAttrItemThree or BaseClass(BaseItem)
  2. local LightAttrItemThree = LightAttrItemThree
  3. -- LightAttrItemThree.Width = 200
  4. -- LightAttrItemThree.Height = 90
  5. function LightAttrItemThree:__init()
  6. self.base_file = "light"
  7. self.layout_file = "LightAttrItemThree"
  8. self.model = FosterModel:GetInstance()
  9. self:Load()
  10. end
  11. function LightAttrItemThree:Load_callback()
  12. self.nodes = {
  13. "lb_num:tmp", "attr_icon1:img", "lb_attr:tmp", "lb_add:tmp", "up_image1:obj", "bg:obj",
  14. }
  15. self:GetChildren(self.nodes)
  16. self:AddEvents()
  17. if self.need_refreshData then
  18. self:UpdateView()
  19. end
  20. -- local x = GetAnchoredPosition( self.lb_num.transform )
  21. -- SetAnchoredPositionX( self.lb_num.transform, x+34 )
  22. self.lb_num_tmp.text = ""
  23. end
  24. function LightAttrItemThree:AddEvents( )
  25. end
  26. function LightAttrItemThree:UpdateView( )
  27. if not self.data then return end
  28. -- attr_id1
  29. -- value1
  30. -- next_value1
  31. local change_num = (self.data.next_value1 or self.data.value1) - self.data.value1
  32. change_num = change_num > 0 and change_num or 0
  33. if change_num > 0 then
  34. local _, name1, _, val1 = WordManager:GetPropertyInfo(tonumber(self.data.attr_id1), change_num)
  35. self.lb_add_tmp.text = val1
  36. self.up_image1_obj:SetActive(true)
  37. else
  38. self.lb_add_tmp.text = ""
  39. self.up_image1_obj:SetActive(false)
  40. end
  41. local _, name1, _, val1 = WordManager:GetPropertyInfo(tonumber(self.data.attr_id1), self.data.value1)
  42. self.lb_attr_tmp.text = name1 .. "" .. HtmlColorTxt( val1 , '#ffffff')
  43. -- self.lb_num_tmp.text =
  44. if WordManager:GetAttrIsSpecial(self.data.attr_id1) then
  45. SetAttrIconByColorType(self, self.attr_icon1_img, self.data.attr_id1, nil, 2)
  46. else
  47. SetAttrIconByColorType(self, self.attr_icon1_img, self.data.attr_id1, nil, 1)
  48. end
  49. -------------------------
  50. self.bg_obj:SetActive(self.index%2 == 1)
  51. end
  52. function LightAttrItemThree:SetData( index, data)
  53. self.index = index
  54. self.data = data
  55. if self.is_loaded then
  56. self.need_refreshData = false
  57. self:UpdateView()
  58. else
  59. self.need_refreshData = true
  60. end
  61. end
  62. function LightAttrItemThree:__delete( )
  63. end