--[[@------------------------------------------------------------------ @description:装备对比Tip @author:huangcong ----------------------------------------------------------------------]] EquipCompareTips = EquipCompareTips or BaseClass(BaseItem) local EquipCompareTips = EquipCompareTips function EquipCompareTips:__init(parent_wnd,prefab_asset,layer_name,equip_type) self.base_file = "common" self.equip_type = equip_type if self.equip_type < EquipModel.EquipType.Guard and self.equip_type >= EquipModel.EquipType.Necklace then--首饰 self.layout_file = "EquipToolTips2" elseif self.equip_type == EquipModel.EquipType.Guard then--守护 self.layout_file = "EquipToolTips2" else self.layout_file = "EquipToolTips" end self.is_delay_callback = true self.pos_x = 0 self.pos_y = 0 self.index = 1 self.model = EquipModel:getInstance() self.btn_list = {} self.attr_item_list = {} self.equip_data = nil--装备数据 self.have_zhuoyue = false--是否有卓越 self.have_longyu = false--是否有刻印 self.base_height = 150--基本高度 self.min_height = 375--最低高度 self.have_longyu_height = 687--有刻印的bg最高高度 self.no_longyu_height = 560--无刻印的bg最高高度 self.attr_scroll_height_min = 220 self.attr_scroll_height_max = 403 self:Load() end function EquipCompareTips:Load_callback() local nodes = { --界面通用部分 "con/attr_scroll","con/equip_name:tmp","con/occupation:tmp","con/use_level:tmp","compare_conta","con/icon_con","con", "con/attr_scroll/Viewport/attr_con:obj","con/equip_num:txt","con/goods_name:tmp","con/hava_wear:obj","con/duibi:obj:img", "con/title_bg:img", "con/find_btn:obj","con/di_bg:img","con/goods_color_name:tmp", "con/bg/bgImg:img", --最终版UI新增节点 "con/equip_num_title:tmp", --守护饰品特殊节点 "con/guard_name:tmp", "con/guard_occupation:tmp", "con/guard_title_bg:img", "con/roleCon", "con/ornamentsCon/equip_skill_pro:tmp", "con/ornamentsCon/attrValue:tmp", "con/ornamentsCon/equip_skill_name:tmp", "con/ornamentsCon/descScroll/Viewport/descCon/descText:tmp", "con/ornamentsCon/proImg:img", "con/ornamentsCon:obj", "con/ornamentsCon/descScroll/Viewport/descCon/descImg2:obj", "con/ornamentsCon/descScroll/Viewport/descCon/descImg1:obj","con/ornamentsCon/descScroll/Viewport/descCon/descImg3:obj", "con/ornamentsCon/descScroll:scroll", } self:GetChildren(nodes) lua_resM:setOutsideImageSprite(self,self.bgImg_img,GameResPath.GetViewBigBg("equip_tool_tip_bg"),false) self.find_btn_obj:SetActive(false) self.icon_item = AwardItem.New(self.icon_con, false, self.layer_name) self.icon_item:SetEnableClick(false) self.icon_item:SetItemSize(78, 78) self.icon_item:ChangeCountVisible(false) self:InitEvent() if self.need_refreshData then self:SetData(self.data) end end function EquipCompareTips:InitEvent() -- local function onclick(target) -- end -- AddClickEvent(self.unload_btn_obj,onclick) local function updateOrnamentInfoFunc( vo ) if self.equip_cfg and self.equip_cfg.series == vo.series and self.equip_cfg.equip_type == vo.pos and self.is_wear_equip then self.lv_exp_info = {vo.lv,vo.exp} if self.is_loaded and not self._use_delete_method then self:UpdateOrnamentInfo() end end end self:BindEvent(self.model,EquipModel.UPDATE_EQUIP_TOOL_TIPS_EXP_LV, updateOrnamentInfoFunc) end function EquipCompareTips:__delete( ) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.duibi) if self.icon_item then self.icon_item:DeleteMe() self.icon_item = nil end for i,v in ipairs(self.attr_item_list) do v:DeleteMe() v = nil end self.attr_item_list = {} end function EquipCompareTips:SetData(equip_data) self.equip_data = equip_data or self.equip_data if not self.equip_data then return end if self.is_loaded then self.need_refreshData = false else self.need_refreshData = true return end self.con.gameObject:SetActive(true) self.equip_cfg = self.model:GetEquipmentCfg(self.equip_data.type_id) self:UpdateInfo() self:UpdateAttrList() self:UpdateBgRes()--根据装备会显示不同的背景样式 self:SetDuiBiState(self.duibi_state,self.up) end --更新基本信息 function EquipCompareTips:UpdateInfo( ) local is_wear_equip = EquipModel:getInstance():IsWearEquip(self.equip_data.goods_vo.goods_id) self.is_wear_equip = is_wear_equip self.hava_wear_obj:SetActive(is_wear_equip) local stren_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(self.equip_data.goods_vo) stren_data.equip_key = "EquipView" self.stren_data = stren_data --基本信息 self.icon_item:SetData(self.equip_data.type_id, nil, nil, stren_data, nil,nil,nil,nil,nil,nil,nil,self.equip_data.have_career) self.use_level_tmp.text = string.format("等级:%s",self.equip_cfg.lv) local trun_str = "任意代" if self.equip_cfg.series ~= 99 then trun_str = ChineseNumber(self.equip_cfg.series).."代" end -- self.equip_name_tmp.text = string.format("%s%s",trun_str,EquipConst.PosTypeName[self.equip_cfg.equip_type]) local score = self.model:MathEquipScore(self.equip_data.goods_vo,self.equip_cfg.goods_id) -- self.equip_num_title_tmp.text = self.is_wear_equip and "评分" or "" -- self.equip_num_txt.text = self.is_wear_equip and score or "" self.equip_num_title_tmp.text = "评分" self.equip_num_txt.text = score end --更新属性信息 function EquipCompareTips:UpdateAttrInfo( ) self.attr_info = {} local attr_height = 0 --基础属性 if self.equip_cfg.base_attr and TableSize(self.equip_cfg.base_attr) ~= 0 then self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.BaseAttr,self.equip_cfg.base_attr} attr_height = attr_height + EquipToolTipsAttr.Height + #self.equip_cfg.base_attr*EquipToolTipsBaseAttr.Height end --高级属性 local zhuoyue_attr = {} local strengthen_level = 0 local goods_vo_gems_info = {} local guard_lv_exp_info = {} local star_evolution_lv = self.equip_cfg.color >= 3 and 1 or 0--星级升星属性等级 local evolution_lv_max = self.model:GetEvoMaxLevel(self.equip_cfg.goods_id) local name = self.equip_cfg.name--名字要和高级属性的星级挂钩 local empower_lv = 0 if self.equip_cfg.color >= 5 and self.equip_cfg.equip_type ~= EquipModel.EquipType.Guard then--如果装备品质色红色并且不是守护则加一级升品属性 empower_lv = self.equip_cfg.color - 4 end if self.equip_data.goods_vo then for k,v in pairs(self.equip_data.goods_vo.other_data or {}) do if v.type == GoodsModel.GoodsInfoType.EquipEvoLevel and self.equip_cfg.equip_type < EquipModel.EquipType.Necklace then--非首饰读特殊属性 star_evolution_lv = tonumber(v.info) elseif v.type == GoodsModel.GoodsInfoType.EquipmentLv then strengthen_level = tonumber(v.info) elseif v.type == GoodsModel.GoodsInfoType.GemestoneLv then--宝石信息 goods_vo_gems_info = stringtotable(v.info) elseif v.type == GoodsModel.GoodsInfoType.EquipEmpower then--赋能等级 empower_lv = tonumber(v.info) elseif v.type == GoodsModel.GoodsInfoType.EquipLvExp then--首饰经验值和等级 guard_lv_exp_info = stringtotable(v.info) end end if self.is_wear_equip then--如果是自己的就去请求 self.model:Fire(EquipModel.REQUEST_CCMD_EVENT,15225,self.equip_cfg.series,self.equip_cfg.equip_type) else if guard_lv_exp_info and #guard_lv_exp_info > 0 then self.lv_exp_info = guard_lv_exp_info[1] end end --升星属性 if star_evolution_lv > 0 then local evolution_attr_list = {} local attr_cfg = self.model:GetEquipEvolutionCfg(self.equip_cfg.goods_id,star_evolution_lv) if attr_cfg then self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.EvolutionAttr,attr_cfg.attr,evolution_lv_max} attr_height = attr_height + EquipToolTipsAttr.Height + #attr_cfg.attr*EquipToolTipsBaseAttr.Height end end end if self.equip_cfg.equip_type >= EquipModel.EquipType.Necklace then--首饰展示预览升星属性 for k,attr_cfg in ipairs(self.equip_cfg.great_attr_list or {}) do zhuoyue_attr[#zhuoyue_attr + 1] = {[1] = attr_cfg} end else local equip_evo_cfg = self.model:GetEquipEvolutionCfg(self.equip_cfg.goods_id,star_evolution_lv) if equip_evo_cfg and equip_evo_cfg.great_attr_list then for i=1,evolution_lv_max do zhuoyue_attr[#zhuoyue_attr + 1] = {[1] = equip_evo_cfg.great_attr_list[i]} end end end if self.equip_data.goods_vo and self.equip_data.goods_vo.is_evolution_show then--装备是否是升星下一级展示 zhuoyue_attr[#zhuoyue_attr + 1] = {is_evolution_show = true} end if zhuoyue_attr and TableSize(zhuoyue_attr) ~= 0 then local evolution_lv_max = self.model:GetEvoMaxLevel(self.equip_cfg.goods_id) self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.ZhuoyueAttr,zhuoyue_attr,evolution_lv_max} attr_height = attr_height + EquipToolTipsAttr.Height + #zhuoyue_attr*EquipToolTipsBaseAttr.Height end --宝石属性 if self.equip_cfg.equip_type ~= EquipModel.EquipType.Guard then if self.is_wear_equip then local gems_info = self.model:GetGemstoneSeriesInfo(self.equip_cfg.series,self.equip_cfg.equip_type) if gems_info and TableSize(gems_info) > 0 then self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.GemstoneAttr,gems_info}--构造数据 else self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.GemstoneAttr,{}}--构造数据 end elseif goods_vo_gems_info and #goods_vo_gems_info > 0 then--如果不是自己身上的就要去物品信息里面找 local gems_info = self.model:GetGemstoneEquipToolTipsInfo(goods_vo_gems_info) if gems_info and TableSize(gems_info) > 0 then self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.GemstoneAttr,gems_info}--构造数据 else self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.GemstoneAttr,{}}--构造数据 end else self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.GemstoneAttr,{}}--构造数据 end end --刻印属性 if self.is_wear_equip then local equip_type = self.equip_cfg.equip_type local info_list = self.model:GetEquipPosInfoList(equip_type) if info_list and info_list.carve_id and info_list.carve_id ~= 0 then--刻印激活数据 local draconic_cfg = Config.Equipmentcarve[info_list.carve_id] if draconic_cfg then self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.DraconicAttr,draconic_cfg}--构造数据 end end end --升品属性 if self.is_wear_equip then--如果是已穿戴就拿自己的 if self.equip_cfg and self.equip_cfg.series ~= 99 then local server_info = EquipModel:getInstance():GetRedEquipInfo(self.equip_cfg.series,self.equip_cfg.equip_type) if server_info then empower_lv = server_info and server_info.lv or 0 end end end if empower_lv > 0 then local empower_cfg = self.model:GetRedEquipCfg(self.equip_cfg.series,self.equip_cfg.equip_type,empower_lv) if empower_cfg.attr then self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.EmpowerAttr,empower_cfg.attr} attr_height = attr_height + EquipToolTipsAttr.Height + #self.equip_cfg.base_attr*EquipToolTipsBaseAttr.Height end local goods_name = GoodsModel:getInstance():getGoodsName(self.equip_cfg.goods_id, false) if empower_lv == 1 then--红色名字 self.goods_name_tmp.text = self.equip_cfg.equip_type ~= EquipModel.EquipType.Guard and HtmlColorTxt(goods_name, ColorUtil.RED_DARK) or "" self.guard_name_tmp.text = self.equip_cfg.equip_type == EquipModel.EquipType.Guard and HtmlColorTxt(goods_name, ColorUtil.RED_DARK) or "" self.goods_color_name_tmp.text = "" elseif empower_lv == 2 then--粉色名字 self.goods_name_tmp.text = self.equip_cfg.equip_type ~= EquipModel.EquipType.Guard and HtmlColorTxt(goods_name, ColorUtil.PINK_DARK) or "" self.guard_name_tmp.text = self.equip_cfg.equip_type == EquipModel.EquipType.Guard and HtmlColorTxt(goods_name, ColorUtil.PINK_DARK) or "" self.goods_color_name_tmp.text = "" elseif empower_lv == 3 then--红色名字 self.goods_name_tmp.text = "" self.guard_name_tmp.text = "" self.goods_color_name_tmp.text = goods_name end else local goods_name = GoodsModel:getInstance():getGoodsName(self.equip_cfg.goods_id, true) self.goods_name_tmp.text = self.equip_cfg.equip_type ~= EquipModel.EquipType.Guard and goods_name or "" self.guard_name_tmp.text = self.equip_cfg.equip_type == EquipModel.EquipType.Guard and goods_name or "" end self.empower_lv = empower_lv --套件属性 if self.equip_cfg.equip_type ~= EquipModel.EquipType.Guard then local suit_cfg_list = self.model:GetEquipmentSuitCfg(self.equip_cfg.series,self.equip_cfg.equip_type >= EquipModel.EquipType.Necklace and 2 or 1) if suit_cfg_list then local cur_suit_id_num,suit_equip_pos_list = 0,{} if self.is_wear_equip then cur_suit_id_num,suit_equip_pos_list = GoodsModel:getInstance():GetEquipSuitNum(self.equip_cfg.series,self.equip_cfg.equip_type >= EquipModel.EquipType.Necklace and 2 or 1) elseif self.equip_data and self.equip_data.goods_vo and self.equip_cfg.equip_type < EquipModel.EquipType.Necklace then cur_suit_id_num = self.equip_data.goods_vo.cur_suit_id_num or cur_suit_id_num suit_equip_pos_list = self.equip_data.goods_vo.suit_equip_pos_list or suit_equip_pos_list elseif self.equip_data and self.equip_data.goods_vo and self.equip_cfg.equip_type < EquipModel.EquipType.Necklace then cur_suit_id_num = self.equip_data.goods_vo.necklace_cur_suit_id_num or necklace_cur_suit_id_num suit_equip_pos_list = self.equip_data.goods_vo.necklace_suit_equip_pos_list or necklace_suit_equip_pos_list end local suit_data = { is_color_ok = self.equip_cfg.color >= 4, cur_suit_id_num = cur_suit_id_num, suit_equip_pos_list = suit_equip_pos_list, } self.attr_info[#self.attr_info + 1] = {EquipToolTips.AttrType.SuitAttr,suit_cfg_list,suit_data}--构造数据--true代表是否 attr_height = attr_height + EquipToolTipsAttr.Height + #suit_cfg_list*EquipToolTipsSuitAttr.Height*2 + 45 end end local sort_func = function ( a, b ) return a[1] < b[1] end table.sort(self.attr_info, sort_func) self.attr_height = attr_height + 150 self.strengthen_level = strengthen_level--强化等级 local strength_level_cfg = self.model:GetEquipStrengthAttrCfg(self.equip_cfg.goods_id,self.strengthen_level)--强化属性 if strength_level_cfg and strength_level_cfg.attr then self.strengthen_info = {self.strengthen_level,strength_level_cfg.attr} end self.attr_info[1] = {EquipToolTips.AttrType.BaseAttr,self.equip_cfg.base_attr,self.strengthen_info} -- print("huangcong:EquipToolTips [start:505] 1:", 1) SetSizeDeltaY(self.attr_con,self.attr_height) -- print("huangcong:EquipToolTips [start:209] self.attr_info:", self.attr_info) -- PrintTable(self.attr_info) -- print("huangcong:EquipToolTips [end]") end --更新属性列表 function EquipCompareTips:UpdateAttrList( ) self:UpdateAttrInfo() for k,v in pairs(self.attr_item_list) do v:SetVisible(false) end local function load_ok( ... ) self.attr_con_obj:SetActive(true) end local item_list = self.attr_info self.attr_con_obj:SetActive(false) if not item_list or TableSize(item_list) == 0 then return end local offer_x = 0 local offer_y = 0 local x = 0 local y = 0 for i, v in ipairs(item_list) do local item = self.attr_item_list[i] if item == nil then item = EquipToolTipsAttr.New(self.attr_con,nil,self.layer_name) item:SetCallBack(load_ok) self.attr_item_list[i] = item end item:SetData(v[2],v[1],v[3],self.equip_cfg,i == #item_list,self.empower_lv) item:SetVisible(true) end end function EquipCompareTips:SetDuiBiState( bool,up )--设置对比状态 do return end self.duibi_state = bool self.up = up if self.is_loaded then self:SetDuiBiAction(up) self.duibi_obj:SetActive(bool) lua_resM:setImageSprite(self, self.duibi_img, "common_asset", up and "tyui_Arrow_1" or "tyui_Arrow_2",true) end end function EquipCompareTips:SetDuiBiAction( bool ) if bool then cc.ActionManager:getInstance():removeAllActionsFromTarget(self.duibi) SetLocalPositionY(self.duibi, -80) local x, y = self.duibi:GetLocalPosXY() local action = cc.FloatFadeIn.New(x, y, 0, 10, 0.5, 0.5, self.duibi) cc.ActionManager:getInstance():addAction(action, self.duibi) else SetLocalPositionY(self.duibi, -74) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.duibi) end end --根据装备不同会显示不同的背景样式 function EquipCompareTips:UpdateBgRes( ) local bg_res = "equip_tool_tip_bg" local attr_scroll_height = 482 local attr_scroll_pos = {12,-110} local find_btn_x = 119 local occupation_str = self.model:GetCareerDesc(self.equip_cfg.career) or "全职业可用"--暂时还没定 local goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.equip_data.type_id)--这里要等属性计算完了才能知道具体的品质 if not goods_vo then return end if self.equip_cfg.equip_type < EquipModel.EquipType.Guard and self.equip_cfg.equip_type >= EquipModel.EquipType.Necklace then--首饰 bg_res = "equip_tool_tip_bg2" attr_scroll_height = 300 self.occupation_tmp.text = occupation_str lua_resM:setImageSprite(self, self.title_bg_img, "commonTipBg_asset", "ui_com_quality_bg_"..goods_vo.color + self.empower_lv,true) self:UpdateOrnamentInfo() self.ornamentsCon_obj:SetActive(true) elseif self.equip_cfg.equip_type == EquipModel.EquipType.Guard then--守护 bg_res = "equip_tool_tip_bg2" attr_scroll_height = 130 find_btn_x = 109 attr_scroll_pos = {12,-282} self.guard_occupation_tmp.text = occupation_str lua_resM:setImageSprite(self, self.guard_title_bg_img, "commonTipBg_asset", "ui_com_g_quality_bg_"..goods_vo.color + self.empower_lv,true) self.icon_con.gameObject:SetActive(false) self.ornamentsCon_obj:SetActive(true) --更新守护模型 self:UpdateEvilModel() self:UpdateOrnamentInfo() else self.ornamentsCon_obj:SetActive(false) self.occupation_tmp.text = occupation_str lua_resM:setImageSprite(self, self.title_bg_img, "commonTipBg_asset", "ui_com_quality_bg_"..goods_vo.color + self.empower_lv,false) end lua_resM:setImageSprite(self, self.di_bg_img, "commonTipBg_asset", "ui_com_quality_samll_bg_"..goods_vo.color + self.empower_lv,true) SetAnchoredPositionX(self.find_btn,find_btn_x) SetAnchoredPosition(self.attr_scroll,attr_scroll_pos[1],attr_scroll_pos[2]) SetSizeDeltaY(self.attr_scroll,attr_scroll_height) lua_resM:setOutsideImageSprite(self,self.bgImg_img,GameResPath.GetViewBigBg(bg_res),false) end function EquipCompareTips:UpdateOrnamentInfo( ) local lv = 1--这两个从服务端那边拿 local cur_exp = 0--这两个从服务端那边拿 if self.lv_exp_info and self.lv_exp_info[1] then lv = self.lv_exp_info[1] cur_exp = self.lv_exp_info[2] end local sp_cfg = Config.Equipmentspinfo[self.equip_cfg.series.."@"..self.equip_cfg.equip_type] if sp_cfg then self.equip_skill_name_tmp.text = string.format("%s Lv.%s",HtmlColorTxt(Trim(sp_cfg.name), "#66abff"),lv) if string.find(Trim(sp_cfg.desc), "\\") then self.descImg2.gameObject:SetActive(true) SetAnchoredPositionY(self.descImg1,-17) SetAnchoredPositionY(self.descText,-52) else SetAnchoredPositionY(self.descImg1,-28) SetAnchoredPositionY(self.descText,-63) self.descImg2.gameObject:SetActive(false) end self.descText_tmp.text = ChuanWenManager:getInstance():FormatColorTag2(string.gsub(Trim(sp_cfg.desc), "\\n", "\n"), true) local attr_cfg = Config.Equipmentspattr[self.equip_cfg.series.."@"..self.equip_cfg.equip_type.."@"..lv] if attr_cfg then self.equip_skill_pro_tmp.text = string.format("%s/%s",cur_exp,attr_cfg.next_exp) self.proImg_img.fillAmount = cur_exp/attr_cfg.next_exp local attr_info = DeepCopy(stringtotable(attr_cfg.attr))--{{1,40}} if attr_info then local attr_name = WordManager:GetProperties(attr_info[1][1]) local attr_value = WordManager:GetPropertyValue(attr_info[1][1],attr_info[1][2]) local cur_attr_str = string.format("%s %s",attr_name,attr_value) local next_attr_cfg = Config.Equipmentspattr[self.equip_cfg.series.."@"..self.equip_cfg.equip_type.."@"..(lv+1)] local next_attr_str = "(当前已满级)" if next_attr_cfg then local next_attr_info = DeepCopy(stringtotable(next_attr_cfg.attr))--{{1,40}} local next_attr_name = WordManager:GetProperties(next_attr_info[1][1]) local next_attr_value = WordManager:GetPropertyValue(next_attr_info[1][1],next_attr_info[1][2]) next_attr_str = string.format(" 下级效果 %s %s",next_attr_name,next_attr_value) end self.attrValue_tmp.text = cur_attr_str..HtmlColorTxt(next_attr_str, ColorUtil.GREEN_DARK) end end end end --更新守护模型 function EquipCompareTips:UpdateEvilModel( ) local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.equip_data.type_id) if not basic then return end local evil_id = basic.model_id local pos_cfg = EquipConst.EvilModelResPos[evil_id] local scale = 185 local pos = Vector3(0,0,0) if pos_cfg then -- scale = pos_cfg.scale pos = pos_cfg.pos end local data = { clothe_res_id = evil_id, type = SceneBaseType.Evil, on_name_list = {"show"}, scale = scale, position = pos, layer_name = self.layer_name, } lua_resM:SetRoleModel(self,self.roleCon,data) end