LightAttrItemTwo = LightAttrItemTwo or BaseClass(BaseItem)
|
|
local LightAttrItemTwo = LightAttrItemTwo
|
|
|
|
-- LightAttrItemTwo.Width = 200
|
|
-- LightAttrItemTwo.Height = 90
|
|
|
|
function LightAttrItemTwo:__init()
|
|
self.base_file = "light"
|
|
self.layout_file = "LightAttrItemTwo"
|
|
self.model = FosterModel:GetInstance()
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function LightAttrItemTwo: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
|
|
self.lb_num_tmp.text = ""
|
|
end
|
|
|
|
function LightAttrItemTwo:AddEvents( )
|
|
|
|
end
|
|
|
|
function LightAttrItemTwo:UpdateView( )
|
|
if not self.data then return end
|
|
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 .. ": " .. val1
|
|
-- self.lb_num_tmp.text = val1
|
|
|
|
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 == 0)
|
|
end
|
|
|
|
function LightAttrItemTwo: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 LightAttrItemTwo:__delete( )
|
|
|
|
end
|