local UIHeroFormationPanel = require "View/Formation/UIHeroFormationPanel" local UIHeroLightEffectTool = require "View/Common/UIHeroLightEffectTool" local UICharacterFormationPopUp = UIViewClass(UIHeroFormationPanel) local HERO_RENDER_ID = 1000003 local BattleLight = ConstAssetPathConfig.LightLeft function UICharacterFormationPopUp:InitInfo(context) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.HeroCurtain) self.curHeroId = context.selectHeroId UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_PowerContrast_GeneralInformation) self.heroLightEffectDatas = UIHeroLightEffectTool.CreateHeroLightEffectDatas(true) self:InitHeroInfos(context.detailHeroInfo) end function UICharacterFormationPopUp:InitHeroInfos(heroInfos) self.heroInfos = heroInfos local selectIndex = 1 for i, v in ipairs(self.group_LeftHead) do v.effect_HeroQuality:StopUIEffect() local heroInfo = heroInfos[i] if heroInfo then UIUtils.SetActive(v.group_Empty, false) UIUtils.SetActive(v.img_HeroHead, true) UIUtils.SetActive(v.group_hero, true) local info = self:GetAwakenInfo(heroInfo.heroId) if info then self:SetHeroHeadItem(v, heroInfo.heroId, heroInfo.heroLevel, info.heroAwakenBreak, heroInfo.heroAdvanceLevel, true) else self:SetHeroHeadItem(v, heroInfo.heroId, heroInfo.heroLevel, heroInfo.starLevel, heroInfo.heroAdvanceLevel, false) end --品质特效 CTL.HeroSelect.PlayHeroQualityEffect(v.effect_HeroQuality, heroInfo.heroId, UTL.Color.EffectType.Formation) else UIUtils.SetActive(v.group_Empty, true) UIUtils.SetActive(v.img_HeroHead, false) UIUtils.SetActive(v.group_hero, false) end if self.curHeroId and heroInfo and heroInfo.heroId == self.curHeroId then selectIndex = i end end self:SelectHeroItem(selectIndex) end function UICharacterFormationPopUp:SelectHeroItem(index) local heroInfo = self.heroInfos[index] if heroInfo == nil then return end if self.selectHeadItem then UIUtils.SetActive(self.selectHeadItem.img_Selected, false) self.selectHeadItem = nil end self.selectHeadItem = self.group_LeftHead[index] UIUtils.SetActive(self.selectHeadItem.img_Selected, true) self:SetHeroInfo(heroInfo) end function UICharacterFormationPopUp:GetEquipGemInfos(equipIndex) local jewelryInfos = self.curHeroInfo.jewelryInfos if jewelryInfos ~= nil then for j = 1, #jewelryInfos do if j == equipIndex then --特定部位4颗宝石信息 return jewelryInfos[j].wearInfo end end else return nil end end function UICharacterFormationPopUp:IsGemTypeUnlock() return true end function UICharacterFormationPopUp:IsEquipTypeEmpty(equipIndex) if self.curHeroInfo.equipInfos and #self.curHeroInfo.equipInfos > 0 then for i, v in ipairs(self.curHeroInfo.equipInfos) do if i == equipIndex then return string.isNilOrEmpty(v.Id) end end end return false end function UICharacterFormationPopUp:SetHeroInfo(heroInfo) self.curHeroId = heroInfo.heroId self.curHeroInfo = heroInfo --装备格子 local equipInfos = heroInfo.equipInfos for i, v in ipairs(self.equipList) do if #equipInfos == 0 or string.isNilOrEmpty(equipInfos[i].Id) then UIUtils.SetActive(v.group_Equipment, false) UIUtils.SetActive(v.group_Empty, true) else UIUtils.SetActive(v.group_Equipment, true) UIUtils.SetActive(v.group_Empty, false) local itemData = DataSheetManager.ItemData:GetDataByID(equipInfos[i].CfgId) self:SetEquipItem(v, itemData, equipInfos[i].level, equipInfos[i].starStage, equipInfos[i].starNum) end end self:SetEquipGemInfo() --坐骑格子 local horseInfo = heroInfo.horseInfo if horseInfo and horseInfo.Id > 0 then self.group_HorseItem.obj_state:SetState(0) local config = DataSheetManager.HorseData:GetDataByHorseID(horseInfo.Id) self:SetHorseItem(config, horseInfo.starLevel) else self.group_HorseItem.obj_state:SetState(1) end --神兵格子 local info = self:GetAwakenInfo(heroInfo.heroId) if info then self:SetDivineWeaponItem(self.curHeroId, true, info.weaponAwakenBreak, true) else self:SetDivineWeaponItem(self.curHeroId, heroInfo.isMagicWeaponActive, heroInfo.magicWeaponLevel, false) end --宝物格子 local treasureInfo = heroInfo.treasureInfo if treasureInfo and treasureInfo.Id > 0 then self.group_TreasureItem.obj_state:SetState(0) local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(treasureInfo.Id) self:SetTreasureItem(treasureData, treasureInfo.starLevel) else self.group_TreasureItem.obj_state:SetState(1) end --战力名字 UIUtils.SetLabel(self.txt_Power, heroInfo.Gs) local heroData = DataSheetManager.HeroNum:GetDataByID(heroInfo.heroId) UIUtils.SetLabelText(self.txt_HeroNameBottom, Const_IDS[heroData.NameIDS]) --模型 UTL.UIRender.CreateHeroRenderTexture(self.modelComponentDataHandle, heroInfo.heroId, heroInfo.curAppearanceId, HERO_RENDER_ID, BattleLight, true, heroInfo.dyeCurPartList) UTL.UIRender.HeroEquipMagicWeapon(self.modelComponentDataHandle, heroInfo.heroId, heroInfo.curWeaponAppearanceId, heroInfo.starLevel, heroInfo.isMagicWeaponActive, false) local weaponSoul = CTL.DivineWeaponForgeSoul.GetWeaponSoulSkillByProtoMap(heroInfo.heroId, heroInfo.weaponSoul) if weaponSoul then UTL.UIRender.LoadPlayerWeaponSoul(self.modelComponentDataHandle, weaponSoul) end self:StopHeroLightEffect() self:BeginHeroLightEffect(heroInfo.lightEffectIds) end function UICharacterFormationPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView(true) else for i, v in ipairs(self.group_LeftHead) do if v.btn_Hero == comp then self:SelectHeroItem(i) break end end end end function UICharacterFormationPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end --不删,不执行父类的关闭 function UICharacterFormationPopUp:OnClosePanel() self:StopHeroLightEffect(true) UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end function UICharacterFormationPopUp:StopHeroLightEffect(isDispose) UIHeroLightEffectTool.StopHeroLightEffect(self.heroLightEffectDatas) if isDispose then self.heroLightEffectDatas = nil end end function UICharacterFormationPopUp:BeginHeroLightEffect(heroLightEffects) if heroLightEffects then local datas = self.heroLightEffectDatas for _, lightEffectID in ipairs(heroLightEffects) do UIHeroLightEffectTool.PlayHeroLightEffect(datas, self, 0, UIHeroLightEffectTool.PlayLightEffectFuncEnum.PlayerModel,lightEffectID) end end end function UICharacterFormationPopUp:PlayModelEffect(index, effectPath) return UTL.UIRender.PlayPsEffect(self.modelComponentDataHandle, effectPath) end function UICharacterFormationPopUp:GetAwakenInfo(heroId) for i, v in ipairs(self.context.awakenBreakInfo) do if heroId == v.heroId and v.heroAwaken == true then return v end end return nil end return UICharacterFormationPopUp