DeityEquipTips = DeityEquipTips or BaseClass(WingInfoTips) local DeityEquipTips = DeityEquipTips local Trim = Trim local SetAnchoredPosition = SetAnchoredPosition function DeityEquipTips:Open(type_id, x, y, goodsID,goods_vo) if not Config.Deityprinciple[type_id] then LogError("DeityEquipTips:Open() 不存在的法则类型, type_id = "..type_id) self:Close() return end self.type_id = type_id self.goods_id = goodsID self.pos_x = x self.pos_y = y self.goods_vo = goods_vo BaseView.Open(self) end function DeityEquipTips:LoadSuccess() EquipToolTips.LoadSuccess(self) self.normal_tra = self:GetChild("layout/normal") self.normal_tra.anchoredPosition = Vector2(0,0) self:GetChild("layout/normal/career_conta/careerName"):GetComponent("Text").text = "部位:" self:GetChild("layout/normal/ScrollView/Viewport/Content/line2/Text"):GetComponent("Text").text = "法则神力" self.skill_desc = self:GetChild("layout/normal/ScrollView/Viewport/Content/addStrengthProp"):GetComponent("Text") self.ScrollView:GetComponent("ScrollRect").enabled = false SetSizeDelta(self.transform,ScreenWidth,ScreenHeight) self.layout.gameObject:SetActive(false) end function DeityEquipTips:InitEvent() local function onBtnClickHandler(target) if target == self.composeBtn then GlobalEventSystem:Fire(EventName.OPEN_COMPOSE_VIEW) self:Close() elseif target == self.wearBtn then DeityModel:getInstance():OutsideRequireEquip(self.goods_id) self:Close() elseif target == self.takeBtn then if self.goods_vo.pos == GoodsModel.GOODS_POS_TYPE.hunt_store then TreasureHuntModel:getInstance():Fire(TreasureHuntModel.REQUEST_PROTO, 41605, self.goods_vo.goods_id) self:Close() else GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15003,self.goods_vo.goods_id,GoodsModel.GOODS_POS_TYPE.warehouse,GoodsModel.GOODS_POS_TYPE.bag) self:Close() end end end AddClickEvent(self.composeBtn, onBtnClickHandler, 2) AddClickEvent(self.wearBtn, onBtnClickHandler, 2) AddClickEvent(self.takeBtn, onBtnClickHandler, 2) end function DeityEquipTips:SetData() local vo = Config.Deityprinciple[self.type_id] local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id) if vo == nil or basic == nil then LogError("DeityEquipTips:SetData() 数据错误, vo = "..tostring(wing_vo)..", basic = "..tostring(basic)..", type_id = "..self.type_id) return end -- 名字 self.nameText.text = ""..basic.goods_name.."" --部位 local part = tonumber(vo.place) local part_config = Config.Deityplace[part] local part_name = part_config and Trim(part_config.name) or "" self.career.text = part_name -- 等阶 local step_str = vo.rank.."阶" self.step_num.text = "" .. step_str .. "" -- 等级 color_str = ColorUtil.WHITE if basic.level > RoleManager.Instance.mainRoleInfo.level then color_str = ColorUtil.RED end self.level.text = "" .. basic.level .. "" --评分 self.equip_score.text = vo.combat lua_resM:setImageSprite(self, self.step_bg, "uiComponent_asset", "tsui_pj_"..basic.color) self.icon_item:SetData(basic) local base_pro = ErlangParser:GetInstance():Parse(vo.attr) self:SetPropertyAndSkill(base_pro,vo.skill_id) self.composite_score.text = GetFighting(base_pro) self:SetBtns() self:AdjustLayoutPos() end --按钮显示 function DeityEquipTips:SetBtns() for i,v in ipairs(self.btn_list) do v:SetActive(false) end local btn_list = {} if self.goods_vo and self.goods_vo.pos == GoodsModel.GOODS_POS_TYPE.hunt_store then btn_list = {self.takeBtn} else table.insert(btn_list, self.wearBtn) table.insert(btn_list, self.composeBtn) 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 + 20) end --设置基础属性 function DeityEquipTips:SetPropertyAndSkill(base_pro,skill_id) self.addPro.gameObject:SetActive(false) self.line3.gameObject:SetActive(false) self.line4.gameObject:SetActive(false) self.line5.gameObject:SetActive(false) self.line6.gameObject:SetActive(false) self.line7.gameObject:SetActive(false) self.line8.gameObject:SetActive(false) self.line9.gameObject:SetActive(false) self.line10.gameObject:SetActive(false) self.strengthAdd.gameObject:SetActive(false) self.washName.gameObject:SetActive(false) self.washPro.gameObject:SetActive(false) self.spiritName.gameObject:SetActive(false) self.spiritPro.gameObject:SetActive(false) self.stone_conta.gameObject:SetActive(false) self.suitNum.gameObject:SetActive(false) self.suitName.gameObject:SetActive(false) self.suitPro.gameObject:SetActive(false) self.suitNameList.gameObject:SetActive(false) self.wake_baseName.gameObject:SetActive(false) self.wake_basePro.gameObject:SetActive(false) self.wake_baseAdd.gameObject:SetActive(false) self.wake_strenName.gameObject:SetActive(false) self.wake_strenPro.gameObject:SetActive(false) self.wake_strenAdd.gameObject:SetActive(false) self.wake_suitNum.gameObject:SetActive(false) self.wake_suitName.gameObject:SetActive(false) self.wake_suitPro.gameObject:SetActive(false) self.wake_suitAdd.gameObject:SetActive(false) self.magic_skillName.gameObject:SetActive(false) self.magic_skillLevel.gameObject:SetActive(false) self.expired_label.gameObject:SetActive(false) self.descCon.gameObject:SetActive(false) self.addName.gameObject:SetActive(false) local name_str = "" local pro_str = "" local color local size = #base_pro for i,v in ipairs(base_pro) do color = ColorUtil:GetColor(tonumber(v[3])) name_str = name_str..""..WordManager:GetProperties(tonumber(v[1])).."" pro_str = pro_str.."".."+"..WordManager:GetPropertyValue(tonumber(v[1]),tonumber(v[2])).."" if i < size then name_str = name_str.."\n" pro_str = pro_str.."\n" end end self.baseName.text = name_str self.basePro.text = pro_str SetSizeDelta(self.baseName.transform, self.baseName.transform.sizeDelta.x, 25 * size) SetSizeDelta(self.basePro.transform, self.basePro.transform.sizeDelta.x, 25 * size) local equip_cfg = Config.Deityprinciple[self.type_id] local skill_desc,skill_name = SkillManager:getInstance():GetSkillFromConfigByIdAndLevel(skill_id, equip_cfg.rank) self.skill_desc.text = ""..Trim(skill_desc).."" local skill_desc_h = 75 SetAnchoredPosition(self.skill_desc.transform, 25, -25 * size - 100) SetSizeDelta(self.skill_desc.transform, 344, skill_desc_h) SetAnchoredPosition(self.line2, 0, -25 * size - 52) SetSizeDelta(self.bg, self.bg.sizeDelta.x, 315 + 25 * size + skill_desc_h) self.btn_conta.anchoredPosition = Vector2(self.btn_conta.anchoredPosition.x, -205 - 25 * size) setTimeout(function () if not self._use_delete_method then local skill_desc_h = self.skill_desc.preferredHeight SetSizeDelta(self.skill_desc.transform, 344, skill_desc_h) SetSizeDelta(self.bg, self.bg.sizeDelta.x, 315 + 25 * size + skill_desc_h) self.btn_conta.anchoredPosition = Vector2(self.btn_conta.anchoredPosition.x, -205 - 25 * size - skill_desc_h) end end,0) end function DeityEquipTips:AdjustLayoutPos() if self.pos_x and self.pos_y then local layout_width = self.bg.sizeDelta.x + self.btn_conta.sizeDelta.x local layout_height = self.bg.sizeDelta.y local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y) local iphone_x_offset = math.max(ClientConfig.iphone_x_offset_left,ClientConfig.iphone_x_offset_right) if x + layout_width + 50 + iphone_x_offset * 2 > SrcScreenWidth then x = SrcScreenWidth - layout_width - 90 - iphone_x_offset * 2 end if y < layout_height + 50 then y = layout_height + 50 end SetAnchoredPosition(self.layout, x,y - ScreenHeight) self.layout.gameObject:SetActive(true) end end