local UIBossChallengeFormation = require "View/FairPlay/BossChallenge/UIBossChallengeFormation"; local UISubjectMonthChallengeFormation = UIViewClass(UIBossChallengeFormation) function UISubjectMonthChallengeFormation:Init(context) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.bossId = context.bossId self.activityId = MDL.SubjectMonth.GetActivityId() MDL.FairPlay.FairGetFixAttrReq(MDL.FairPlay.FairPlayType.Boss) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title,Const_IDS.IDS_BossChallenge_ChooseHero_Title) self.currentSkillGroupIndex = 1 --当前显示的技能组索引 self:RegistDragEvent() self:RegistSystemEvent(EventID.UI_FairPlay_RefreshHeroFixedInfo, self.RefreshHeroFixedInfo) self.buffTable = {} self.heroList = {} local heroList = MDL.HeroSelect.GetHasHeroList() for i, v in ipairs(heroList) do table.insert(self.heroList, v) end self.effectResult = nil local sort = function (a, b) local infA = CTL.MonthBossChallenge.GetBossLevelBuffInfluenceNumbers(self.bossId, a.heroId) local infB = CTL.MonthBossChallenge.GetBossLevelBuffInfluenceNumbers(self.bossId, b.heroId) if infA ~= infB then return infA > infB else return a.heroId < b.heroId end end self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.BossFormation) table.sort(self.heroList, sort) CTL.HeroAwaken.TryFillAwakenHeroData(self.heroList, false) --1. 初始化武将出阵 self.formationHeroIdList = CTL.MonthBossChallenge.LoadBossFormation(self.bossId) or {0, 0, 0, 0, 0, 0} --2. 首次打开界面加载武将优化策略 self:LoadHeroModelOnEnter() self.btn_Challenge:SetText(Const_IDS.IDS_ClimbTower_Start) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Hero_Choose) self:RefreshRightFormationHeroes() self:RefreshLeftHeroScroll() UIUtils.SetActive(self.group_card, false) end function UISubjectMonthChallengeFormation:OnClickChallenge() for i, v in ipairs(self.formationHeroIdList) do if v == 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_BossChallenge_ChooseHero_LackHero"]) return end end MDL.MonthBossChallenge.EnterBossChallengeRequest(self.bossId, self.formationHeroIdList) end function UISubjectMonthChallengeFormation:Closed() UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) CTL.MonthBossChallenge.SaveBossFormation(self.bossId, self.formationHeroIdList) UIManager.ActiveUIModle(true, "UIBossChallengeFormation") if self.effectResult then self.effectResult:Dispose() self.effectResult = nil end end function UISubjectMonthChallengeFormation:RefreshHeroBasicInfos(heroId) local isAwaken heroId, isAwaken = CTL.HeroAwaken.DecodeHeroId(heroId) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) if isAwaken then self.txt_HeroName.text = string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_Awaken, UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS])) else UIUtils.SetLabelText(self.txt_HeroName, Const_IDS[heroData.NameIDS]) end -- 武将国别 CTL.HeroSelect.SetHeroCountry(heroId, self.obj_Country) -- 武将职业 CTL.HeroSelect.SetHeroProfession(heroId, self.obj_Profession, true) local bossLevelData = CTL.MonthBossChallenge.GetLevelCfg(self.bossId) local buffTable = bossLevelData.BuffID for i, v in ipairs(buffTable) do local iconPath = DataSheetManager.BuffData:GetDataByBuffID(v).BuffIcon UIUtils.SetImageByAssetBundle(self.group_BuffInfos[i].gameObject:GetComponent(typeof(Image)), iconPath) if CTL.BossChallenge.IsHeroBenefitBuffByBuffId(v, heroId) then self.group_BuffInfos[i]:SetGray(false) else self.group_BuffInfos[i]:SetGray(true, true) end end end function UISubjectMonthChallengeFormation:SetBasicHeroCell(cell, heroId) local id, isAwaken = CTL.HeroAwaken.DecodeHeroId(heroId) UTL.Item.SetHeroIconByHeroId(cell.img_HeroHead, id, isAwaken) local influenceList = CTL.MonthBossChallenge.GetBossLevelBuffInfluenceList(self.bossId, id) local bossLevelData = CTL.MonthBossChallenge.GetLevelCfg(self.bossId) local buffTable = bossLevelData.BuffID for i, v in ipairs(cell.group_Buffs) do if influenceList[i] then UIUtils.SetImageByAssetBundle(v, DataSheetManager.BuffData:GetDataByBuffID(buffTable[i]).BuffIcon) UIUtils.SetActive(v, true) else UIUtils.SetActive(v, false) end end end function UISubjectMonthChallengeFormation:OnButtonClicked(comp) if comp == self.btn_Challenge then self:OnClickChallenge() CTL.Sound.PlayGameSound("UI_sound_Attack") elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.MonthBossChallenge, params = {[1] = CTL.MonthBossChallenge.GetRankSettlementTime()} }) elseif comp == self.obj_Country.btn_Country then if self.curHeroId then local id, isAwaken = CTL.HeroAwaken.DecodeHeroId(self.curHeroId) UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFilterView, {canJump = false, heroId = id, isCountry = true, heroFilterPos = self.obj_HeroFilterPos}) end elseif comp == self.obj_Profession.btn_Profession then if self.curHeroId then local id, isAwaken = CTL.HeroAwaken.DecodeHeroId(self.curHeroId) UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFilterView, {canJump = false, heroId = id, isCountry = false, heroFilterPos = self.obj_HeroFilterPos}) end elseif comp == self.btn_Change then --切换技能显示 self.currentSkillGroupIndex = self.currentSkillGroupIndex + 1 if self.currentSkillGroupIndex > #self.skillList then self.currentSkillGroupIndex = 1 end self:RefreshHeroSkills(self.curHeroId) else for i, v in ipairs(self.group_RightHero) do if comp == v.btn_FormationHero then if self.dragItemId and self.dragItem then self.dragIndex = nil self.dragItemId = nil if self.dragItem then GameObject.Destroy(self.dragItem) self.dragItem = nil end return end local heroId = self.formationHeroIdList[i] local loopIndex = MDL.Array.GetIndexCellByList(self.formationHeroIdList[i], self.heroList) self.formationHeroIdList[i] = 0 self:RefreshSingleHeroCell(i) self.loopScroll_BossFormationHero:UpdateIndex(loopIndex - 1) self:OnClickHeroItem(heroId) return end end for index, cell in ipairs(self.group_Skills) do if comp == cell.btn_Skill then local id, isAwaken = CTL.HeroAwaken.DecodeHeroId(self.curHeroId) CTL.Tips.OpenHeroSkillTipsPreview(true, self.SkillTips, id, self.skillList[self.currentSkillGroupIndex][index], isAwaken) return end end for i, v in ipairs(self.group_BuffInfos) do if comp == v then CTL.Tips.CloseSkillTips(self.SkillTips) local buffId = CTL.MonthBossChallenge.GetLevelCfg(self.bossId).BuffID[i] CTL.Tips.OpenSkillTips(buffId, self.SkillTips, CTL.Tips.SkillType.ConstantBuff) end end end end function UISubjectMonthChallengeFormation:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end return UISubjectMonthChallengeFormation