源战役客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

220 行
7.1 KiB

EquipToolTipsAttr = EquipToolTipsAttr or BaseClass(BaseItem)
EquipToolTipsAttr.Height = 27
local EquipToolTipsAttr = EquipToolTipsAttr
function EquipToolTipsAttr:__init()
self.base_file = "common"
self.layout_file = "EquipToolTipsAttr"
self.is_delay_callback = true
self.attrType = EquipToolTips.AttrType.BaseAttr
self.model = EquipModel:getInstance()
self.height = 27
self.item_height = 0
self.attr_list = {}
self.pos_data = {}
self:Load()
end
function EquipToolTipsAttr:Load_callback()
self.nodes = {
"suit_con:obj","zhuoyue_con:obj","suit_con/suitText:tmp"
,"base_con:obj","attr_con:obj","title:tmp",
}
self:GetChildren(self.nodes)
if self.need_refreshData then
self:SetData(self.data)
end
self:InitEvent()
end
function EquipToolTipsAttr:InitEvent()
-- local function clickHandler(target)
-- if target == self.touch_obj then
-- end
-- end
-- AddClickEvent(self.touch_obj, clickHandler,2)
end
function EquipToolTipsAttr:__delete()
for k,v in pairs(self.attr_list) do
v:DeleteMe()
v = nil
end
self.attr_list = {}
end
function EquipToolTipsAttr:SetData(vo,attrType,value,equip_cfg,is_last,empower_lv)
self.data = vo
self.attrType = attrType or self.attrType
self.value = value or self.value
self.equip_cfg = equip_cfg or self.equip_cfg
self.is_last = is_last or self.is_last
self.empower_lv = empower_lv or self.empower_lv
if self.is_loaded then
self.need_refreshData = false
else
self.need_refreshData = true
return
end
-- print("huangcong:EquipToolTipsAttr [start:56] self.data:", self.data)
-- PrintTable(self.data)
-- print("huangcong:EquipToolTipsAttr [end]")
--基础属性
if self.attrType == EquipToolTips.AttrType.BaseAttr then
self.base_con_obj:SetActive(true)
-- if self.value and self.value[1] and self.value[1] > 0 then
-- self.base_strangthen_txt.text = string.format("<color=%s>(精炼+%s)</color>",ColorUtil.GREEN_DARK,self.value[1])
-- else
-- self.base_strangthen_txt.text = ""
-- end
self.title_tmp.text = "基础属性(基础+精炼)"
self.item_class = EquipToolTipsBaseAttr
--升星属性
elseif self.attrType == EquipToolTips.AttrType.EvolutionAttr then
self.base_con_obj:SetActive(true)
self.item_class = EquipToolTipsBaseAttr
self.title_tmp.text = "升星属性"
-- self.base_strangthen_txt.text = string.format("<color=%s>(升星+%s)</color>",ColorUtil.GREEN_DARK,self.value)
--高级属性
elseif self.attrType == EquipToolTips.AttrType.ZhuoyueAttr then
self.zhuoyue_con_obj:SetActive(true)
self.item_class = EquipToolTipsZhuoYueAttr
local level = 0
for k,v in pairs(self.data) do
if v and v[1] and v[1][1] then
level = level + 1
end
end
if self.value - level > 0 then--还有可升星的
self.title_tmp.text = string.format("高级属性(剩余%s条可升星解锁)",self.value - level)
else
self.title_tmp.text ="高级属性"
end
--宝石属性
elseif self.attrType == EquipToolTips.AttrType.GemstoneAttr then
self.item_class = EquipToolTipsGemstoneAttr
local new_gems_info = {}
for i=1,3 do
new_gems_info[i] = self.data[i] or {}
end
self.data = new_gems_info
self.title_tmp.text = "宝石属性"
--刻印属性
elseif self.attrType == EquipToolTips.AttrType.DraconicAttr then
self.item_class = EquipToolTipsDraconicAttr
self.title_tmp.text = "刻印属性"
--技能
elseif self.attrType == EquipToolTips.AttrType.Skill then
self.item_class = EquipToolTipsSkillAttr
self.title_tmp.text = "技能"
--套装属性
elseif self.attrType == EquipToolTips.AttrType.SuitAttr then
self.suit_con_obj:SetActive(true)
self.item_class = EquipToolTipsSuitAttr
local is_color_ok = self.value.is_color_ok or false
if self.data[1] then
local cur_suit_id_num,suit_equip_pos_list = self.value.cur_suit_id_num,self.value.suit_equip_pos_list
-- suit_equip_pos_list = is_color_ok and suit_equip_pos_list or {}
-- cur_suit_id_num = is_color_ok and cur_suit_id_num or 0
local suit_str = nil
for i,v in ipairs(self.data[1].suit_equip) do
if i ~= EquipModel.EquipType.Guard then
local equip_name = Config.ConfigEquipShow[v].name
if not suit_str then
suit_str = HtmlColorTxt(equip_name, not suit_equip_pos_list[v] and ColorUtil.GRAY_DARK or "#ffffff")
else
suit_str = suit_str.." "..HtmlColorTxt(equip_name, not suit_equip_pos_list[v] and ColorUtil.GRAY_DARK or "#ffffff")
end
end
end
self.suitText_tmp.text = suit_str
--当前穿了几件套装相关
local suit_num_str = ""
local name = Trim(self.data[#self.data].name)
if cur_suit_id_num then
suit_num_str = string.format("%s/%s",cur_suit_id_num <= self.data[1].suit_num_max and cur_suit_id_num or self.data[1].suit_num_max,self.data[1].suit_num_max)
-- suit_num_str = cur_suit_id_num > 0 and HtmlColorTxt(suit_num_str, ColorUtil.GREEN_DARK) or suit_num_str
self.value = cur_suit_id_num
for i,v in ipairs(self.data) do
if cur_suit_id_num <= v.suit_num then
name = Trim(v.name)
end
end
else
suit_num_str = "0/"..self.data[1].suit_num_max
end
self.title_tmp.text = string.format("%s(%s)%s", Trim(name),suit_num_str,not is_color_ok and HtmlColorTxt("橙品装备可激活", ColorUtil.RED_DARK) or "")
local sort_func = function ( a, b )
return a.suit_num < b.suit_num
end
table.sort(self.data, sort_func)
end
self.pos_data = {}
local pos_value = 0
for i,vo in ipairs(self.data) do
if vo.stage_attr then
pos_value = #vo.stage_attr + pos_value
self.pos_data[i] = {#self.data,pos_value}
end
end
elseif self.attrType == EquipToolTips.AttrType.EmpowerAttr then
self.base_con_obj:SetActive(true)
self.title_tmp.text = "升品属性"
-- if self.empower_lv and self.empower_lv > 0 then
-- self.base_strangthen_txt.text = string.format("<color=%s>(精炼+%s)</color>",ColorUtil.GREEN_DARK,self.empower_lv)
-- else
-- self.base_strangthen_txt.text = ""
-- end
self.item_class = EquipToolTipsBaseAttr
end
self:UpdateAttrList()
end
function EquipToolTipsAttr:UpdateAttrList( )
if not self.item_class or not self.data then return end
local data = self.data
for k,v in pairs(self.attr_list) do
v:SetVisible(true)
end
local y = 0
local real_len = 0
for i,v in ipairs(data) do
local item = self.attr_list[i]
if not item then
item = self.item_class.New(self.attr_con)
self.attr_list[i] = item
if self.attrType == EquipToolTips.AttrType.SuitAttr then--装备套装要计算排版位置
if i == 1 then
y = 0
else
real_len = #v.attr+real_len
y = -self.item_class.Height*real_len + 12*(i-1)
end
else
y = -self.item_class.Height*(i - 1)
end
item:SetPosition(0, y)
end
if self.attrType == EquipToolTips.AttrType.EmpowerAttr then
item:SetData(v, i, self.value, ColorUtil.RED_DARK)
else
item:SetData(v, i, self.value, self.pos_data[i])
end
item:SetVisible(true)
end
if self.attrType == EquipToolTips.AttrType.SuitAttr then--装备套装要计算排版位置
else
self.item_height = #data*self.item_class.Height
end
SetSizeDeltaY(self.transform,self.item_height + EquipToolTipsAttr.Height)
if self.call_back and self.is_last then
self.call_back()
end
end
function EquipToolTipsAttr:SetCallBack( call_back )
self.call_back = call_back
end