|
BeastCompareTips = BeastCompareTips or BaseClass(BaseItem)
|
|
|
|
function BeastCompareTips:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "BeastCompareTips"
|
|
self.goods_vo = nil
|
|
self.model = GoodsModel:getInstance()
|
|
|
|
self.star_list = {}
|
|
self.item_list = {}
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function BeastCompareTips:__delete()
|
|
if self.icon_item then
|
|
self.icon_item:DeleteMe()
|
|
end
|
|
|
|
if self.arrowHint then
|
|
self.arrowHint:DeleteMe()
|
|
self.arrowHint = nil
|
|
end
|
|
for i,v in ipairs(self.item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.item_list = {}
|
|
|
|
if self.expire_label then
|
|
lua_viewM:ClearItem(self.expire_label)
|
|
self.expire_label = nil
|
|
end
|
|
end
|
|
|
|
function BeastCompareTips:Load_callback()
|
|
self.bg = self:GetChild("normal/bg")
|
|
self.icon_con = self:GetChild("normal/icon_con")
|
|
self.nameText = self:GetChild("normal/nameText"):GetComponent("Text")
|
|
self.composite_score = self:GetChild("normal/composite_score"):GetComponent("Text")
|
|
self.equip_score = self:GetChild("normal/equip_score"):GetComponent("Text")
|
|
self.ScrollView = self:GetChild("normal/ScrollView")
|
|
self.ScrollViewContent = self:GetChild("normal/ScrollView/Viewport/Content")
|
|
self.ScrollViewViewport = self:GetChild("normal/ScrollView/Viewport")
|
|
self.line1 = self:GetChild("normal/ScrollView/Viewport/Content/line1")
|
|
self.line2 = self:GetChild("normal/ScrollView/Viewport/Content/line2")
|
|
self.ui_line2 = self:GetChild("normal/ui_line2")
|
|
|
|
self.baseName = self:GetChild("normal/ScrollView/Viewport/Content/baseName"):GetComponent("Text")
|
|
self.basePro = self:GetChild("normal/ScrollView/Viewport/Content/basePro"):GetComponent("Text")
|
|
self.strengthAdd = self:GetChild("normal/ScrollView/Viewport/Content/strengthAdd"):GetComponent("Text")
|
|
self.add_name = self:GetChild("normal/ScrollView/Viewport/Content/line2/Text"):GetComponent("Text")
|
|
self.addName = self:GetChild("normal/ScrollView/Viewport/Content/addName"):GetComponent("Text")
|
|
self.addPro = self:GetChild("normal/ScrollView/Viewport/Content/addPro"):GetComponent("Text")
|
|
|
|
self.down_arrow = self:GetChild("normal/down_arrow")
|
|
self.sell_conta = self:GetChild("normal/sell_conta")
|
|
self.sell_icon = self:GetChild("normal/sell_conta/icon"):GetComponent("Image")
|
|
self.price_label = self:GetChild("normal/sell_conta/price_label"):GetComponent("Text")
|
|
self.info_content = self:GetChild("normal/info_content"):GetComponent("Text")
|
|
self.compare_conta = self:GetChild("compare_conta")
|
|
|
|
self.icon_item = BagIconItem.New(self.icon_con,false,self.layer_name)
|
|
self.icon_item:ChangeCountVisible(false)
|
|
|
|
self:InitEvent()
|
|
|
|
if self.need_refresh then
|
|
self:SetData(self.goods_vo)
|
|
end
|
|
end
|
|
|
|
function BeastCompareTips:InitEvent()
|
|
|
|
end
|
|
|
|
function BeastCompareTips:SetData(goods_vo)
|
|
self.goods_vo = goods_vo
|
|
if self.goods_vo == nil then return print("BeastCompareTips里面没有物品数据") end
|
|
|
|
if self.is_loaded then
|
|
if self.goods_vo.expire_time then
|
|
if self.goods_vo.expire_time == 0 then
|
|
if self.expire_label then
|
|
self.expire_label:SetActive(false)
|
|
end
|
|
else
|
|
if not self.expire_label then
|
|
self.expire_label = UiFactory.createChild(self.star_conta, UIType.Label2,"expire_label")
|
|
self.expire_label.transform.pivot = Vector2(0, 1)
|
|
end
|
|
self.expire_label:SetActive(true)
|
|
local text = ""
|
|
if TimeUtil:getServerTime() > self.goods_vo.expire_time then
|
|
text = "<color=#de4141>已过期</color>"
|
|
else
|
|
local time = self.goods_vo.expire_time - TimeUtil:getServerTime()
|
|
text = string.format("<color=#fac090>【%s】后过期</color>",TimeUtil:timeConvert6(time))
|
|
end
|
|
self.expire_label:GetComponent("Text").text = text
|
|
self.expire_label.transform.sizeDelta = Vector2(280, 30)
|
|
end
|
|
else
|
|
if self.expire_label then
|
|
self.expire_label:SetActive(false)
|
|
end
|
|
end
|
|
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_vo.type_id)
|
|
if basic then
|
|
self.info_content.text = basic.intro
|
|
end
|
|
|
|
if self.goods_vo.goods_id then
|
|
local callback = function (dynamic)
|
|
if self.goods_vo.goods_id and dynamic and self.goods_vo.goods_id == dynamic.goods_id then
|
|
self.dynamic = dynamic
|
|
self.dynamic.stren = dynamic.stren or 0
|
|
local stren = ""
|
|
if dynamic.stren and dynamic.stren > 0 then
|
|
stren = "+" ..dynamic.stren
|
|
end
|
|
self.nameText.text = "<color="..WordManager.GetGoodsColor(self.dynamic.color)..">" .. WordManager:GetEquipPrefix(self.dynamic.prefix,"·") .. self.goods_vo.goods_name .. stren .. "</color>"
|
|
self.icon_item:SetData(self.goods_vo)
|
|
--local star = Config.Equipattr[self.goods_vo.type_id] and Config.Equipattr[self.goods_vo.type_id].star or 0
|
|
-- self:CreateStar(star)
|
|
self.composite_score.text = self.dynamic.overall_rating
|
|
self.equip_score.text = self.dynamic.rating
|
|
|
|
if basic then
|
|
local base_pro = ErlangParser:GetInstance():Parse(basic.base_attrlist)
|
|
self:SetProperty(base_pro, dynamic.stren, basic.equip_type)
|
|
end
|
|
self:SetAddProperty(self.dynamic)
|
|
|
|
self:Refresh()
|
|
--self:ShowReDot()
|
|
end
|
|
end
|
|
GoodsModel:getInstance():GetDynamic(self.goods_vo.goods_id, callback)
|
|
end
|
|
|
|
--self:Refresh()
|
|
else
|
|
self.need_refresh = true
|
|
end
|
|
end
|
|
|
|
--设置附加属性
|
|
function BeastCompareTips:SetAddProperty(dynamic)
|
|
if dynamic and dynamic.equip_extra_attr then
|
|
local name_str = ""
|
|
local pro_str = ""
|
|
|
|
for i,v in ipairs(dynamic.equip_extra_attr) do
|
|
if v.type_id == 1 then
|
|
name_str = name_str .. "<color="..WordManager.GetGoodsColor(v.color)..">每"..v.plus_interval.."级"..WordManager:GetProperties(tonumber(v.attr_id)).."</color>"
|
|
pro_str = pro_str .."<color="..WordManager.GetGoodsColor(v.color)..">+"..WordManager:GetPropertyValue(tonumber(v.attr_id), tonumber(v.plus_unit)) .. "</color>"
|
|
else
|
|
name_str = name_str .. "<color=" .. WordManager.GetGoodsColor(v.color) .. ">"..WordManager:GetProperties(tonumber(v.attr_id)).."</color>"
|
|
pro_str = pro_str .. "<color="..WordManager.GetGoodsColor(v.color)..">+"..WordManager:GetPropertyValue(tonumber(v.attr_id), v.attr_val).."</color>"
|
|
end
|
|
if i < #dynamic.equip_extra_attr then
|
|
name_str = name_str .. "\n"
|
|
pro_str = pro_str .. "\n"
|
|
end
|
|
end
|
|
self.addName.text = name_str
|
|
self.addPro.text = pro_str
|
|
end
|
|
end
|
|
|
|
--刷新相关控件的位置
|
|
function BeastCompareTips:Refresh()
|
|
if self.goods_vo then
|
|
self:RefreshPosAndSize(self.dynamic)
|
|
end
|
|
end
|
|
|
|
--设置基础属性
|
|
function BeastCompareTips:SetProperty(base_pro, stren, pos)
|
|
stren = stren or 0
|
|
local stren_config = EquipModel:getInstance():GetStrengthConfig(pos, stren)
|
|
local name_str = ""
|
|
local pro_str = ""
|
|
local stren_str = ""
|
|
local pro_list = {}
|
|
if stren_config and Trim(stren_config.attr_list) ~= "[]" then
|
|
pro_list = ErlangParser:GetInstance():Parse(stren_config.attr_list)
|
|
end
|
|
for i,v in ipairs(base_pro) do
|
|
name_str = name_str .. WordManager:GetProperties(tonumber(v[1]))
|
|
pro_str = pro_str.."+" .. WordManager:GetPropertyValue(tonumber(v[1]),tonumber(v[2]))
|
|
for i2, v2 in ipairs(pro_list) do
|
|
if tonumber(v2[1]) == tonumber(v[1]) then
|
|
stren_str = stren_str .. "<color="..ColorUtil.GREEN..">(强化+" .. v2[2] .. ")</color>"
|
|
end
|
|
end
|
|
|
|
if i < #base_pro then
|
|
name_str = name_str.."\n"
|
|
pro_str = pro_str.."\n"
|
|
stren_str = stren_str.."\n"
|
|
end
|
|
end
|
|
self.baseName.text = name_str
|
|
self.basePro.text = pro_str
|
|
self.strengthAdd.text = stren_str
|
|
end
|
|
|
|
--更新各个控件的位置
|
|
function BeastCompareTips:RefreshPosAndSize(dynamic)
|
|
local off_y = 0
|
|
off_y = self.basePro.preferredHeight + 15
|
|
SetSizeDelta(self.baseName.transform, self.baseName.transform.sizeDelta.x, off_y)
|
|
SetSizeDelta(self.basePro.transform, self.basePro.transform.sizeDelta.x, off_y)
|
|
off_y = off_y + 30
|
|
|
|
local show_add = false
|
|
if dynamic and dynamic.equip_extra_attr and #dynamic.equip_extra_attr > 0 then
|
|
show_add = true
|
|
end
|
|
if show_add then
|
|
self.line2.gameObject:SetActive(true)
|
|
self.addName.gameObject:SetActive(true)
|
|
self.addPro.gameObject:SetActive(true)
|
|
|
|
SetLocalPosition(self.line2, 0, -off_y)
|
|
off_y = off_y + 30
|
|
--显示推荐属性
|
|
if self.type and self.type == EquipShowTips.EQUIP_RECOMMAND_TARGET then
|
|
SetLocalPosition(self.addName.transform, self.addName.transform.localPosition.x, -off_y)
|
|
SetLocalPosition(self.addPro.transform, 160, -off_y)
|
|
SetSizeDelta(self.addName.transform, 130, self.addName.preferredHeight + 15)
|
|
SetSizeDelta(self.addPro.transform, self.addPro.transform.sizeDelta.x, self.addPro.preferredHeight + 15)
|
|
else
|
|
SetLocalPosition(self.addName.transform, self.addName.transform.localPosition.x, -off_y)
|
|
SetLocalPosition(self.addPro.transform, self.addPro.transform.localPosition.x, -off_y)
|
|
SetSizeDelta(self.addName.transform, self.addName.transform.sizeDelta.x, self.addName.preferredHeight + 15)
|
|
SetSizeDelta(self.addPro.transform, self.addPro.transform.sizeDelta.x, self.addPro.preferredHeight + 15)
|
|
end
|
|
off_y = off_y + self.addPro.preferredHeight + 10
|
|
else
|
|
self.line2.gameObject:SetActive(false)
|
|
self.addName.gameObject:SetActive(false)
|
|
self.addPro.gameObject:SetActive(false)
|
|
end
|
|
|
|
self.max_off = 470 - self.info_content.preferredHeight
|
|
|
|
SetSizeDelta(self.ScrollViewContent, self.ScrollViewContent.sizeDelta.x, off_y)
|
|
if off_y > self.max_off then
|
|
--self.down_arrow.gameObject:SetActive(true)
|
|
--self.sell_conta.localPosition = Vector3(22, -643.5, 0)
|
|
self.arrowHint = self.arrowHint or ArrowHint.New()
|
|
self.arrowHint:Init(self, self.ScrollView, self.ScrollViewContent, self.down_arrow, nil, self.layer_name, nil, 0.7)
|
|
|
|
SetSizeDelta(self.ScrollView, self.ScrollView.sizeDelta.x, self.max_off)
|
|
SetSizeDelta(self.ScrollViewViewport, self.ScrollViewViewport.sizeDelta.x, self.max_off)
|
|
-- self.transform.sizeDelta = Vector2(328, 685)
|
|
SetSizeDelta(self.bg, self.bg.sizeDelta.x, 711)
|
|
else
|
|
self.stren_y = 451 - off_y
|
|
--self.down_arrow.gameObject:SetActive(false)
|
|
--self.down_arrow.localPosition = Vector3(self.down_arrow.localPosition.x, -off_y + self.ScrollView.localPosition.y + 20, 0)
|
|
--self.sell_conta.localPosition = Vector3(22, -off_y + self.ScrollView.localPosition.y, 0)
|
|
SetSizeDelta(self.ScrollView, self.ScrollView.sizeDelta.x, off_y)
|
|
SetSizeDelta(self.ScrollViewViewport, self.ScrollViewViewport.sizeDelta.x, off_y)
|
|
-- self.transform.sizeDelta = Vector2(328, off_y - self.ScrollView.localPosition.y + 60)
|
|
SetSizeDelta(self.bg, self.bg.sizeDelta.x, off_y + self.info_content.preferredHeight + 200)
|
|
end
|
|
SetLocalPosition(self.down_arrow, self.down_arrow.localPosition.x, -self.ScrollView.sizeDelta.y - 165)
|
|
SetLocalPosition(self.info_content.transform, self.info_content.transform.localPosition.x, -self.ScrollView.sizeDelta.y - 180)
|
|
SetLocalPosition(self.ui_line2.transform, self.ui_line2.transform.localPosition.x, -self.ScrollView.sizeDelta.y - 185)
|
|
end
|