-- 玩家自身阵容详情界面 -- UIFreeLineupCustomDetailPanel 继承此界面 -- UIFreeLineupCustomDetailPanel_3v3 继承此界面 local UIFreeLineupDetailPanel = UIViewClass() local TabIconPathFormat = ConstAssetPathConfig.TabIconPathFormat local PetRuneDragTypeParam = "PetRune" local DragEffectPath = { bigDragging = ConstAssetPathConfig.bigDragging, bigReplace = ConstAssetPathConfig.bigReplace, smallDragging = ConstAssetPathConfig.smallDragging, smallReplace = ConstAssetPathConfig.smallReplace, } --region Basic function UIFreeLineupDetailPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshSlotDetailUI, self.RefreshView) --对应MDL.FreeLineUp.FuncType self.curFuncType = context.id self.heroList = context.heroList self.parentView = context.parentView -- 此时拖拽的对象, self.onEnterSlot, self.onEnterSubSlot = nil, nil -- 进入物体EffectID self.draggingItemEffectComp, self.enterItemEffectComp = nil, nil self.lineNumbers = {1, 2, 3} self:UpdateViewBySubView() self:InitDatasAndEvents() self:InitHeroPictures() self:RefreshTabTitle() self:SendFreeLineUpGetSlotInfoRequest() --设置拖拽父物体的sortingorder local canvas = self.gameObject:GetComponent(typeof(UnityEngine.Canvas)) UIUtils.SetCanvasSortingOrderByMainCanvas(canvas, self.dragParent, 250) end function UIFreeLineupDetailPanel:SendFreeLineUpGetSlotInfoRequest() local lineNumber = MDL.FreeLineUp.GetFreeLineUpLineNumber(self.curFuncType) MDL.FreeLineUp.FreeLineUpGetSlotInfoRequest(self.curFuncType, lineNumber) end --定制子界面 function UIFreeLineupDetailPanel:InitCustomChildPanel(showSaveBtn, showGSGroup) self.customCanvas:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIFreeLineupDetailChildPanel), { parentView = self, curFuncType = self.curFuncType, showSaveBtn = showSaveBtn, showGSGroup = showGSGroup }) end -- BASE function UIFreeLineupDetailPanel:UpdateViewBySubView() self:InitCustomChildPanel(false, true) end function UIFreeLineupDetailPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIFreeLineupDetailPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then if self.context.homeFunc then self.context.homeFunc() else CTL.HomeMain.CloseViewBackHomeMain() end elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.FreeLineUp}) end end function UIFreeLineupDetailPanel:OnClosed() self:OnClosedFunc() end function UIFreeLineupDetailPanel:OnClosedFunc() if self.hasChanged then MDL.FreeLineUp.FreeLineUpSlotSetRequest(self.curFuncType, self.serverData) end self.serverData = nil end function UIFreeLineupDetailPanel:InitDatasAndEvents() --六个大槽位的拖拽检测组 self.dropGroup = {} --四个装备的拖拽检测组 self.dropEquipGroup = { [1] = {}, [2] = {}, [3] = {}, [4] = {}, } --三个宠物符文的拖拽检测组 self.dropPetRuneGroup = { [1] = 1, [2] = 1, [3] = 1, } --注册拖拽事件 for slotIndex = 1, #self.formationGroupCollections do local groupFormation = self.formationGroupCollections[slotIndex] --整个槽位有两处位置可以拖拽 self:RegistAllEvent(groupFormation.img_drag) table.insert(self.dropGroup, groupFormation.img_drag.gameObject) --装备的四个也可以拖拽 groupFormation.equipList = { [1] = groupFormation.group_EquipItem1, [2] = groupFormation.group_EquipItem2, [3] = groupFormation.group_EquipItem3, [4] = groupFormation.group_EquipItem4, } for i = 1, #groupFormation.equipList do self:RegistAllEvent(groupFormation.equipList[i].btn_Click) table.insert(self.dropEquipGroup[i], groupFormation.equipList[i].btn_Click.gameObject) end end for i = 1, #self.dropPetRuneGroup do local obj = self.formationGroupPetRune[i].img_dragPetRune self:RegistAllEvent(obj) self.dropPetRuneGroup[i] = obj.gameObject end --注册释放事件 for slotIndex = 1, #self.formationGroupCollections do local groupFormation = self.formationGroupCollections[slotIndex] self:RegistDropEvent(groupFormation.img_drag, self.dropGroup) for i = 1, #groupFormation.equipList do self:RegistDropEvent(groupFormation.equipList[i].btn_Click, self.dropEquipGroup[i]) end end for i = 1, #self.dropPetRuneGroup do local obj = self.formationGroupPetRune[i].img_dragPetRune self:RegistDropEvent(obj, self.dropPetRuneGroup) end end function UIFreeLineupDetailPanel:RegistAllEvent(comp) self:RegistTriggerEvent(comp, UIEventTriggerType.BeginDrag) self:RegistTriggerEvent(comp, UIEventTriggerType.Drag) self:RegistTriggerEvent(comp, UIEventTriggerType.EndDrag) end function UIFreeLineupDetailPanel:RefreshView(serverData, slotCustomDetail, petSlotNum, petInfo, petSlotBreak, lineNumbers) if serverData then self.serverData = serverData end if slotCustomDetail then self.slotCustomDetail = slotCustomDetail end if petSlotNum then self.petSlotNum = petSlotNum end if petInfo then self.petInfo = petInfo end if petSlotBreak then self.petSlotBreak = petSlotBreak end if self.slotCustomDetail == nil then -- 需要等待服务器发来数据源 return end if lineNumbers then self.lineNumbers = lineNumbers end self:RefreshFormateTitle() UIUtils.SetActive(self.formationGroupPetRune.gameObject, self.currentTabData.titleIds == MDL.FreeLineUp.TabTypeIDS[5]) for slotIndex = 1, #self.formationGroupCollections do local formationGroupCollection = self.formationGroupCollections[slotIndex] UIUtils.SetActive(formationGroupCollection.group_Equipment, false) UIUtils.SetActive(formationGroupCollection.group_Info, false) UIUtils.SetActive(formationGroupCollection.group_TreasureHorse, false) UIUtils.SetActive(formationGroupCollection.group_PetHead.gameObject, false) UIUtils.SetActive(formationGroupCollection.group_PetRune, false) UIUtils.SetActive(formationGroupCollection.group_Empty, false) UIUtils.SetActive(formationGroupCollection.img_TreasureIcon, true) local titleIds = self.currentTabData.titleIds if titleIds == MDL.FreeLineUp.TabTypeIDS[1] then UIUtils.SetActive(formationGroupCollection.group_Info, true) self:InitHeroInfo(formationGroupCollection, slotIndex) elseif titleIds == MDL.FreeLineUp.TabTypeIDS[2] then UIUtils.SetActive(formationGroupCollection.group_Equipment, true) self:InitEquipment(formationGroupCollection, slotIndex) elseif titleIds == MDL.FreeLineUp.TabTypeIDS[3] then UIUtils.SetActive(formationGroupCollection.group_TreasureHorse, true) self:InitHorse(formationGroupCollection, slotIndex) elseif titleIds == MDL.FreeLineUp.TabTypeIDS[4] then UIUtils.SetActive(formationGroupCollection.group_TreasureHorse, true) self:InitTreasure(formationGroupCollection, slotIndex) elseif titleIds == MDL.FreeLineUp.TabTypeIDS[5] then self:InitPet(formationGroupCollection, slotIndex) end end end function UIFreeLineupDetailPanel:GetMappingData(tabType, slotIndex, slotSubIndex) if self.serverData and self.serverData[slotIndex] then if tabType == 1 then return self.serverData[slotIndex].heroLevelPos elseif tabType == 2 then return self.serverData[slotIndex].equipPoses[slotSubIndex] elseif tabType == 3 then return self.serverData[slotIndex].horsePos elseif tabType == 4 then return self.serverData[slotIndex].treasurePos elseif tabType == 5 then return self.serverData[slotIndex].petSlotPos, self.serverData[slotIndex].petPos end end return slotIndex end function UIFreeLineupDetailPanel:ExchangeMappingData(tabType, originSlot, originSubSlot, targetSlot, targetSubSlot, param) if self.serverData and self.serverData[originSlot] then self.hasChanged = true if tabType == 2 then if originSubSlot == 0 then for i = 1, #self.serverData[originSlot].equipPoses do local originData = self.serverData[originSlot].equipPoses[i] self.serverData[originSlot].equipPoses[i] = self.serverData[targetSlot].equipPoses[i] self.serverData[targetSlot].equipPoses[i] = originData end else local originData = self.serverData[originSlot].equipPoses[originSubSlot] self.serverData[originSlot].equipPoses[originSubSlot] = self.serverData[targetSlot].equipPoses[targetSubSlot] self.serverData[targetSlot].equipPoses[targetSubSlot] = originData end elseif tabType == 1 then local originData = self.serverData[originSlot].heroLevelPos self.serverData[originSlot].heroLevelPos = self.serverData[targetSlot].heroLevelPos self.serverData[targetSlot].heroLevelPos = originData elseif tabType == 3 then local originData = self.serverData[originSlot].horsePos self.serverData[originSlot].horsePos = self.serverData[targetSlot].horsePos self.serverData[targetSlot].horsePos = originData elseif tabType == 4 then local originData = self.serverData[originSlot].treasurePos self.serverData[originSlot].treasurePos = self.serverData[targetSlot].treasurePos self.serverData[targetSlot].treasurePos = originData elseif tabType == 5 then if param == PetRuneDragTypeParam then local oriSlotIndex = (originSlot + 1) / 2 local tarSlotIndex = (targetSlot + 1) / 2 local oriRuneData, oriRuneIndex, tarRuneData, tarRuneIndex for i, v in ipairs(self.petSlotBreak) do if v.slotId == oriSlotIndex then oriRuneData = v oriRuneIndex = i elseif v.slotId == tarSlotIndex then tarRuneData = v tarRuneIndex = i end end self.petSlotBreak[oriRuneIndex] = tarRuneData self.petSlotBreak[tarRuneIndex] = oriRuneData local originData = self.serverData[originSlot].petSlotPos self.serverData[originSlot].petSlotPos = self.serverData[targetSlot].petSlotPos self.serverData[originSlot + 1].petSlotPos = self.serverData[originSlot].petSlotPos self.serverData[targetSlot].petSlotPos = originData self.serverData[targetSlot + 1].petSlotPos = originData self.formationGroupPetRune[(targetSlot + 1) / 2].effect_RuneSuccess:PlayUIEffect() else local originData = self.serverData[originSlot].petPos self.serverData[originSlot].petPos = self.serverData[targetSlot].petPos self.serverData[targetSlot].petPos = originData end end end end --endregion Basic --region Drag --获取拖拽节点所属的位置索引,第一个返回值是槽位,第二个返回值为装备的索引 function UIFreeLineupDetailPanel:GetDragGameObjectIndex(obj) for slotIndex = 1, #self.dropGroup do if obj == self.dropGroup[slotIndex] then return slotIndex, 0 end end for i = 1, #self.dropEquipGroup do local tb = self.dropEquipGroup[i] for j = 1, #tb do if obj == tb[j] then return j, i end end end for i = 1, #self.dropPetRuneGroup do if obj == self.dropPetRuneGroup[i] then return i * 2 - 1, nil, PetRuneDragTypeParam end end end function UIFreeLineupDetailPanel:OnBeginDrag(comp, eventData) -- 第一步,把拖拽父物体设置到点下的屏幕位置 UIUtils.ScreenPointToWorldPointInRectangle(self.dragParent.gameObject, eventData) -- 第二步,记录拖拽前的位置 self.draggingTrans = comp.transform.parent self.draggingObj = comp.gameObject self.originParent = self.draggingTrans.parent self.originX, self.OriginY = comp.transform.parent:GetLocalPosition() -- 第三步,把响应拖拽的物体,移动节点到拖拽父物体下 self.draggingTrans:SetParent(self.dragParent.transform, true) -- 第四步,播放拖拽中物体的特效 local effectPath, param = self:GetEffectPath(comp.gameObject, true) if param == PetRuneDragTypeParam then --所有符文播放特效 for i, v in ipairs(self.formationGroupPetRune) do v.effect_DargRune:PlayUIEffect() end else local targetComp = self:GetCompBySlot_SubSlot(comp.gameObject) if targetComp then self.draggingItemEffectComp = targetComp.tag_Effect self.draggingItemEffectComp:PlayUIEffect(effectPath, -1) end end end function UIFreeLineupDetailPanel:OnDrag(comp, eventData) UIUtils.ScreenPointToWorldPointInRectangle(self.dragParent.gameObject, eventData) --拖拽符文无特效 for i = 1, #self.dropPetRuneGroup do if self.draggingObj == self.dropPetRuneGroup[i] then return end end -- 播放进入item的特效 local effectPath = self:GetEffectPath(eventData.pointerEnter.gameObject, false) local tempComp = self:GetCompBySlot_SubSlot(eventData.pointerEnter.gameObject) if tempComp and self.enterItemEffectComp ~= tempComp then if self.enterItemEffectComp then self.enterItemEffectComp:StopUIEffect() end if tempComp then self.enterItemEffectComp = tempComp.tag_Effect self.enterItemEffectComp:PlayUIEffect(effectPath, -1) end if self.draggingItemEffectComp then self.draggingItemEffectComp:PlayUIEffect(self:GetEffectPath(comp.gameObject, true), -1) end end end function UIFreeLineupDetailPanel:OnDrop(comp, eventData) --第一步,还原拖拽物体的位置 self.draggingTrans:SetParent(self.originParent, true) self.draggingTrans:SetLocalPosition(self.originX, self.OriginY, 0) -- 停止特效的播放 self:StopEffectByDrag() -- 第二步,计算交换后的数据 if comp and comp.transform ~= eventData.pointerDrag.transform then local targetSlot, targetSubSlot, param = self:GetDragGameObjectIndex(comp.transform.gameObject) local originSlot, originSubSlot = self:GetDragGameObjectIndex(eventData.pointerDrag.transform.gameObject) self:ExchangeMappingData(self.currentTabData.index, originSlot, originSubSlot, targetSlot, targetSubSlot, param) if self.hasChanged then self:SaveLineupDetail() end end --第三步,刷新当前页签 self:RefreshView() end function UIFreeLineupDetailPanel:SaveLineupDetail() MDL.FreeLineUp.FreeLineUpSlotSetRequest(self.curFuncType, self.serverData) end function UIFreeLineupDetailPanel:OnEndDrag(comp, eventData) --不作处理 end function UIFreeLineupDetailPanel:StopEffectByDrag() if self.draggingItemEffectComp then self.draggingItemEffectComp:StopUIEffect() self.draggingItemEffectComp = nil end if self.enterItemEffectComp then self.enterItemEffectComp:StopUIEffect() self.enterItemEffectComp = nil end for i, v in ipairs(self.formationGroupPetRune) do v.effect_DargRune:StopUIEffect() v.effect_RuneSuccess:StopUIEffect() end end function UIFreeLineupDetailPanel:GetEffectPath(obj, isDragging) local slot, subSlot, param = self:GetDragGameObjectIndex(obj.transform.gameObject) if param == PetRuneDragTypeParam then return nil, param end if not slot or not subSlot then return nil else if subSlot > 0 then return isDragging and DragEffectPath.smallDragging or DragEffectPath.smallReplace else return isDragging and DragEffectPath.bigDragging or DragEffectPath.bigReplace end end end function UIFreeLineupDetailPanel:GetCompBySlot_SubSlot(obj) local index, subIndex, param = self:GetDragGameObjectIndex(obj.transform.gameObject) if not index then return nil end if param == PetRuneDragTypeParam then return nil end local group = self.formationGroupCollections[index] if subIndex and subIndex > 0 then return group["group_EquipItem"..subIndex] else return group end end --endregion Drag --region HeroPictures function UIFreeLineupDetailPanel:InitHeroPictures() for k, v in ipairs(self.heroGroupCollections) do local heroId = self.heroList[k] if heroId > 0 then UIUtils.SetActive(v.group_Empty, false) local lineNumber = self.context.lineNumber and self.context.lineNumber or self.context.curKingdom local isAwaken = MDL.FreeLineUp.GetLineupHeroAwaken(self.curFuncType, k, nil, lineNumber) UTL.Item.SetHeroIconByHeroId(v.img_Hero, heroId, isAwaken) UTL.Color.SetQualityImageByType(v.img_QuaDec, CTL.HeroAwaken.GetHeroQuality(heroId, isAwaken), UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(v.img_Qua, CTL.HeroAwaken.GetHeroQuality(heroId, isAwaken), UTL.Color.QualityType.HeroSelectBg) local heroBreak = MDL.FreeLineUp.GetLineupHeroStar(self.curFuncType, k, nil, lineNumber) if heroBreak == 0 then UIUtils.SetActive(v.group_Break, false) else UIUtils.SetActive(v.group_Break, true) UIUtils.SetLabel(v.txt_Num, "+" .. heroBreak) end end end end --endregion HeroPictures --region Equipment -- BASE function UIFreeLineupDetailPanel:InitEquipment(formationGroupCollection, slotIndex) local groupFormation = formationGroupCollection local equipList = { [1] = groupFormation.group_EquipItem1, [2] = groupFormation.group_EquipItem2, [3] = groupFormation.group_EquipItem3, [4] = groupFormation.group_EquipItem4, } for slotSubIndex = 1, #equipList do local realSlotIndex = self:GetMappingData(2, slotIndex, slotSubIndex) local heroId = MDL.Formation.GetSlotHeroIdByIndex(realSlotIndex) local equipInfos = MDL.Equipment.GetEquipmentsByHeroId(heroId) if equipInfos then equipList[slotSubIndex].btn_Click:SetRedPoint(false) UIUtils.SetActive(equipList[slotSubIndex].img_Upgrade, false) local isUnlock, content = CTL.Equipment.CheckIfEquipTypeUnlock(slotSubIndex) if isUnlock == false then equipList[slotSubIndex].txt_Locked.text = content else local isEquipped = false for j = 1, #equipInfos do if equipInfos[j].EquipData.EquipType == slotSubIndex then isEquipped = true equipList[slotSubIndex].obj_state:SetState(0) local _, enhanceLevel = MDL.Equipment.GetEquipHeroInfo(equipInfos[j].ID) self:SetEquipItem(equipList[slotSubIndex], equipInfos[j].ItemData, enhanceLevel) -- 装备阶级信息 local equipData = DataSheetManager.EquipData:GetDataByID(equipInfos[j].EquipData.ID) UIUtils.SetLabel(equipList[slotSubIndex].txt_StageLv, string.FormatByIdsId(Const_IDS.IDS_EquipData_StageShow, UIUtils.GetLocalizedTxt(Const_IDS["IDS_Number_Written_"..equipData.EquipStage]))) break end end if isEquipped == false then equipList[slotSubIndex].obj_state:SetState(1) UTL.Item.SetAtlasSprite(equipList[slotSubIndex].img_quality, "UI_Formation", "zr_icon_pz02") end end else local isUnlock, content = CTL.Equipment.CheckIfEquipTypeUnlock(slotSubIndex) if isUnlock == false then equipList[slotSubIndex].txt_Locked.text = content else equipList[slotSubIndex].obj_state:SetState(1) equipList[slotSubIndex].btn_Click:SetRedPoint(false) UIUtils.SetActive(equipList[slotSubIndex].img_Upgrade, false) UTL.Item.SetAtlasSprite(equipList[slotSubIndex].img_quality, "UI_Formation", "zr_icon_pz02") end end self:SetEquipGemInfo(heroId, equipList, slotSubIndex) end end -- BASE function UIFreeLineupDetailPanel:SetEquipItem(equipComp, itemData, enhanceLevel) CTL.Equipment.SetEquipShow(equipComp.img_Equip, equipComp.img_quality, itemData) if enhanceLevel and enhanceLevel > 0 then UIUtils.SetActive(equipComp.EquipLv, true) equipComp.txt_Lv.text = UTL.Item.GetNobilityByTeamLevel(enhanceLevel) -- 爵位转换 else UIUtils.SetActive(equipComp.EquipLv, false) end end -- BASE function UIFreeLineupDetailPanel:SetEquipGemInfo(heroId, equipList, slotSubIndex) local gemIconRoot = equipList[slotSubIndex].group_Gem local gemIconBg = equipList[slotSubIndex].bg_Gem local gemIcons = equipList[slotSubIndex].cell_Gem local inlayGemInfos = MDL.GemCompose.GetHeroInlayGemInfo(heroId, slotSubIndex) if inlayGemInfos ~= nil and #inlayGemInfos > 0 then UIUtils.SetActive(gemIconRoot.gameObject, true) UIUtils.SetActive(gemIconBg, true) for i = 1, #inlayGemInfos do local gemIcon = gemIconRoot[i] if gemIcon == nil then gemIcon = self:InstantiateCollection(gemIconRoot, gemIcons.gameObject) end UIUtils.SetActive(gemIcon.gameObject, true) local icon = gemIcon.icon_Gem if inlayGemInfos[i] > 0 then local itemData = DataSheetManager.ItemData:GetDataByID(inlayGemInfos[i]) local jadeIcon = DataSheetManager.JadeLittleIcon:GetDataByLevel(itemData.ThirdType) UTL.Item.ItemIconByName(icon, jadeIcon.JadeIcon) UIUtils.SetActive(icon, true) else UIUtils.SetActive(icon, false) end end else if MDL.GemCompose.HasEquipByHeroId(heroId, slotSubIndex) == false then UIUtils.SetActive(gemIconRoot.gameObject, false) UIUtils.SetActive(gemIconBg, false) else UIUtils.SetActive(gemIconRoot.gameObject, true) UIUtils.SetActive(gemIconBg, true) for i = 1, 4 do local GemTypeCfgData = DataSheetManager.JadeType:GetDataByID_ChildID(slotSubIndex, i) local isUnlock = MDL.Unlock.IsComplete(GemTypeCfgData.UnlockCondition, GemTypeCfgData.UnlockConditionParam) if isUnlock then local gemIcon = gemIconRoot[i] if gemIcon == nil then gemIcon = self:InstantiateCollection(gemIconRoot, gemIcons.gameObject) end UIUtils.SetActive(gemIcon.gameObject, true) local icon = gemIcon.icon_Gem UIUtils.SetActive(icon, false) else local gemIcon = gemIconRoot[i] if gemIcon ~= nil then UIUtils.SetActive(gemIcon.gameObject, false) end end end end end end --endregion Equipment --region HeroInfo -- BASE function UIFreeLineupDetailPanel:InitHeroInfo(formationGroupCollection, slotIndex) local realSlotIndex = self:GetMappingData(1, slotIndex, 0) local heroId = MDL.Formation.GetSlotHeroIdByIndex(realSlotIndex) --进阶 local advancedData = DataSheetManager.HeroAdvance:GetDataByAdvanceID(MDL.Advanced.GetHeroAdvancedInfo(heroId)) local totalStar, lightStar = MDL.Advanced.GetStarInfoOfAdvanced(heroId) local groupStar = formationGroupCollection.group_Star CTL.Advanced.InstantiateStarCell(self, groupStar[1].gameObject, groupStar, totalStar, lightStar, advancedData.StarColorIcon, advancedData.StarLockIcon) --X阶X级 local title = string.FormatByIdsId(Const_IDS[advancedData.AdvanceDesc], advancedData.Stage, advancedData.LightStar) UIUtils.SetLabel(formationGroupCollection.txt_Advance, title) --等级显示 local currentLevel = MDL.HeroSelect.GetHeroLevel(heroId) local heroLevelUpData = DataSheetManager.HeroLevelUp:GetDataByHeroLevel(currentLevel) local levelStr = UTL.Item.GetNobilityByTeamLevel(heroLevelUpData.HeroLevel, 2) -- 爵位转换 local teamLevelName = string.FormatByIdsId(Const_IDS[heroLevelUpData.TeamLevelName], levelStr) UIUtils.SetLabel(formationGroupCollection.txt_Level, teamLevelName) end --endregion --region Horse -- BASE function UIFreeLineupDetailPanel:InitHorse(formationGroupCollection, slotIndex) local realSlotIndex = self:GetMappingData(3, slotIndex, 0) local heroId = MDL.Formation.GetSlotHeroIdByIndex(realSlotIndex) local horseInfo = MDL.WarHorse.GetInfoByHeroID(heroId) local config if horseInfo then config = horseInfo.ConfigInfo end if config then local framePath = DataSheetManager.QualityColor:GetDataByID(config.HorseQuality).LineupSelectionFrame UIUtils.SetImageByAssetBundle(formationGroupCollection.img_Bg, framePath) UIUtils.SetImageByAssetBundle(formationGroupCollection.img_TreasureIcon, config.HorsePicture) formationGroupCollection.img_TreasureIcon:SetNativeSize() formationGroupCollection.effect_TreasureQuality:StopUIEffect() local activeInfo = MDL.WarHorse.GetInfoByID(config.HorseID) if activeInfo then if activeInfo.HorseInfo.starLevel > 0 then formationGroupCollection.lab_StarLevel.text = "+" .. activeInfo.HorseInfo.starLevel UIUtils.SetActive(formationGroupCollection.bg_Level, true) else formationGroupCollection.lab_StarLevel.text = "" UIUtils.SetActive(formationGroupCollection.bg_Level, false) end formationGroupCollection.lab_TreasureName.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[config.HorseName]), config.HorseQuality) --品质特效 UTL.Color.PlayQualityEffect(formationGroupCollection.effect_TreasureQuality, config.HorseColorEffectID, UTL.Color.EffectType.Main) end else UIUtils.SetActive(formationGroupCollection.group_TreasureHorse, false) UIUtils.SetActive(formationGroupCollection.group_Empty, true) end end --endregion Horse --region Treasure -- BASE function UIFreeLineupDetailPanel:InitTreasure(formationGroupCollection, slotIndex) local realSlotIndex = self:GetMappingData(4, slotIndex, 0) local heroId = MDL.Formation.GetSlotHeroIdByIndex(realSlotIndex) local treasureInfo = MDL.Treasure.GetTreasureInfoByHeroId(heroId) local data if treasureInfo then data = treasureInfo.TreasureData end if data then UTL.Color.SetQualityImageByType(formationGroupCollection.img_QualityBg, data.TreasureQuality, UTL.Color.QualityType.TreasureBase) local framePath = DataSheetManager.QualityColor:GetDataByID(data.TreasureQuality).LineupSelectionFrame UIUtils.SetImageByAssetBundle(formationGroupCollection.img_Bg, framePath) UIUtils.SetImageByAssetBundle(formationGroupCollection.img_TreasureIcon, data.TreasurePicture) formationGroupCollection.img_TreasureIcon:SetNativeSize() UIUtils.SetLabelText(formationGroupCollection.lab_TreasureName, Const_IDS[data.TreasureName]) local activeInfo = MDL.Treasure.GetTreasureInfo(data.TreasureID) formationGroupCollection.effect_TreasureQuality:StopUIEffect() if activeInfo then local starLevel = activeInfo.TreasureInfo.starLevel if starLevel > 0 then formationGroupCollection.lab_StarLevel.text = "+" .. starLevel UIUtils.SetActive(formationGroupCollection.bg_Level, true) else formationGroupCollection.lab_StarLevel.text = "" UIUtils.SetActive(formationGroupCollection.bg_Level, false) end formationGroupCollection.lab_TreasureName.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[data.TreasureName]), data.TreasureQuality) UTL.Color.PlayQualityEffect(formationGroupCollection.effect_TreasureQuality, data.TreasureQualityEffect, UTL.Color.EffectType.Main) end else UIUtils.SetActive(formationGroupCollection.group_TreasureHorse, false) UIUtils.SetActive(formationGroupCollection.group_Empty, true) end end --endregion Treasure function UIFreeLineupDetailPanel:InitPet(formationGroupCollection, slotIndex) UIUtils.SetActive(formationGroupCollection.bg_Level, false) formationGroupCollection.lab_TreasureName.text = nil formationGroupCollection.lab_StarLevel.text = nil local petRuneId, petPos = self:GetMappingData(5, slotIndex, 0) if slotIndex % 2 ~= 0 then local runeIndex = math.ceil(slotIndex / 2) if petRuneId <= self.petSlotNum then UIUtils.SetActive(self.formationGroupPetRune[runeIndex].group_Content, true) local runeBreak = 0 for i, v in ipairs(self.petSlotBreak) do if v.slotId == petRuneId then runeBreak = v.bigBreak break end end CTL.Pet.FormatLineUpRuneName(self.formationGroupPetRune[runeIndex].txt_Rune, self.formationGroupPetRune[runeIndex].icon_Rune, petRuneId, runeBreak) else UIUtils.SetActive(self.formationGroupPetRune[runeIndex].group_Content, false) end end local petInfo = self.petInfo[petPos] if petInfo and petInfo.petType > 0 then UIUtils.SetActive(formationGroupCollection.group_TreasureHorse, true) UIUtils.SetActive(formationGroupCollection.img_TreasureIcon, false) UIUtils.SetActive(formationGroupCollection.group_PetHead.gameObject, true) local petCfg = DataSheetManager.PetData:GetDataByID_Stage(petInfo.petType, petInfo.stage) if string.isNilOrEmpty(petInfo.petName) then UIUtils.SetLabelText(formationGroupCollection.group_PetHead.lab_PetName, Const_IDS[petCfg.PetName]) else formationGroupCollection.group_PetHead.lab_PetName.text = petInfo.petName end formationGroupCollection.group_PetHead.lab_PetLv.text = petInfo.petLevel UIUtils.SetImageByAssetBundle(formationGroupCollection.group_PetHead.img_PetHead, petCfg.PetIcon) else UIUtils.SetActive(formationGroupCollection.group_TreasureHorse, false) UIUtils.SetActive(formationGroupCollection.group_Empty, true) end end --region loopScrollView function UIFreeLineupDetailPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_FormationTab then UIUtils.SetLabelText(cellTable.lab_UnSelectTab, Const_IDS[data.titleIds]) UIUtils.SetLabelText(cellTable.lab_SelectedTab, Const_IDS[data.titleIds]) UIUtils.SetImageByAssetBundle(cellTable.img_BoxSelected,string.format(TabIconPathFormat,data.titleIcon,1)) UIUtils.SetImageByAssetBundle(cellTable.img_Box,string.format(TabIconPathFormat,data.titleIcon,2)) end end function UIFreeLineupDetailPanel:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_FormationTab then self.currentTabData = data for i, v in ipairs(self.formationGroupPetRune) do v.effect_DargRune:StopUIEffect() v.effect_RuneSuccess:StopUIEffect() end self:RefreshView() end end function UIFreeLineupDetailPanel:RefreshTabTitle() -- 设置标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_LineupSelection_DetailTitle) -- 修改为动态文本 self:RefreshFormateTitle() if self.loop_FormationTab.Count > 0 then self.loop_FormationTab:ClearCells() end for i = 1, #MDL.FreeLineUp.TabTypeIDS do --越南地区屏蔽灵宠标签 if GameAppInfo.IsVietnamPackage() and MDL.FreeLineUp.TabTypeIDS[i] == "IDS_Pet" then break end local data = {} data.index = i data.titleIds = MDL.FreeLineUp.TabTypeIDS[i] data.titleIcon = MDL.FreeLineUp.TabIcons[i] self.loop_FormationTab:AddData(data, 0) end self.loop_FormationTab:SelectIndex(0) end function UIFreeLineupDetailPanel:RefreshFormateTitle() UIUtils.SetLabelText(self.lab_Front1, Const_IDS.IDS_Formation_Team1) UIUtils.SetLabelText(self.lab_Front2, Const_IDS.IDS_Formation_Team2) UIUtils.SetLabelText(self.lab_Front3, Const_IDS.IDS_Formation_Team3) UIUtils.SetLabelText(self.lab_Formate1, Const_IDS.IDS_Front) UIUtils.SetLabelText(self.lab_Formate2, Const_IDS.IDS_Middle) UIUtils.SetLabelText(self.lab_Formate3, Const_IDS.IDS_Back) end --endregion loopScrollView --region 拖拽特效 --endregion return UIFreeLineupDetailPanel