--只显示装备信息的tips, 可与showiconitem搭配使用
|
|
EquipShowTips = EquipShowTips or BaseClass(EquipToolTips)
|
|
|
|
EquipShowTips.ONLY_SHOW = 0 --只展示信息
|
|
EquipShowTips.COMPOSE_OFF = 1 --显示卸下按钮,点击移除合成物品
|
|
EquipShowTips.EQUIP_RECOMMAND_TARGET = 2 --显示合成装备的推荐属性
|
|
|
|
function EquipShowTips:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "EquipToolTips"
|
|
self.layer_name = "Top"
|
|
|
|
self.use_background = true
|
|
self.click_bg_toClose = true
|
|
self.close_mode = CloseMode.CloseDestroy
|
|
self.destroy_imm = true
|
|
|
|
self.dynamic = nil
|
|
self.is_show_btn = false
|
|
|
|
--self:AddPreLoadList("common_asset",{"star", "com_blackstar"},LuaResManager.RES_TYPE.SPRITE)
|
|
|
|
self.star_list = {}
|
|
self.item_list = {}
|
|
self.fumo_item_list = {}
|
|
self.stone_item_list = {}
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
end
|
|
self.open_callback = function ()
|
|
self:SetData(self.dynamic)
|
|
end
|
|
self.close_callback = function ()
|
|
end
|
|
self.destroy_callback = function ()
|
|
self:Remove()
|
|
end
|
|
end
|
|
|
|
--[[
|
|
dynamic: 在外部整合好的物品动态信息table,一般获取背包中的动态信息即可
|
|
若要实现预览等特殊信息,在外部修改后传入
|
|
type: 枚举类型,实现某个界面的特殊需求,显示某些按钮,实现特定功能
|
|
ych#callback:为了兼容在其它模块触发卸下事件
|
|
]]
|
|
function EquipShowTips:Open(dynamic, x, y, type, callback)
|
|
self.dynamic = dynamic
|
|
self.type = type
|
|
self.pos_x = x
|
|
self.pos_y = y
|
|
self.off_callback = callback
|
|
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function EquipShowTips:Remove()
|
|
if self.icon_item then
|
|
self.icon_item:DeleteMe()
|
|
self.icon_item = nil
|
|
end
|
|
|
|
for i,v in ipairs(self.item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.item_list = {}
|
|
|
|
if self.compareTips then
|
|
self.compareTips:DeleteMe()
|
|
end
|
|
|
|
for i,v in ipairs(self.stone_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.stone_item_list = {}
|
|
for i,v in ipairs(self.fumo_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.fumo_item_list = {}
|
|
|
|
self:DeleteArrowTip()
|
|
if self.addNumComponent then
|
|
if self.change_count_id then
|
|
self.addNumComponent:UnBind(self.change_count_id)
|
|
self.change_count_id = nil
|
|
end
|
|
self.addNumComponent:DeleteMe()
|
|
self.addNumComponent = nil
|
|
end
|
|
end
|
|
|
|
function EquipShowTips:InitEvent()
|
|
local function onBtnClickHandler(target)
|
|
if target == self.takeBtn then
|
|
if self.off_callback ~= nil then
|
|
self.off_callback()
|
|
else
|
|
if self.type == EquipShowTips.COMPOSE_OFF then
|
|
ComposeModel:getInstance():Fire(ComposeEvent.COMPOSE_GOODS_OFF, self.dynamic.goods_id)
|
|
--为了兼容神装打造,取出装备
|
|
EquipModel:getInstance():Fire(ComposeEvent.COMPOSE_GOODS_OFF, self.dynamic.goods_id)
|
|
end
|
|
end
|
|
end
|
|
self:Close()
|
|
end
|
|
AddClickEvent(self.takeBtn, onBtnClickHandler)
|
|
end
|
|
|
|
function EquipShowTips:SetData(dynamic)
|
|
self.dynamic = dynamic
|
|
self.goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.dynamic.type_id)
|
|
if self.dynamic == nil or self.goods_vo == nil then
|
|
return print("EquipShowTips里面没有物品数据")
|
|
end
|
|
|
|
self.show_compare_tips, self.have_equip_data = EquipModel:getInstance():ShowCompareTips(self.goods_vo.goods_id, self.goods_vo.equip_type)
|
|
if self.show_compare_tips then
|
|
self.compare_conta.gameObject:SetActive(true)
|
|
self.compareTips = self.compareTips or EquipCompareTips.New(self.compare_conta, nil, self.layer_name)
|
|
self.compareTips:SetData(self.have_equip_data)
|
|
else
|
|
self.compare_conta.gameObject:SetActive(false)
|
|
end
|
|
|
|
local mainVo = RoleManager.Instance.mainRoleInfo
|
|
local color_str = ColorUtil.WHITE
|
|
if self.goods_vo.level > mainVo.level then
|
|
color_str = ColorUtil.RED
|
|
end
|
|
self.level.text = "<color='#ffc12c'>" .. self.goods_vo.level .. "</color>"
|
|
-- local index = Config.ConfigEquipShow[self.goods_vo.equip_type].index
|
|
self.equip_pos.text = WordManager:GetEquipStyleStr(self.goods_vo.equip_type)
|
|
self.fight.text = self.goods_vo.combat_power or 0
|
|
|
|
if (self.goods_vo.career_id == 0 or mainVo.career == self.goods_vo.career_id) and (self.goods_vo.sex == 0 or self.goods_vo.sex == mainVo.sex) and self.goods_vo.turn <= mainVo.turn then
|
|
color_str = "#ffc12c"
|
|
else
|
|
color_str = ColorUtil.RED
|
|
end
|
|
local career_name = WordManager:GetRoleCareerName(self.goods_vo.career_id,self.goods_vo.turn)
|
|
self.career.text = "<color="..color_str..">" .. career_name .. "</color>"
|
|
-- self:CreateStar(8)
|
|
|
|
self.depot_conta.gameObject:SetActive(false)
|
|
|
|
local stren = ""
|
|
self.dynamic.stren = self.dynamic.stren or 0
|
|
if self.dynamic.stren > 0 then
|
|
stren = "+" .. self.dynamic.stren
|
|
end
|
|
self.nameText.text = "<color="..WordManager.GetGoodsColor(self.goods_vo.color)..">" .. WordManager:GetEquipPrefix(self.dynamic.prefix,"·") .. self.goods_vo.goods_name .. stren .. "</color>"
|
|
local step_str = WordManager:GetEquipStepNum(self.dynamic.type_id)
|
|
self.step_num.text = "<color="..WordManager.GetGoodsColor(self.goods_vo.color)..">" .. step_str .. "</color>"
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_vo.type_id)
|
|
|
|
if self.dynamic.color then
|
|
lua_resM:setImageSprite(self, self.step_bg, "uiComponent_asset", "tsui_pj_"..self.dynamic.color)
|
|
elseif basic then
|
|
lua_resM:setImageSprite(self, self.step_bg, "uiComponent_asset", "tsui_pj_"..basic.color)
|
|
end
|
|
self.icon_item:SetData(self.goods_vo)
|
|
self.equip_score.text = self:GetEquipScore(self.goods_vo.type_id) --self.dynamic.rating
|
|
self.composite_score.text = self:GetFightList(self.dynamic,basic) --self.dynamic.overall_rating or self.dynamic.rating
|
|
|
|
|
|
if basic then
|
|
local base_pro = ErlangParser:GetInstance():Parse(basic.base_attrlist)
|
|
self:SetProperty(base_pro, self.dynamic.stren, basic.equip_type)
|
|
self.fight.text = self.dynamic.combat_power or 0
|
|
end
|
|
|
|
self:SetAddProperty(self.dynamic)
|
|
self:SetWashProperty(self.dynamic)
|
|
self:SetSpiritProperty(self.dynamic)
|
|
if self.dynamic.suit_lv and self.dynamic.suit_lv > 0 then
|
|
self:SetSuitProperty(self.dynamic, self.goods_vo.equip_type)
|
|
end
|
|
if self.dynamic.awakening_lv and self.dynamic.awakening_lv > 0 then
|
|
self:SetWakeProperty(self.dynamic)
|
|
end
|
|
if self.dynamic.equip_skill_lv and self.dynamic.equip_skill_lv > 0 then
|
|
self:SetMagicSKill(self.dynamic)
|
|
end
|
|
|
|
self:SetSellState(self.dynamic.sell, self.dynamic.price_type, self.dynamic.type_id)
|
|
self:Refresh()
|
|
end
|
|
|
|
--按钮显示
|
|
function EquipShowTips:SetBtns()
|
|
for i,v in ipairs(self.btn_list) do
|
|
v:SetActive(false)
|
|
end
|
|
|
|
local btn_list = {}
|
|
if self.type == EquipShowTips.COMPOSE_OFF then
|
|
table.insert(btn_list, self.takeBtn)
|
|
end
|
|
for i,v in ipairs(btn_list) do
|
|
v:SetActive(true)
|
|
end
|
|
|
|
self.btn_conta.sizeDelta = Vector2(self.btn_conta.sizeDelta.x, #btn_list * 53)
|
|
--[[local pos_y = self.layout.sizeDelta.y - self.btn_conta.sizeDelta.y + 20
|
|
--prefab做了自适应处理,固定在底部就行了
|
|
if self.goods_vo.type==10 and self.goods_vo.subtype==11 then
|
|
self.btn_conta.transform.anchoredPosition = Vector3(self.btn_conta.transform.anchoredPosition.x, -401, 0)
|
|
else
|
|
self.btn_conta.anchoredPosition = Vector2(self.btn_conta.transform.anchoredPosition.x, -600 + self.stren_y + 20)
|
|
end--]]
|
|
end
|
|
|
|
--刷新相关控件的位置
|
|
function EquipShowTips:Refresh()
|
|
if self.dynamic then
|
|
self:RefreshPosAndSize(self.dynamic)
|
|
self:SetRootPos()
|
|
self:SetBtns()
|
|
end
|
|
end
|
|
|
|
|
|
function EquipShowTips:GetFightList( dynamic,basic)
|
|
local list = {}
|
|
if basic then
|
|
--基础属性
|
|
local base_pro = ErlangParser:GetInstance():Parse(basic.base_attrlist)
|
|
for i,v in ipairs(base_pro) do
|
|
table.insert(list,{attr_id = v[1],attr_val = v[2]})
|
|
end
|
|
|
|
local equip_cfg = Config.Equipattr[basic.type_id]
|
|
if equip_cfg then
|
|
local parse_list = ErlangParser:GetInstance():Parse(equip_cfg.extra_attr)
|
|
if parse_list and #parse_list > 0 then
|
|
for i,v in ipairs(parse_list) do
|
|
table.insert(list,{attr_id = tonumber(v[2]),attr_val = tonumber(v[3])})
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
if dynamic.equip_extra_attr then
|
|
--极品属性
|
|
for i,v in ipairs(dynamic.equip_extra_attr) do
|
|
table.insert(list,{attr_id = v.attr_id,attr_val = v.attr_val})
|
|
end
|
|
end
|
|
|
|
local stren_config = EquipModel:getInstance():GetStrengthConfig(basic.equip_type, dynamic.stren)
|
|
if stren_config and Trim(stren_config.attr_list) ~= "[]" then
|
|
pro_list = ErlangParser:GetInstance():Parse(stren_config.attr_list)
|
|
for i,v in ipairs(pro_list) do
|
|
table.insert(list,{attr_id = v[1],attr_val = v[2]})
|
|
end
|
|
end
|
|
|
|
local temp_attr_id,temp_attr_val
|
|
--说明之前有装备
|
|
local base_attr_list = {
|
|
[1] = 0,
|
|
[2] = 0,
|
|
[3] = 0,
|
|
[4] = 0,
|
|
[5] = 0,
|
|
[6] = 0,
|
|
[7] = 0,
|
|
[8] = 0,
|
|
}
|
|
|
|
local wear_equip = GoodsModel:getInstance().wear_equip_dic[dynamic.goods_id]
|
|
if wear_equip == nil then
|
|
--要先减去当前穿的,然后加上要替换的基础属性跟魂火属性
|
|
if self.show_compare_tips then
|
|
--print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.穿戴id ",self.have_equip_data.type_id)
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.have_equip_data.type_id)
|
|
if basic then
|
|
local list = ErlangParser:GetInstance():Parse(basic.base_attrlist)
|
|
if list and #list > 0 then
|
|
for index,data in ipairs(list) do
|
|
temp_attr_id = tonumber(data[1])
|
|
if base_attr_list[temp_attr_id] then
|
|
base_attr_list[temp_attr_id] = base_attr_list[temp_attr_id] - tonumber(data[2])
|
|
-- print("当前减去穿戴基础属性 ",temp_attr_id,tonumber(data[2]))
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
local equip_cfg = Config.Equipattr[self.have_equip_data.type_id]
|
|
if equip_cfg then
|
|
local list = ErlangParser:GetInstance():Parse(equip_cfg.extra_attr)
|
|
if list and #list > 0 then
|
|
for index,data in ipairs(list) do
|
|
temp_attr_id = tonumber(data[2])
|
|
if base_attr_list[temp_attr_id] then
|
|
base_attr_list[temp_attr_id] = base_attr_list[temp_attr_id] - tonumber(data[3])
|
|
-- print("当前减去魂火基础属性 ",temp_attr_id,tonumber(data[3]))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
--加上要替换的基础属性跟魂火属性
|
|
if basic then
|
|
--print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.替换id ",basic.type_id)
|
|
local list = ErlangParser:GetInstance():Parse(basic.base_attrlist)
|
|
if list and #list > 0 then
|
|
for index,data in ipairs(list) do
|
|
temp_attr_id = tonumber(data[1])
|
|
if base_attr_list[temp_attr_id] then
|
|
base_attr_list[temp_attr_id] = base_attr_list[temp_attr_id] + tonumber(data[2])
|
|
--print("当前加上替换基础属性 ",temp_attr_id,tonumber(data[2]))
|
|
end
|
|
end
|
|
end
|
|
|
|
local equip_cfg = Config.Equipattr[basic.type_id]
|
|
if equip_cfg then
|
|
local list = ErlangParser:GetInstance():Parse(equip_cfg.extra_attr)
|
|
if list and #list > 0 then
|
|
for index,data in ipairs(list) do
|
|
temp_attr_id = tonumber(data[2])
|
|
if base_attr_list[temp_attr_id] then
|
|
base_attr_list[temp_attr_id] = base_attr_list[temp_attr_id] + tonumber(data[3])
|
|
-- print("当前加上替换魂火属性 ",temp_attr_id,tonumber(data[3]))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
local AllProList = {}
|
|
local tempList = {}
|
|
local mainVo = RoleManager.Instance.mainRoleInfo
|
|
for i,v in ipairs(list) do
|
|
local cfg = Config.ConfigAttributeAddition[v.attr_id]
|
|
if cfg then
|
|
--print("人物当前最基础属性 ",v.attr_id,mainVo[cfg.baseAttrVo] )
|
|
local val = v.attr_val * (mainVo[cfg.baseAttrVo] + (base_attr_list[cfg.baseAttr] or 0)) / 10000
|
|
table.insert(tempList,{attr_id = cfg.baseAttr,attr_val = val})
|
|
else
|
|
table.insert(AllProList,v)
|
|
end
|
|
end
|
|
for i,v in ipairs(tempList) do
|
|
table.insert(AllProList,v)
|
|
end
|
|
local endList = {}
|
|
for i,v in ipairs(AllProList) do
|
|
table.insert(endList,{[1] = v.attr_id,[2] = v.attr_val})
|
|
end
|
|
return GetFighting(endList)
|
|
end
|
|
|
|
function EquipShowTips:GetEquipScore(type_id)
|
|
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
|
|
|
|
local score = 0
|
|
local dict = {}
|
|
if basic then
|
|
--基础属性
|
|
local attr_id
|
|
local base_pro = ErlangParser:GetInstance():Parse(basic.base_attrlist)
|
|
for i,v in ipairs(base_pro) do
|
|
attr_id = tonumber(v[1])
|
|
if dict[attr_id] then
|
|
dict[attr_id] = dict[attr_id] + tonumber(v[2])
|
|
else
|
|
dict[attr_id] = tonumber(v[2])
|
|
end
|
|
end
|
|
end
|
|
|
|
local equip_cfg = Config.Equipattr[type_id]
|
|
if equip_cfg then
|
|
local parse_list = ErlangParser:GetInstance():Parse(equip_cfg.extra_attr)
|
|
if parse_list and #parse_list > 0 then
|
|
for i,v in ipairs(parse_list) do
|
|
attr_id = tonumber(v[2])
|
|
if dict[attr_id] then
|
|
dict[attr_id] = dict[attr_id] + tonumber(v[3])
|
|
else
|
|
dict[attr_id] = tonumber(v[3])
|
|
end
|
|
end
|
|
end
|
|
|
|
parse_list = ErlangParser:GetInstance():Parse(equip_cfg.recommend_attr)
|
|
if parse_list and #parse_list > 0 then
|
|
for i,v in ipairs(parse_list) do
|
|
attr_id = tonumber(v[2][2])
|
|
if dict[attr_id] then
|
|
dict[attr_id] = dict[attr_id] + tonumber(v[2][3])
|
|
else
|
|
dict[attr_id] = tonumber(v[2][3])
|
|
end
|
|
end
|
|
end
|
|
|
|
local config
|
|
for key,value in pairs(dict) do
|
|
config = Config.Equipattrrating[key .. "@" .. equip_cfg.stage]
|
|
if config then
|
|
score = score + value * config.rating
|
|
end
|
|
end
|
|
end
|
|
|
|
return score
|
|
end
|