LightAttrItem = LightAttrItem or BaseClass(BaseItem) local LightAttrItem = LightAttrItem function LightAttrItem:__init(parent_wnd,prefab_asset,layer_name,layout_file) self.parent_wnd = parent_wnd or false -- 父容器 self.prefab_asset = prefab_asset or false --预制体 如果有传进来就直接通过预制体创建对象 免去加载预制体的过程 self.layer_name = layer_name or false --需要挂接特效的时候 必须设置 self.base_file = "light" self.layout_file = layout_file or "LightAttrItem" self.model = FashionModel:GetInstance() self:Load() end function LightAttrItem:Load_callback() self.nodes = { "extra_text:tmp","attr_icon1:img:obj","attr_text1:tmp","bg:obj","attr_icon2:img:obj","attr_text2:tmp", "up_image1:obj","add_text2:tmp","add_text1:tmp","up_image2:obj", } self:GetChildren(self.nodes) self:AddEvents() if self.need_refreshData then self:UpdateView() end end function LightAttrItem:AddEvents( ) end function LightAttrItem:UpdateView( ) if self.data then local id1 = self.data.attr_id1 local id2 = self.data.attr_id2 local value1 = self.data.value1 local value2 = self.data.value2 local next_value1 = self.data.next_value1 local next_value2 = self.data.next_value2 self.extra_text_tmp.text = "" if id1 and value1 then local a_name,b_name = GameResPath.GetAttrIcon(id1) lua_resM:setImageSprite(self, self.attr_icon1_img, a_name, b_name,true) local _, name, _, val = WordManager:GetPropertyInfo(id1, value1) local str = string.format("%s: %s", name, val) self.attr_text1_tmp.text = str self.attr_icon1_obj:SetActive(true) else self.attr_text1_tmp.text = "" self.attr_icon1_obj:SetActive(false) end if id2 and value2 then local a_name,b_name = GameResPath.GetAttrIcon(id2) lua_resM:setImageSprite(self, self.attr_icon2_img, a_name, b_name,true) local _, name, _, val = WordManager:GetPropertyInfo(id2, value2) local str = string.format("%s: %s", name, val) self.attr_text2_tmp.text = str self.attr_icon2_obj:SetActive(true) else self.attr_text2_tmp.text = "" self.attr_icon2_obj:SetActive(false) end if next_value1 then self.up_image1_obj:SetActive(true) self.add_text1_tmp.text = HtmlColorTxt(next_value1, ColorUtil.GREEN_DARK) else self.up_image1_obj:SetActive(false) self.add_text1_tmp.text = "" end if next_value2 then self.up_image2_obj:SetActive(true) self.add_text2_tmp.text = HtmlColorTxt(next_value2, ColorUtil.GREEN_DARK) else self.up_image2_obj:SetActive(false) self.add_text2_tmp.text = "" end elseif self.special_data then local a_name,b_name = GameResPath.GetAttrIcon(self.special_data[1]) lua_resM:setImageSprite(self, self.attr_icon1_img, a_name, b_name,true) local _, name, _, val = WordManager:GetPropertyInfo(self.special_data[1], self.special_data[2]) local str = string.format("%s: %s", name, val) self.attr_text1_tmp.text = HtmlColorTxt(str, ColorUtil.PURPLE_DARK) self.attr_text2_tmp.text = "" if self.is_active then self.extra_text_tmp.text = "" else self.extra_text_tmp.text = HtmlColorTxt("(解锁全部染色获得)", ColorUtil.PURPLE_DARK) end self.attr_icon1_obj:SetActive(true) self.attr_icon2_obj:SetActive(false) self.up_image1_obj:SetActive(false) self.add_text1_tmp.text = "" self.up_image2_obj:SetActive(false) self.add_text2_tmp.text = "" end self.bg_obj:SetActive(not self.is_active_view) end function LightAttrItem:SetData( index, data, is_active_view ) self.index = index self.data = data self.is_active_view = is_active_view or self.is_active_view if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function LightAttrItem:SetSpecialData( i, special_data, active ) self.index = index self.special_data = special_data self.is_active = active if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function LightAttrItem:__delete( ) end