LightAttrItemThree = LightAttrItemThree or BaseClass(BaseItem) local LightAttrItemThree = LightAttrItemThree -- LightAttrItemThree.Width = 200 -- LightAttrItemThree.Height = 90 function LightAttrItemThree:__init() self.base_file = "light" self.layout_file = "LightAttrItemThree" self.model = FosterModel:GetInstance() self:Load() end function LightAttrItemThree:Load_callback() self.nodes = { "lb_num:tmp", "attr_icon1:img", "lb_attr:tmp", "lb_add:tmp", "up_image1:obj", "bg:obj", } self:GetChildren(self.nodes) self:AddEvents() if self.need_refreshData then self:UpdateView() end -- local x = GetAnchoredPosition( self.lb_num.transform ) -- SetAnchoredPositionX( self.lb_num.transform, x+34 ) self.lb_num_tmp.text = "" end function LightAttrItemThree:AddEvents( ) end function LightAttrItemThree:UpdateView( ) if not self.data then return end -- attr_id1 -- value1 -- next_value1 local change_num = (self.data.next_value1 or self.data.value1) - self.data.value1 change_num = change_num > 0 and change_num or 0 if change_num > 0 then local _, name1, _, val1 = WordManager:GetPropertyInfo(tonumber(self.data.attr_id1), change_num) self.lb_add_tmp.text = val1 self.up_image1_obj:SetActive(true) else self.lb_add_tmp.text = "" self.up_image1_obj:SetActive(false) end local _, name1, _, val1 = WordManager:GetPropertyInfo(tonumber(self.data.attr_id1), self.data.value1) self.lb_attr_tmp.text = name1 .. ": " .. HtmlColorTxt( val1 , '#ffffff') -- self.lb_num_tmp.text = if WordManager:GetAttrIsSpecial(self.data.attr_id1) then SetAttrIconByColorType(self, self.attr_icon1_img, self.data.attr_id1, nil, 2) else SetAttrIconByColorType(self, self.attr_icon1_img, self.data.attr_id1, nil, 1) end ------------------------- self.bg_obj:SetActive(self.index%2 == 1) end function LightAttrItemThree:SetData( index, data) self.index = index self.data = data if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function LightAttrItemThree:__delete( ) end