local UIOptBaseTip = require "View/Common/UIOptBaseTip" local UIHorseEquipTip = UIViewClass(UIOptBaseTip) local TipsType = { BaseType = 1, -- 基础属性 DescType = 2, -- 战装描述 Path = 3, --获取途径 } function UIHorseEquipTip:Init(context) if context.horseId <= 0 then -- 无坐骑时 context.equipId 是CfgId(与ItemId相同) self.itemId = context.equipId self.equipData = DataSheetManager.HorseEquipData:GetDataByID(self.itemId) self.targetObjId = 0 else -- 有坐骑时 context.equipId 是实例id self.equipUId = context.equipId self.equipInfo = MDL.HorseEquip.GetEquipInfoById(self.equipUId) self.equipData = self.equipInfo.equipData self.itemId = self.equipInfo.cfgId self.targetObjId = context.horseId end end function UIHorseEquipTip:SetCfgTip() self:RefreshNormalInfo() self.state_CE:SetState(2) UIUtils.SetActive(self.group_Btns, false) UIUtils.SetActive(self.bg_Head, false) end function UIHorseEquipTip:SetTargetObjInfo() self:RefreshNormalInfo() local choosedEquipGs = self.equipInfo.gs --选择的装备战力 local pos = self.equipData.EquipType local slotInfo = MDL.HorseEquip.GetEquipSlotInfoByHorseId(self.targetObjId, pos) self.isSlotEquip = slotInfo and CTL.HorseEquip.JudgeEquipId(slotInfo.Id) if self.isSlotEquip then local slotEquipGs = CTL.HorseEquip.GetEquipGs(slotInfo.CfgId) if slotEquipGs == choosedEquipGs then self.state_CE:SetState(2) else self.state_CE:SetState(slotEquipGs < choosedEquipGs and 0 or 1) end else self.state_CE:SetState(2) end if self.equipInfo.equipHorseId then UIUtils.SetActive(self.bg_Head, true) local horseData = DataSheetManager.HorseData:GetDataByHorseID(self.equipInfo.equipHorseId) UIUtils.SetImageByAssetBundle(self.img_HorseHead, horseData.HorseIcon) else UIUtils.SetActive(self.bg_Head, false) end end function UIHorseEquipTip:RefreshNormalInfo() UIOptBaseTip.RefreshNormalInfo(self) self.txt_Armor_lv.text = self.equipData.OfferLevel self.txt_stage.text = string.FormatByIdsId(Const_IDS.IDS_EquipData_StageShow, self.equipData.EquipStage) self.txt_CE.text = CTL.HorseEquip.GetEquipGs(self.itemId) UIUtils.SetLabel(self.txt_ItemType, UIUtils.GetLocalizedTxt(Const_IDS.IDS_EquipRefine_EquipLevel)..CTL.HorseEquip.GetEquipLevel(self.equipData.EquipLevel)) UIUtils.SetActive(self.img_Armor, true) UIUtils.SetActive(self.txt_stage.gameObject, true) self.loop_EquipInfo:AddData(TipsType.BaseType, 0) self.loop_EquipInfo:AddData(TipsType.DescType, 1) if not self.context.isChildTips and CTL.ItemSources.IsShowItemSource(self.itemId) then self.loop_EquipInfo:AddData(TipsType.Path, 2) end end function UIHorseEquipTip:RefreshBtns() if not self.isRightTip or self.targetObjId == 0 then UIUtils.SetActive(self.group_Btns, false) else UIUtils.SetActive(self.group_Btns, true) local horseID = MDL.HorseEquip.JudgeIfEquip(self.equipUId) if horseID then UIUtils.SetActive(self.btn_Equip, false) if horseID == self.targetObjId then UIUtils.SetActive(self.btn_UnEquip, true) UIUtils.SetActive(self.btn_Exchange, false) else UIUtils.SetActive(self.btn_UnEquip, false) UIUtils.SetActive(self.btn_Exchange, true) end else UIUtils.SetActive(self.btn_UnEquip, false) UIUtils.SetActive(self.btn_Equip, not self.isSlotEquip) UIUtils.SetActive(self.btn_Exchange, self.isSlotEquip) end end UIUtils.SetActive(self.btn_LevelUp, false) end function UIHorseEquipTip:OnButtonClicked(comp) if comp == self.btn_Equip or comp == self.btn_Exchange then if MDL.HeroSelect.GetTeamLevel() >= self.equipData.EquipLevel then MDL.HorseEquip.OptHorseEquipReq(self.targetObjId, self.equipUId, MDL.HorseEquip.WearHorseEquipType.PutOn) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_EquipRefine_WrongHint2"]) end self:CloseAll() elseif comp == self.btn_UnEquip then MDL.HorseEquip.OptHorseEquipReq(self.targetObjId, self.equipUId, MDL.HorseEquip.WearHorseEquipType.TakeOff) self:CloseAll() else UIOptBaseTip.OnButtonClicked(self, comp) end end function UIHorseEquipTip:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_EquipInfo then if data == TipsType.BaseType then UIUtils.SetActive(cellTable.group_Star.gameObject, false) UIUtils.SetActive(cellTable.txt_NoStar.gameObject, false) UIUtils.SetLabelText(cellTable.txt_EquipTitle, Const_IDS.IDS_BaseAttr) local attrTable = CTL.HorseEquip.GetEquipAttrTable(self.itemId) for i, v in ipairs(attrTable) do if not cellTable.Content_EquipAttr[i] then self:InstantiateCollection(cellTable.Content_EquipAttr, cellTable.cell_EquipAttr.gameObject) UIUtils.SetActive(cellTable.Content_EquipAttr[i].gameObject, true) end UTL.Attr.SetAttrItemByCompName(cellTable.Content_EquipAttr[i], v.AttrType, v.AttrNum, true) end elseif data == TipsType.DescType then UIUtils.SetActive(cellTable.txt_SkillName, false) UIUtils.SetLabelText(cellTable.txt_EquipDescTitle, Const_IDS.IDS_HorseEquip_Hint_3) cellTable.txt_ItemInfoDes.text = UTL.Item.GetItemDataSpliceByType(self.itemId).Des UIUtils.SetActive(cellTable.txt_Lock, false) elseif data == TipsType.Path then local sourcesList = MDL.ItemSources.GetItemSourcesById(self.itemId) for i, sourceData in ipairs(sourcesList) do local item = cellTable.Content[i] if not item then item = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, cellTable.Content[1].gameObject) end UIUtils.SetActive(item.gameObject, true) item.txt_ItemSources.text = sourceData.desc item.state_ItemSources:SetState(sourceData.isUnlock) end end else UIOptBaseTip.OnCellInit(self, scrollRect, index, cellTable, data) end end function UIOptBaseTip:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_EquipInfo then for i, itemCell in ipairs(cellTable.Content) do if target == itemCell.btn_ItemSources then local sourcesList = MDL.ItemSources.GetItemSourcesById(self.itemId) local sourceData = sourcesList[i] if sourceData.isUnlock > 0 then if CTL.ItemSources.ExecuteSourceFunctionById(sourceData.sourceId, self.itemId) then self:CloseAll() end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Formation_RelationShip_Closed) end end end end end return UIHorseEquipTip