--- 武将阵容界面 local UIHeroLightEffectTool = require "View/Common/UIHeroLightEffectTool" local UIHeroFormationPanel = UIViewClass() local MAX_EQUIP_NUM = 4 --最多装备数量 local MAX_GEM_NUM = 4 local SCROLL_SPEED = 0.6 -- 武将技能滚动速度 -- TODO -- 优化前:进入界面时 会同时加载4国场景、加载展示模型、设置UI,峰值压力较大 -- 优化后:进入界面时 会先加载界面(不设置具体UI内容)、加载4国场景和展示模型、设置UI,尽量降低了峰值压力 -- 还存在的问题: -- 1、由于加载场景的接口没有单独拆分,所以加载场景和展示模是同时加载,峰值还是比较大, -- 后续将加载场景接口单独拆分,实现 加载UI(不设置具体UI内容)、加载场景、分帧加载武将、设置UI,以便进一步降低峰值压力 -- 2、这个界面所有的刷新全是监听的RefreshPanel,但是这个函数刷新的范围非常广,会把整个界面绝大部分UI全刷新一遍, -- 比如一个HUD的变化,整个界面都会重刷。包括武将。这里需要后续将RefreshPanel拆分,具体刷新只刷新对应的UI,以便降低开着这个界面时的频繁刷新开销。 -- 3、使用分帧加载后。由于武将先加载、界面后设置,具体的表现效果有一点肉眼上的延迟 需要重新考虑效果 function UIHeroFormationPanel:OnCreated() self.equipList = { [1] = self.group_EquipItem_1, [2] = self.group_EquipItem_2, [3] = self.group_EquipItem_3, [4] = self.group_EquipItem_4, } if self.heroFormation then self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.heroFormation) end self:InitGemInfo() end function UIHeroFormationPanel:OnOpened(context) self:InitInfo(context) UIManager.ActiveUIModle(false, "UIHeroFormationPanel") CTL.Setting.SetUIShadowDistance(6) CTL.Setting.Set5SSkin(true) end function UIHeroFormationPanel:InitInfo(context) self.heroLightEffectDatas = UIHeroLightEffectTool.CreateHeroLightEffectDatas(false) self:InitHero(context) self:StartRepeatFunc(self.DelayInitPanel, 0.12, 1) end function UIHeroFormationPanel:InitHero(context) if context and context.heroId then self.curHeroId = context.heroId else if MDL.HeroSelect.curSelectHeroID > 0 and MDL.Player.HeroIsLineUp(MDL.HeroSelect.curSelectHeroID) then self.curHeroId = MDL.HeroSelect.curSelectHeroID MDL.HeroSelect.curSelectHeroID = 0 else self.curHeroId = CTL.Formation.TempSelectedHeroId or MDL.Formation.GetSlotHeroIdByIndex(1) end end ---添加一个标志位IsBack,目的是在C#端,打开这个界面的时候,先执行enter,再设置镜头融合时间,防止一个BUG(仅手机端可复现,点开阵容界面后快速切换一个武将,镜头位置不对) ---如果是从养成界面回来的,那么isBack就是true,那么就需要先设置融合时间,再进行enter if context and context.isBack then if context and context.ifBlend then UTL.UIRender.SetBlendTime(self.modelComponentDataHandle, 0.5) end self:RefreshHeroModel() else self:RefreshHeroModel() if context and context.ifBlend then UTL.UIRender.SetBlendTime(self.modelComponentDataHandle, 0.5) end end -- 清空缓存标志位 if context then context.isBack = false context.ifBlend = false end end function UIHeroFormationPanel:DelayInitPanel() self.hplmtAttrData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.hplmt) self.atkAttrData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.atk) self.defAttrData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.def) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.UpdateUnlockBtns) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Formation_AssistFight, self.UpdateUnlockBtnRP) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Formation_GodBeast, self.UpdateUnlockBtnRP) self:UpdateUnlockBtns(MDL.Unlock.FunctionType.HeroFormation) self:UpdateUnlockBtns(MDL.Unlock.FunctionType.GodBeast) self:UpdateUnlockBtns(MDL.Unlock.FunctionType.AssistanceFight) self:UpdateUnlockBtns(MDL.Unlock.FunctionType.Pet) self.currentSkillGroupIndex = 1 --当前显示的技能组索引 self.relationList = {} self.equipInfoList = {} UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Fomation_Fomation) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info.gameObject, false) self:RefreshPanel(self.curHeroId, true) self:RegistSystemEvent(EventID.UI_RefreshAdvancedInfo, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_HeroBreak_Breakthrough, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_HeroFormation_ChangeHero, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.RefreshPanel) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_LightEffect_Refresh, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_ResonanceChange_Refresh, self.RefreshResonanceLv) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshResonanceLv) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Formation_AssistFight, self.RefreshBtnArrayRP) self:RegistSystemEvent(EventID.UI_HeroRelation_Refresh, self.UpdateHeroRelation) self:RegistSystemEvent(EventID.UI_HeroRelation_Refresh, self.UpdateHeroRelationLoc) --装备解锁条件 if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Equipment) then for i = 1, #self.equipList do UIUtils.SetActive(self.equipList[i].gameObject, true) end self:RegistSystemEvent(EventID.UI_UpdateEquipmentInfo, self.RefreshPanel) else for i = 1, #self.equipList do UIUtils.SetActive(self.equipList[i].gameObject, false) end end --坐骑解锁条件 if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.WarHorse) then UIUtils.SetActive(self.group_HorseItem.gameObject, true) self:RegistSystemEvent(EventID.UI_UpdateWarHorseInfo, self.RefreshPanel) else UIUtils.SetActive(self.group_HorseItem.gameObject, false) end --宝物解锁条件 if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Treasure) then UIUtils.SetActive(self.group_TreasureItem.gameObject, true) self:RegistSystemEvent(EventID.UI_UpdateTreasureInfo, self.RefreshPanel) self:RegistSystemEvent(EventID.TreasureSoulCrystal_UpdateBag, self.RefreshTreasureInfo) self:RegistSystemEvent(EventID.TreasureSoulCrystal_UpdateBag, self.RefreshLeftHeroHeads) else UIUtils.SetActive(self.group_TreasureItem.gameObject, false) end -- 共鸣解锁条件 if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Resonance) then UIUtils.SetActive(self.btn_Medal, true) else UIUtils.SetActive(self.btn_Medal, false) end if self.loc_Develop.CurState ~= 1 then UIUtils.SetLocalizationImage(self.img_CultivateIcon, "zr_msz_yc.png") end self:ShowNewHeroIcon() self:RefreshResonanceLv() end function UIHeroFormationPanel:RefreshResonanceLv() local mainLevel = MDL.FormationResonance.GetMainResonanceLevel() local cfg = DataSheetManager.ResonanceAll:GetDataByResonanceLevel(mainLevel) if cfg then for i, v in ipairs(self.group_Fire) do UIUtils.SetActive(v, i <= cfg.Star) end UIUtils.SetLabelText(self.txt_ResonanceLv, Const_IDS[cfg.ResonanceName]) UIUtils.SetImageByAssetBundle(self.icon_Resonance, cfg.Icon) UIUtils.SetImageByAssetBundle(self.img_IconBg, cfg.IconUnderframe) end UIUtils.SetImageByAssetBundle(self.icon_ResonanceBG, cfg.IconUnderframe) local isCanLevelup, _, _ = MDL.FormationResonance.IsCanLevelupMainResonance() UIUtils.SetActive(self.medal_Upgrade, isCanLevelup) end function UIHeroFormationPanel:ShowNewHeroIcon() if CTL.Formation.IsShowNewHero() then UIUtils.SetActive(self.group_New, true) self:PlayUIAnimation("UIAnimationNew") else UIUtils.SetActive(self.group_New, false) end end function UIHeroFormationPanel:GemGongMingLevel(heroID) local gongMingInfo = MDL.GemCompose.GetHeroGongMingInfo(heroID) local gongMingLevel = 0 if gongMingInfo and gongMingInfo.isActive then gongMingLevel = gongMingInfo.level end end function UIHeroFormationPanel:OnClosed() CTL.Setting.SetUIShadowDistance(0) CTL.Setting.Set5SSkin(false) UIManager.ActiveUIModle(true, "UIHeroFormationPanel") self:OnClosePanel() end function UIHeroFormationPanel:OnClosePanel() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info.gameObject, true) UIHeroLightEffectTool.StopHeroLightEffect(self.heroLightEffectDatas) self.heroLightEffectDatas = nil UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end function UIHeroFormationPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIHeroFormationPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then UTL.UIRender.CancelBlend(self.modelComponentDataHandle) self:CloseView(true) CTL.Formation.TempSelectedHeroId = nil elseif comp == self.UITemplateTitlePanel.btn_Home then UTL.UIRender.CancelBlend(self.modelComponentDataHandle) CTL.HomeMain.CloseViewBackHomeMain() CTL.Formation.TempSelectedHeroId = nil elseif comp == self.btn_Array then self.context = nil UTL.UIRender.CancelBlend(self.modelComponentDataHandle) CTL.Formation.TempSelectedHeroId = self.curHeroId UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIArray) elseif comp == self.btn_Cultivate then MDL.HeroSelect.curSelectHeroID = self.curHeroId CTL.Formation.TempSelectedHeroId = self.curHeroId self.context = { ifBlend = true, isFormation = true, isBack = true } self:OpenHeroShowView({ ifBlend = true, isFormation = true, isBack = true}) elseif comp == self.btn_ChangeHero then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroChangeView, { oldHeroId = self.curHeroId }) UIUtils.SetActive(self.group_New, false) elseif comp == self.event_AttrInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroDetailProperties, {showHeroId = self.curHeroId}) -- 武将详细属性界面 elseif comp == self.obj_Country.btn_Country then self:CloseSubView() self.heroFilterView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroFilterView), {canJump = true, parent = self}) self.heroFilterView:InitByHeroID(self.curHeroId, true) self.heroFilterView:SetFilterViewPosByTF(self.obj_HeroFilterPos) elseif comp == self.obj_Profession.btn_Profession then self:CloseSubView() self.heroFilterView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroFilterView), {canJump = true, parent = self}) self.heroFilterView:InitByHeroID(self.curHeroId, false) self.heroFilterView:SetFilterViewPosByTF(self.obj_HeroFilterPos) elseif comp == self.btn_AssistanceFight then self.context = nil UTL.UIRender.CancelBlend(self.modelComponentDataHandle) CTL.Formation.TempSelectedHeroId = self.curHeroId CTL.AssistanceFight.OpenAssistancePanel(1, true) elseif comp == self.group_Artifact.Button then UTL.UIRender.CancelBlend(self.modelComponentDataHandle) self.context = nil local data = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(self.curHeroId) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIDivineWeaponBasePanel, { data = data, isFormation = true }) elseif comp == self.group_HorseItem.btn_Click then if self.HorseVo then --进入养成界面 self.context = nil UTL.UIRender.CancelBlend(self.modelComponentDataHandle) CTL.WarHorse.OpenSubPanel(CTL.WarHorse.Horse_EnterType.Formation, self.HorseVo.ConfigInfo, CTL.WarHorse.Horse_TabIndex.Break) else --穿戴 CTL.WarHorse.OpenWearPanel(self.curHeroId, self.HorseVo) end elseif comp == self.group_TreasureItem.btn_Click then if self.treasureInfo then --进入养成界面 self.context = nil UTL.UIRender.CancelBlend(self.modelComponentDataHandle) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UITreasureBasePanel, { treasureId = self.treasureInfo.TreasureID, isFormation = true }) else --穿戴 UIManager.OpenView(Const_UI_Lua.UIEnum.UITreasureChangeView, { heroId = self.curHeroId }, "WarHorse/UIWarHorseChangeView") end elseif comp == self.btn_Medal then -- 阵位共鸣 UIManager.OpenView(Const_UI_Lua.UIEnum.UIMedal) elseif comp == self.group_ActiveSkill.btn_Change then --切换技能展示 self.currentSkillGroupIndex = self.currentSkillGroupIndex + 1 if self.currentSkillGroupIndex > #self.activeSkillList then self.currentSkillGroupIndex = 1 end self:RefreshHeroSkills(self.curHeroId) elseif comp == self.btn_StratagemSetting then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIStratagemEquip) elseif comp == self.btn_GodBeast then -- 神兽布阵 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGodBeastEquip) elseif comp == self.btn_Pet then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIPetFormation) elseif comp == self.group_Attr.lab_Hp then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.group_Attr.img_HPIcon, posType = LuaConst.DescriptionPanelType.RightLower, offsetX = -20, text = Const_IDS[self.hplmtAttrData.AttrDesc] }) elseif comp == self.group_Attr.lab_Atk then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.group_Attr.img_AtkIcon, posType = LuaConst.DescriptionPanelType.RightLower, offsetX = -20, text = Const_IDS[self.atkAttrData.AttrDesc] }) elseif comp == self.group_Attr.lab_Def then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.group_Attr.img_DefIcon, posType = LuaConst.DescriptionPanelType.RightLower, offsetX = -20, text = Const_IDS[self.defAttrData.AttrDesc] }) else for index, cell in ipairs(self.equipList) do if comp == cell.btn_Click then local equipInfo = self.equipInfoList[index] if equipInfo then CTL.Equipment.OpenDetailByEquipInfo(equipInfo, nil, true) else CTL.Equipment.OpenDetailByHeroId(self.curHeroId, index, MDL.Equipment.DetailType.Base, true) end return end end for index, cell in ipairs(self.group_LeftHead) do if comp == cell.btn_Hero then if self.curHeroId ~= MDL.Formation.GetSlotHeroIdByIndex(index) then self.curHeroId = MDL.Formation.GetSlotHeroIdByIndex(index) self:RefreshPanel() end return elseif comp == cell.img_Get then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_NoHero"]) return end end for index, cell in ipairs(self.group_ActiveSkill.skills) do if comp == cell.btn_Skill then self.ActiveSkillTips:CloseAll() self.PassiveSkillTips:CloseAll() CTL.Tips.OpenHeroSkillTips(self.ActiveSkillTips, self.curHeroId, self.activeSkillList[self.currentSkillGroupIndex][index], MDL.HeroAwaken.GetIsHeroAwaken(self.curHeroId)) return end end end end function UIHeroFormationPanel:RefreshPanel(heroId, isInit) self.curHeroId = heroId or self.curHeroId self.attrAppearanceWearID = MDL.HeroSelect.GetAttrAppearanceIDByHeroID(self.curHeroId) if not isInit then self:StopRepeatFunc(self.RefreshHeroModel) self:StartRepeatFunc(self.RefreshHeroModel, 0.12, 1) end self:RefreshLeftHeroHeads() self:RefreshRightHeroInfos(self.curHeroId) self:RefreshMiddleInfo(self.curHeroId) self:RefreshButtonsState(self.curHeroId) self:RefreshHeroEquipments() self:RefreshHorseInfo() self:RefreshTreasureInfo() self:SetWeaponInfo(self.curHeroId) self:GemGongMingLevel(self.curHeroId) self:RefreshStratagemInfo() end function UIHeroFormationPanel:RefreshHeroModel() if self.curHeroModelId == self.curHeroId then return end self.curHeroModelId = self.curHeroId UIHeroLightEffectTool.StopHeroLightEffect(self.heroLightEffectDatas) local scenePath, modelPath, equipTable, modelScale, lightPath, heroEffectPath, heroLightEffects = CTL.HeroDetail.GetHeroShowDetail(self.curHeroModelId) -- 卸载之前的模型 UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) -- 加载场景 UTL.UIRender.Create3DSceneTrans(self.modelComponentDataHandle, scenePath, 2000, 0, 2000, 0, 327, 0, UTL.UIRender.LayerActiveType.HeroFormation) -- 模型设置 UTL.UIRender.CreatePlayerModel(self.modelComponentDataHandle, self.curHeroModelId, nil, nil, true) UTL.UIRender.SetModelRootLocalScale(self.modelComponentDataHandle, modelScale, modelScale, modelScale) -- 铸魂天命 if MDL.DivineWeaponForgeSoul.IsWeaponSoulActive(self.curHeroModelId) then UTL.UIRender.LoadPlayerWeaponSoul(self.modelComponentDataHandle, MDL.DivineWeaponForgeSoul.GetWeaponForgeSoulSkillsLv(self.curHeroModelId)) end for _, lightId in ipairs(heroLightEffects) do UIHeroLightEffectTool.PlayHeroLightEffect(self.heroLightEffectDatas, self, 0, UIHeroLightEffectTool.PlayLightEffectFuncEnum.LuaView, lightId, nil) end end function UIHeroFormationPanel:RefreshLeftHeroHeads() local lineUpIds = MDL.Formation.GetSlotHeroIds() for index, cell in ipairs(self.group_LeftHead) do cell.effect_HeroQuality:StopUIEffect() if lineUpIds[index] < 0 then cell.state_hero:SetState(1) local arrayData = DataSheetManager.BattleArray:GetDataByArrayID(index) local unLockParamVal = tonumber(arrayData.UnlockConditionParam) local isLevel = DataSheetManager.BarrierChosenData:GetDataByID(unLockParamVal) ~= nil if isLevel then local unLockIDS = DataSheetManager.BarrierChosenData:GetDataByID(unLockParamVal).BarrierNum local unLockTemp = UIUtils.GetLocalizedTxt(Const_IDS[arrayData.UnlockDes]) local unLockInfo = UIUtils.GetLocalizedTxt(Const_IDS[unLockIDS]) UIUtils.SetLabel(cell.txt_Locked, string.format(unLockTemp, unLockInfo)) else UIUtils.SetLabel(cell.txt_Locked, string.format(UIUtils.GetLocalizedTxt(Const_IDS[arrayData.UnlockDes]), arrayData.UnlockConditionParam)) end elseif lineUpIds[index] == 0 then cell.state_hero:SetState(2) else cell.state_hero:SetState(0) self:RefreshSingleHeroHead(lineUpIds[index], cell) end end end function UIHeroFormationPanel:SetHeroHeadIcon(cell, heroId, isAwaken) UTL.Color.SetQualityImageByType(cell.bg_HeroHead, CTL.HeroAwaken.GetHeroQuality(heroId, isAwaken), UTL.Color.QualityType.NewSquare) UTL.Item.SetHeroIconByHeroId(cell.img_HeroHead, heroId, isAwaken) end --左侧显示头像逻辑 function UIHeroFormationPanel:SetHeroHeadItem(cell, heroId, heroLevel, heroBreak, heroAdvanceLevel, isAwaken) self:SetHeroHeadIcon(cell, heroId, isAwaken) cell.txt_HeroLv.text = UTL.Item.GetNobilityByTeamLevel(heroLevel) if isAwaken then UIUtils.SetActive(cell.bg_Break, true) UIUtils.SetLabel(cell.lab_Break, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_AwakenLevelNum"], heroBreak)) elseif heroBreak and heroBreak > 0 then UIUtils.SetActive(cell.bg_Break, true) UIUtils.SetLabel(cell.lab_Break, "+" .. heroBreak) else UIUtils.SetActive(cell.bg_Break, false) end if heroAdvanceLevel and heroAdvanceLevel > 0 then UIUtils.SetActive(cell.img_StarGroupBg, true) local advancedData = DataSheetManager.HeroAdvance:GetDataByAdvanceID(heroAdvanceLevel) CTL.Advanced.InstantiateStarCell(self, cell.group_Star[1].gameObject, cell.group_Star, advancedData.SumStar, advancedData.LightStar, advancedData.StarColorIcon, advancedData.StarLockIcon) else UIUtils.SetActive(cell.img_StarGroupBg, false) end end function UIHeroFormationPanel:RefreshSingleHeroHead(heroId, cell) if heroId == self.curHeroId then UIUtils.SetActive(cell.effect_Selected, true) cell.effect_Selected:PlayUIEffect() else UIUtils.SetActive(cell.effect_Selected, false) end local heroLevel = MDL.HeroSelect.GetHeroLevel(heroId) local heroBreak = MDL.HeroStar.GetHeroStarLevel(heroId) local advanceLevel = 0 if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Advanced) then advanceLevel = MDL.Advanced.GetHeroAdvancedInfo(heroId) end local isAwaken = MDL.HeroAwaken.GetIsHeroAwaken(heroId) if isAwaken then heroBreak = MDL.HeroAwaken.GetCurStar(heroId) end self:SetHeroHeadItem(cell, heroId, heroLevel, heroBreak, advanceLevel, isAwaken) --装备红点统一到箭头上 if CTL.HeroSelect.IsHeroCanUpgradeByFormation(heroId) or CTL.Equipment.CheckFormationEquipIfRedByHeroId(heroId) or CTL.DivineWeapon.IfDivineWeaponCanUpgrade(heroId) or MDL.GemCompose.RedpointEquipGemInfoByHero(heroId) or MDL.GemCompose.QuickEquipGemInfoByHero(heroId) or CTL.WarHorse.CheckHeroHorseRed(heroId) or CTL.Treasure.CheckHeroTreasureRedPoint(heroId) or CTL.Equipment.EquipStarHasRed(heroId) or CTL.HeroAwaken.CheckAwakenRed(heroId) or CTL.HeroAwaken.CheckHeroSkillRed(heroId) then UIUtils.SetActive(cell.img_Upgrade, true) else UIUtils.SetActive(cell.img_Upgrade, false) end --品质特效 CTL.HeroSelect.PlayHeroQualityEffect(cell.effect_HeroQuality, heroId, UTL.Color.EffectType.Formation) end function UIHeroFormationPanel:RefreshRightHeroInfos(heroId) self.currentSkillGroupIndex = 1 --重置技能组索引 self:RefreshHeroInformation(heroId) -- 武将信息 self:RefreshHeroAttr(heroId) -- 属性 self:RefreshHeroSkills(heroId) -- 技能 -- 羁绊 if self.obj_Country.loc_Country.CurState == 0 then UIUtils.SetActive(self.group_Assembly, true) UIUtils.SetActive(self.group_AssemblyLoc, false) self:UpdateHeroRelation() else UIUtils.SetActive(self.group_AssemblyLoc, true) UIUtils.SetActive(self.group_Assembly, false) self:UpdateHeroRelationLoc() end end local countryTitleBgPathTemplate = ConstAssetPathConfig.countryTitleBgPathTemplate function UIHeroFormationPanel:RefreshHeroInformation(heroId) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UIUtils.SetLabelText(self.txt_HeroName, Const_IDS[heroData.NameIDS]) local countryData = DataSheetManager.HeroCountry:GetDataByID(heroData.Kingdom) -- 英雄title背景底图 UIUtils.SetImageByAssetBundle(self.img_TitleBG, string.format(countryTitleBgPathTemplate, heroData.Kingdom)) -- 国家名称图片 CTL.HeroSelect.SetHeroCountry(heroId, self.obj_Country) -- 武将职业 CTL.HeroSelect.SetHeroProfession(heroId, self.obj_Profession, true) local heroBreak = MDL.HeroStar.GetHeroStarLevel(heroId) if MDL.HeroAwaken.GetIsHeroAwaken(heroId) then local awakenLevel = MDL.HeroAwaken.GetCurStar(heroId) UIUtils.SetLabel(self.txt_BreakNum, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_AwakenLevelNum"], awakenLevel)) elseif heroBreak == 0 then UIUtils.SetLabel(self.txt_BreakNum, nil) else UIUtils.SetLabel(self.txt_BreakNum, "+" .. heroBreak) end if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Advanced) then local totalStar, lightStar = MDL.Advanced.GetStarInfoOfAdvanced(heroId) local advancedData = DataSheetManager.HeroAdvance:GetDataByAdvanceID(MDL.Advanced.GetHeroAdvancedInfo(heroId)) CTL.Advanced.InstantiateStarCell(self, self.group_Star[1].gameObject, self.group_Star, totalStar, lightStar, advancedData.StarColorIcon, advancedData.StarLockIcon) UIUtils.SetActive(self.group_Star.gameObject, true) else UIUtils.SetActive(self.group_Star.gameObject, false) end UIUtils.SetLabel(self.txt_Lv, MDL.HeroSelect.GetHeroLevelName(heroId)) end local QualIconPath = "sx_icon_zizhi" function UIHeroFormationPanel:RefreshHeroAttr(heroId) -- 资质 local heroQuality = CTL.HeroSelect.GetHeroNameQuality(heroId) UIUtils.SetLabelText(self.group_Attr.txt_QuaTitle, Const_IDS.IDS_Intelligence) UIUtils.SetLabel(self.group_Attr.txt_Qualification, UTL.Color.FormatQualityText(CTL.HeroSelect.GetHeroIntelligence(heroId), heroQuality)) UTL.Item.SetAtlasSprite(self.group_Attr.img_QuaIcon, "UI_Formation", QualIconPath) local totalAttrList = MDL.HeroDetail.GetTotalAttr(heroId) -- 生命值 UIUtils.SetLabelText(self.group_Attr.txt_HPTitle, Const_IDS[self.hplmtAttrData.Name]) UTL.Attr.SetAttrIcon(self.group_Attr.img_HPIcon, LuaConst.AttrTypeId.hplmt) UIUtils.SetLabel(self.group_Attr.txt_Hp, totalAttrList[LuaConst.AttrTypeId.hplmt]) -- 攻击力 UIUtils.SetLabelText(self.group_Attr.txt_AtkTitle, Const_IDS[self.atkAttrData.Name]) UTL.Attr.SetAttrIcon(self.group_Attr.img_AtkIcon, LuaConst.AttrTypeId.atk) UIUtils.SetLabel(self.group_Attr.txt_Atk, totalAttrList[LuaConst.AttrTypeId.atk]) -- 防御力 UIUtils.SetLabelText(self.group_Attr.txt_DefTitle, Const_IDS[self.defAttrData.Name]) UIUtils.SetLabel(self.group_Attr.txt_Def, totalAttrList[LuaConst.AttrTypeId.def]) UTL.Attr.SetAttrIcon(self.group_Attr.img_DefIcon, LuaConst.AttrTypeId.def) end function UIHeroFormationPanel:RefreshHeroSkills(heroId) self.activeSkillList = MDL.HeroSelect.GetHeroDisplaySkillIdList(heroId) --多套技能显示切换展示按钮 local showChangeState = #self.activeSkillList > 1 and 0 or 1 self.group_ActiveSkill.state_Line:SetState(showChangeState) for index, cell in ipairs(self.group_ActiveSkill.skills) do local skillId = self.activeSkillList[self.currentSkillGroupIndex][index] if skillId == nil then UIUtils.SetActive(cell.gameObject,false) else UIUtils.SetActive(cell.gameObject,true) self:RefreshSkillIconShow(cell, heroId, skillId, false) end end -- 武将天赋 self.group_PassiveSkills.loop_PassiveSkills:ClearCells() self.passiveSkillList = MDL.HeroStar.GetCurrentDevelopEffectIdTableByHeroId(heroId) if MDL.HeroAwaken.GetIsHeroAwaken(heroId) then for i, v in ipairs(CTL.HeroAwaken.GetHeroAwakenTalent(heroId)) do self.group_PassiveSkills.loop_PassiveSkills:AddData(v, 0) end end if self.attrAppearanceWearID > 0 then local appearanceData = DataSheetManager.HeroAppearance:GetDataByID(self.attrAppearanceWearID) if appearanceData.TalentID > 0 then self.group_PassiveSkills.loop_PassiveSkills:AddData({heroId = heroId, skillId = appearanceData.TalentID, isAppearancePassiveSkill = true, appearanceData = appearanceData}, 0) end end for k,v in ipairs(self.passiveSkillList) do self.group_PassiveSkills.loop_PassiveSkills:AddData({heroId = heroId, skillId = v, isAppearancePassiveSkill = false}, 0) end end local SkillPath = ConstAssetPathConfig.SkillImagePath function UIHeroFormationPanel:RefreshSkillIconShow(cell, heroId, skillId) local skillIcon, skillTips local isLock,currentSkillId,currentSkillLevel = MDL.HeroSelect.GetSkillTipsOfCurrentLevel(heroId,skillId) local skillData = DataSheetManager.SkillTipsData:GetDataByID(currentSkillId) cell.txt_Level.text = 1 if skillData then UIUtils.SetActive(cell.img_LevelBg, not isLock) UIUtils.SetActive(cell.group_Locked.gameObject, isLock) cell.txt_Level.text = currentSkillLevel skillIcon = skillData.SkillIcon skillTips = skillData.SkillFuncType end if MDL.HeroAwaken.GetIsHeroAwaken(heroId) then UIUtils.SetImageByAssetBundle(cell.sprite_Skill, CTL.HeroAwaken.GetAwakenDisplaySkillIcon(heroId, skillId)) else UIUtils.SetImageByAssetBundle(cell.sprite_Skill, string.format(SkillPath, skillIcon)) end UIUtils.SetLabelText(cell.txt_SkillType, Const_IDS[skillTips]) if skillData.LevelUpType == 5 then UIUtils.SetActive(cell.img_LevelBg, false) end end --装备Icon下面宝石信息 function UIHeroFormationPanel:InitGemInfo() self.GemIconRoot = {} table.insert(self.GemIconRoot, self.group_EquipItem_1.group_Gem) table.insert(self.GemIconRoot, self.group_EquipItem_2.group_Gem) table.insert(self.GemIconRoot, self.group_EquipItem_3.group_Gem) table.insert(self.GemIconRoot, self.group_EquipItem_4.group_Gem) self.GemIconBg = {} table.insert(self.GemIconBg, self.group_EquipItem_1.bg_Gem) table.insert(self.GemIconBg, self.group_EquipItem_2.bg_Gem) table.insert(self.GemIconBg, self.group_EquipItem_3.bg_Gem) table.insert(self.GemIconBg, self.group_EquipItem_4.bg_Gem) self.GemIcons = {} table.insert(self.GemIcons, self.group_EquipItem_1.cell_Gem) table.insert(self.GemIcons, self.group_EquipItem_2.cell_Gem) table.insert(self.GemIcons, self.group_EquipItem_3.cell_Gem) table.insert(self.GemIcons, self.group_EquipItem_4.cell_Gem) end function UIHeroFormationPanel:GetEquipGemInfos(equipIndex) if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Gem) == false then return nil end return MDL.GemCompose.GetHeroInlayGemInfo(self.curHeroId, equipIndex) end function UIHeroFormationPanel:IsEquipTypeEmpty(equipIndex) return MDL.GemCompose.HasEquipByHeroId(self.curHeroId, equipIndex) end function UIHeroFormationPanel:IsGemTypeUnlock(equipIndex, gemType) local GemTypeCfgData = DataSheetManager.JadeType:GetDataByID_ChildID(equipIndex, gemType) return MDL.Unlock.IsComplete(GemTypeCfgData.UnlockCondition, GemTypeCfgData.UnlockConditionParam) end function UIHeroFormationPanel:SetEquipGemInfo() for equipIndex = 1, MAX_EQUIP_NUM do local inlayGemInfos = self:GetEquipGemInfos(equipIndex) if inlayGemInfos ~= nil and #inlayGemInfos > 0 then UIUtils.SetActive(self.GemIconRoot[equipIndex].gameObject, true) UIUtils.SetActive(self.GemIconBg[equipIndex], true) for i = 1, #inlayGemInfos do local isUnlock = self:IsGemTypeUnlock(equipIndex, i) if isUnlock then local gemIcon = self.GemIconRoot[equipIndex][i] if gemIcon == nil then gemIcon = self:InstantiateCollection(self.GemIconRoot[equipIndex], self.GemIcons[equipIndex].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 else local gemIcon = self.GemIconRoot[equipIndex][i] if gemIcon ~= nil then UIUtils.SetActive(gemIcon.gameObject, false) end end end else if self:IsEquipTypeEmpty(equipIndex) == false then UIUtils.SetActive(self.GemIconRoot[equipIndex].gameObject, false) UIUtils.SetActive(self.GemIconBg[equipIndex], false) else UIUtils.SetActive(self.GemIconRoot[equipIndex].gameObject, true) UIUtils.SetActive(self.GemIconBg[equipIndex], true) for i = 1, MAX_GEM_NUM do local isUnlock = self:IsGemTypeUnlock(equipIndex, i) if isUnlock then local gemIcon = self.GemIconRoot[equipIndex][i] if gemIcon == nil then gemIcon = self:InstantiateCollection(self.GemIconRoot[equipIndex], self.GemIcons[equipIndex].gameObject) end UIUtils.SetActive(gemIcon.gameObject, true) local icon = gemIcon.icon_Gem UIUtils.SetActive(icon, false) else local gemIcon = self.GemIconRoot[equipIndex][i] if gemIcon ~= nil then UIUtils.SetActive(gemIcon.gameObject, false) end end end end end end end --region -- **************** 羁绊部分(待补充) ******************* -- --endregion 协议部分 function UIHeroFormationPanel:RefreshMiddleInfo(heroId) UIUtils.SetLabel(self.txt_Power, MDL.HeroSelect.GetHeroGs(heroId)) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UIUtils.SetLabelText(self.txt_HeroNameBottom, Const_IDS[heroData.NameIDS]) local heroBreak = MDL.HeroStar.GetHeroStarLevel(heroId) if heroBreak == 0 then UIUtils.SetLabel(self.txt_BreakNumBottom, nil) else UIUtils.SetLabel(self.txt_BreakNumBottom, "+" .. heroBreak) end UIUtils.SetActive(self.img_HeroAdvanced, MDL.Advanced.IsHeroCanAdvance(heroId) or MDL.Advanced.IsHeroCanGatherToAdvance(heroId)) end function UIHeroFormationPanel:RefreshButtonsState(heroId) UIUtils.SetActive(self.cultivate_Upgrade, CTL.HeroSelect.IsHeroCanUpgradeByFormation(heroId)) UIUtils.SetActive(self.btn_Array, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.ArrayInFormation)) end --装备格子显示 function UIHeroFormationPanel:SetEquipItem(equipComp, itemData, enhanceLevel, starStage, starNum) CTL.Equipment.SetUIFormationEquipShow(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 if starStage > 0 then UIUtils.SetActive(equipComp.group_EquipStar, true) equipComp.txt_Num.text = starNum local stageData = DataSheetManager.EquipStarStage:GetDataByStarStage(starStage) UIUtils.SetImageByAssetBundle(equipComp.img_Star, stageData.Icon) else UIUtils.SetActive(equipComp.group_EquipStar, false) end CTL.Equipment.SetEquipmentStage(equipComp.txt_EquipStageNum, itemData.ID, false) UIUtils.SetActive(equipComp.txt_EquipStageNum, true) end function UIHeroFormationPanel:RefreshHeroEquipments() local heroId = self.curHeroId local equipInfos = MDL.Equipment.GetEquipmentsByHeroId(heroId) if equipInfos then --宝石镶嵌箭头 local gemRedPoint = MDL.GemCompose.RedpointEquipGemInfoInFunction(heroId) local quickCompose = MDL.GemCompose.QuickEquipGemInfoInFunction(heroId) local heroInfo = MDL.HeroSelect.GetHeroInfo(heroId) for i = 1, #self.equipList do self.equipList[i].btn_Click:SetRedPoint(false) UIUtils.SetActive(self.equipList[i].img_Upgrade, false) UIUtils.SetActive(self.equipList[i].group_EquipStar, false) local isUnlock, content = CTL.Equipment.CheckIfEquipTypeUnlock(i) if isUnlock == false then self.equipList[i].condition_UnlockState:SetState(1) self.equipList[i].txt_Locked.text = content self.equipList[i].btn_Click:SetRedPoint(false) else self.equipList[i].condition_UnlockState:SetState(0) local isEquipped = false for j = 1, #equipInfos do if equipInfos[j].EquipData.EquipType == i then isEquipped = true self.equipList[i].obj_state:SetState(0) local gemArrow = gemRedPoint[i] or quickCompose[i] if gemArrow or CTL.Equipment.CheckEquipIfStrength(equipInfos[j]) or CTL.Equipment.CheckIfRefine(equipInfos[j]) or CTL.Equipment.CheckEquipIfLevelUp(equipInfos[j]) then UIUtils.SetActive(self.equipList[i].img_Upgrade, true) end local _, enhanceLevel = MDL.Equipment.GetEquipHeroInfo(equipInfos[j].ID) local starStage, starNum = MDL.Equipment.GetEquipStarInfo(equipInfos[j].ID) self:SetEquipItem(self.equipList[i], equipInfos[j].ItemData, enhanceLevel, starStage, starNum) self.equipInfoList[i] = equipInfos[j] self.equipList[i].btn_Click:SetRedPoint(CTL.Equipment.CheckHasBetterBetterEquip(heroInfo.equipInfos[i], i)) break end end if isEquipped == false then self.equipList[i].obj_state:SetState(1) UTL.Item.SetAtlasSprite(self.equipList[i].img_quality, "UI_Formation", "zr_icon_pz02") self.equipInfoList[i] = nil end end end else for i = 1, #self.equipList do UIUtils.SetActive(self.equipList[i].group_EquipStar, false) local isUnlock, content = CTL.Equipment.CheckIfEquipTypeUnlock(i) if isUnlock == false then self.equipList[i].condition_UnlockState:SetState(1) self.equipList[i].txt_Locked.text = content else self.equipList[i].condition_UnlockState:SetState(0) self.equipList[i].obj_state:SetState(1) self.equipList[i].btn_Click:SetRedPoint(false) UIUtils.SetActive(self.equipList[i].img_Upgrade, false) UTL.Item.SetAtlasSprite(self.equipList[i].img_quality, "UI_Formation", "zr_icon_pz02") self.equipInfoList[i] = nil end self.equipList[i].btn_Click:SetRedPoint(false) end end --宝石相关 self:SetEquipGemInfo() end --坐骑格子显示 function UIHeroFormationPanel:SetHorseItem(config, level) local horseComp = self.group_HorseItem UIUtils.SetImageByAssetBundle(horseComp.img_Horse, config.HorseIcon) UTL.Color.SetQualityImageByType(horseComp.img_quality, config.HorseQuality, UTL.Color.QualityType.FormationHorseTreasureEquipBg) if level and level > 0 then UIUtils.SetActive(horseComp.bg_Break, true) horseComp.txt_Break.text = "+"..level else UIUtils.SetActive(horseComp.bg_Break, false) end end function UIHeroFormationPanel:RefreshHorseInfo() local heroId = self.curHeroId local info = MDL.WarHorse.GetInfoByHeroID(heroId) self.HorseVo = info self.group_HorseItem.effect_HorseQuality:StopUIEffect() if info then self.group_HorseItem.obj_state:SetState(0) self:SetHorseItem(info.ConfigInfo, info.HorseInfo.starLevel) --战装红点 local horseEquipRedPoint = CTL.HorseEquip.CheckIfHorseEquipHasRp(info.ID) UIUtils.SetActive(self.group_HorseItem.img_Upgrade, CTL.WarHorse.CheckIfWarHorseBreak(info.ID) or CTL.HorseSoul.CheckIfHorseSoulHasRp(info.ID) or horseEquipRedPoint) self.group_HorseItem.btn_Click:SetRedPoint(CTL.WarHorse.CheckHeroHorseIfReplace(heroId, info.ID)) --品质特效 UTL.Color.PlayQualityEffect(self.group_HorseItem.effect_HorseQuality, info.ConfigInfo.HorseColorEffectID, UTL.Color.EffectType.Formation) else self.group_HorseItem.obj_state:SetState(1) self.group_HorseItem.btn_Click:SetRedPoint(CTL.WarHorse.CheckHeroHorseIfWear(self.curHeroId)) UIUtils.SetActive(self.group_HorseItem.img_Upgrade, false) UTL.Item.SetAtlasSprite(self.group_HorseItem.img_quality, "UI_Formation", "zr_icon_pz02") end end --设置宝物格子 function UIHeroFormationPanel:SetTreasureItem(config, level) local comp = self.group_TreasureItem UIUtils.SetImageByAssetBundle(comp.img_Treasure, config.TreasureIcon) UTL.Color.SetQualityImageByType(comp.img_quality, config.TreasureQuality, UTL.Color.QualityType.FormationHorseTreasureEquipBg) if level and level > 0 then UIUtils.SetActive(comp.bg_Break, true) UIUtils.SetLabel(comp.txt_Break, "+" .. level) else UIUtils.SetActive(comp.bg_Break, false) end end function UIHeroFormationPanel:RefreshTreasureInfo() local heroId = self.curHeroId local info = MDL.Treasure.GetTreasureInfoByHeroId(heroId) self.treasureInfo = info self.group_TreasureItem.effect_TreasureQuality:StopUIEffect() if info then --品质特效 UTL.Color.PlayQualityEffect(self.group_TreasureItem.effect_TreasureQuality, info.TreasureData.TreasureQualityEffect, UTL.Color.EffectType.Formation) self.group_TreasureItem.obj_state:SetState(0) self:SetTreasureItem(info.TreasureData, info.TreasureInfo.starLevel) UIUtils.SetActive(self.group_TreasureItem.img_Upgrade, CTL.Treasure.IfTreasureCanBreak(info.TreasureID) or CTL.Treasure.IfTreasureCanSoulPanel(info.TreasureID)) self.group_TreasureItem.btn_Click:SetRedPoint(CTL.Treasure.IfHasBetterTreasureToEquip(info.TreasureID)) else self.group_TreasureItem.obj_state:SetState(1) self.group_TreasureItem.btn_Click:SetRedPoint(CTL.Treasure.IfHeroHasTreasureToEquip(self.curHeroId)) UIUtils.SetActive(self.group_TreasureItem.img_Upgrade, false) UTL.Item.SetAtlasSprite(self.group_TreasureItem.img_quality, "UI_Formation", "zr_icon_pz02") end end --region ***************************** Loop scrollRect ************************* function UIHeroFormationPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Bounds then local isActive = MDL.HeroSelect.GetRelationLev(data.HeroID, data.ID) > 0 if isActive then UIUtils.SetActive(cellTable.group_Active, true) cellTable.lab_Des.text = nil UIUtils.SetLabelText(cellTable.lab_Des2,Const_IDS[data.HeroRelationName]) else UIUtils.SetActive(cellTable.group_Active, false) UIUtils.SetLabelText(cellTable.lab_Des,Const_IDS[data.HeroRelationName]) end elseif scrollRect == self.group_PassiveSkills.loop_PassiveSkills then local passiveData = DataSheetManager.DevelopEffectData:GetDataByID(data.skillId) UIUtils.SetImageByAssetBundle(cellTable.sprite_Skill, string.format(SkillPath, passiveData.Icon)) UIUtils.SetActive(cellTable.img_Appearance, not not data.isAppearancePassiveSkill) local skillName, _ = MDL.HeroStar.GetTalentNameAndDesc(data.skillId) cellTable.txt_SkillName:SetScrollSpeed(SCROLL_SPEED) cellTable.txt_SkillName:SetText(skillName) if data.isAppearancePassiveSkill then UIUtils.SetActive(cellTable.group_Level, false) UIUtils.SetActive(cellTable.group_Locked, false) elseif data.isHeroAwakenTalent then local level = data.level local isUnlock = level > 0 UIUtils.SetActive(cellTable.group_Level, isUnlock) UIUtils.SetActive(cellTable.group_Locked, not isUnlock) if not isUnlock then UIUtils.SetLabel(cellTable.txt_Unlock, UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroAwaken_TianZi)) end UIUtils.SetLabel(cellTable.txt_Lv, level) else local level = MDL.HeroStar.GetHeroTalentLevel(data.heroId, data.skillId) local isUnlock, unlockStar = CTL.HeroStar.IsDevelopEffectUnlock(data.heroId, data.skillId) UIUtils.SetActive(cellTable.group_Level, level > 0 and isUnlock) UIUtils.SetActive(cellTable.group_Locked, not isUnlock) if not isUnlock then UIUtils.SetLabel(cellTable.txt_Unlock, "+" .. unlockStar .. UIUtils.GetLocalizedTxt(Const_IDS.IDS_AssistanceFight_UnlockButton)) end UIUtils.SetLabel(cellTable.txt_Lv, level) end elseif scrollRect == self.loop_BoundsLoc then local isActive = MDL.HeroSelect.GetRelationLev(data.HeroID, data.ID) > 0 UIUtils.SetLabelText(cellTable.lab_Des,Const_IDS[data.HeroRelationName]) if isActive then cellTable.UIState:SetState(1) UIUtils.SetActive(cellTable.group_Active, true) else cellTable.UIState:SetState(0) UIUtils.SetActive(cellTable.group_Active, false) end end end function UIHeroFormationPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.group_PassiveSkills.loop_PassiveSkills then self.ActiveSkillTips:CloseAll() self.PassiveSkillTips:CloseAll() local talentType = CTL.Tips.TalentType.HeroStarTalent local extraData if data.appearanceData then talentType = CTL.Tips.TalentType.AppearanceTalent extraData = data.appearanceData elseif data.isHeroAwakenTalent then talentType = CTL.Tips.TalentType.HeroAwakenTalent extraData = {pointId = data.pointId} end CTL.Tips.OpenTalentTips(self.PassiveSkillTips, self.curHeroId, data.skillId, talentType, extraData) else self.context = { ifBlend = true, isFormation = true, isBack = true } MDL.HeroSelect.curSelectHeroID = self.curHeroId CTL.Formation.TempSelectedHeroId = self.curHeroId self:OpenHeroShowView({ ifBlend = true, isFormation = true, subViewName = MDL.HeroSelect.ToggleViewNameList.Relation, isBack = true }) end end --endregion ***************************** Loop scrollRect ************************* -- TODO 这里因为框架问题,导致子界面的时候 无法用closeView来关闭,暂时先使用父界面的 subView:CloseAll() 来关闭 function UIHeroFormationPanel:CloseSubView() self.subView:CloseAll() self.heroFilterView = nil end function UIHeroFormationPanel:HeroFilterJumpCallBack() self.context = { ifBlend = true, isFormation = true, isBack = true } CTL.Formation.TempSelectedHeroId = self.curHeroId UTL.UIRender.SetBlendTime(self.modelComponentDataHandle, 0) end --设置神兵格子 function UIHeroFormationPanel:SetDivineWeaponItem(heroId, isActive, level, isAwaken) local comp = self.group_Artifact local data = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(heroId) UTL.Color.SetQualityImageByType(comp.img_Kuang, CTL.HeroAwaken.GetWeaponQuality(heroId, isAwaken), UTL.Color.QualityType.FormationMagicWeaponBg) if isAwaken then CTL.HeroAwaken.SetWeaponItemImage(comp.img_Artifact, heroId) else local itemIcon = string.format(MDL.Bag.ItemIconPathTemplete, data.MagicWeaponPicture) UIUtils.SetImageByAssetBundle(comp.img_Artifact, itemIcon) end comp.effect_WeaponQuality:StopUIEffect() UIUtils.SetActive(self.group_Artifact.mask_Activation, not isActive) if isActive then UIUtils.SetActive(comp.bg_Break, true) if isAwaken then UIUtils.SetLabel(comp.txt_Break, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_AwakenLevelNum, level)) elseif level > 0 then comp.txt_Break.text = "+" .. level else UIUtils.SetActive(comp.bg_Break, false) end --品质特效 UTL.Color.PlayQualityEffect(comp.effect_WeaponQuality, data.EffectID, UTL.Color.EffectType.Formation) else UIUtils.SetActive(comp.bg_Break, false) end end function UIHeroFormationPanel:SetWeaponInfo(id) if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Weapon) then self.group_Artifact.gameObject:SetActive(false) return else self.group_Artifact.gameObject:SetActive(true) end local heroInfo = MDL.HeroSelect.GetHeroInfo(id) local isAwaken = MDL.HeroAwaken.GetIsWeaponAwaken(id) local level = isAwaken and MDL.HeroAwaken.GetCurWeaponStar(id) or heroInfo.magicWeaponLevel self:SetDivineWeaponItem(id, heroInfo.isMagicWeaponActive, level, isAwaken) UIUtils.SetActive(self.group_Artifact.img_Upgrade, CTL.DivineWeapon.IfDivineWeaponCanUpgrade(id)) end function UIHeroFormationPanel:UpdateHeroRelation() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroRelation) == false then self.state_Relation:SetState(0) return end self.state_Relation:SetState(1) CTL.HeroSelect.UpdateSortedRelationList(self.curHeroId, self.relationList) self.loop_Bounds:ReloadAll(self.relationList) end function UIHeroFormationPanel:UpdateHeroRelationLoc() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroRelation) == false then self.state_RelationLoc:SetState(0) return end self.state_RelationLoc:SetState(1) CTL.HeroSelect.UpdateSortedRelationList(self.curHeroId, self.relationList) self.loop_BoundsLoc:ReloadAll(self.relationList) end function UIHeroFormationPanel:UpdateUnlockBtns(funcID) if funcID == MDL.Unlock.FunctionType.AssistanceFight then UIUtils.SetActive(self.btn_AssistanceFight, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.AssistanceFight)) self.btn_AssistanceFight:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation_AssistFight)) elseif funcID == MDL.Unlock.FunctionType.GodBeast then UIUtils.SetActive(self.btn_GodBeast, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GodBeast)) self.btn_GodBeast:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation_GodBeast)) elseif funcID == MDL.Unlock.FunctionType.Pet then UIUtils.SetActive(self.btn_Pet, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Pet)) self.btn_Pet:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation_Pet)) end end function UIHeroFormationPanel:UpdateUnlockBtnRP() self.btn_AssistanceFight:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation_AssistFight)) self.btn_GodBeast:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation_GodBeast)) end function UIHeroFormationPanel:OpenHeroShowView(viewContext) UTL.UIRender.SetBlendTime(self.modelComponentDataHandle, 0) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroShowPanel, viewContext) end function UIHeroFormationPanel:GetModelParent(modelPath) local parent = UnityEngine.GameObject.Find("EMPTY_GAME_OBJECT") if parent == nil then parent = UnityEngine.GameObject.Find(modelPath) end return parent end function UIHeroFormationPanel:RefreshStratagemInfo() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Stratagem) then UIUtils.SetActive(self.btn_StratagemSetting, true) self.btn_StratagemSetting:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation_Stratagem)) else UIUtils.SetActive(self.btn_StratagemSetting, false) end end function UIHeroFormationPanel:AuxUtilPlayPsEffect(effectPath) return UTL.UIRender.PlayPsEffect(self.modelComponentDataHandle, effectPath) end return UIHeroFormationPanel