local UIPCSelectHeroView = UIViewClass() --UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIPCSelectHeroView, nil, "AnchorCustomized/UIAnchorCustomizedFormation") function UIPCSelectHeroView:OnOpened(context) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.BossFormation) local bgTexturePath = ConstAssetPathConfig.bgTexturePath local Common2DScenePrefab = ConstAssetPathConfig.Common2DScenePrefab UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, Common2DScenePrefab, 1600, 0, 1600, bgTexturePath, false) self.lineUpHeroIds = CTL.PCGameStreamer.GetLineupHeroesId() self:RefreshRightFormationHeroes() for i, v in ipairs(self.group_BuffInfos) do UIUtils.SetActive(v.gameObject, false) end for i, v in ipairs(self.group_Skills) do UIUtils.SetActive(v.gameObject, false) end UIUtils.SetActive(self.obj_Country.gameObject, false) UIUtils.SetActive(self.obj_Profession.gameObject, false) self.allHeroList = {} for i, v in DataSheetManager.HeroNum:GetEnumerator() do if MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Hero, v.ID) then -- 屏蔽金将判断 table.insert(self.allHeroList, v.ID) end end local f = function(idA, idB) local heroDataA = DataSheetManager.HeroNum:GetDataByID(idA) local heroDataB = DataSheetManager.HeroNum:GetDataByID(idB) if heroDataA.HeroQuality ~= heroDataB.HeroQuality then return heroDataA.HeroQuality > heroDataB.HeroQuality --1.按品质排序 else return idA < idB --4.按ID排序 end end table.sort(self.allHeroList, f) --插入觉醒武将 for _, v in DataSheetManager.AwakenHeroNum:GetEnumerator() do for i, heroId in ipairs(self.allHeroList) do if heroId == v.ID then table.insert(self.allHeroList, i, CTL.HeroAwaken.EncodeHeroId(heroId)) break end end end self.loopScroll_BossFormationHero:ReloadAll(self.allHeroList) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_ZhuBo_EntryName3) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self:RefreshHeroInfo(self.lineUpHeroIds[1]) end function UIPCSelectHeroView:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end function UIPCSelectHeroView:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Challenge then if table.containValue(self.lineUpHeroIds, 0 ) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ZhuBo_BattleWarning"]) else CTL.PCGameStreamer.SetLineupHeroesId(self.lineUpHeroIds) self:CloseView(true) end else for index, cell in ipairs(self.group_Skills) do if comp == cell.btn_Skill then CTL.Tips.OpenHeroSkillTipsPreview(true, self.SkillTips, self.curHeroId, self.skillList[self.currentSkillGroupIndex][index]) return end end for i, v in ipairs(self.group_RightHero) do if comp == v.btn_FormationHero then local heroId = self.lineUpHeroIds[i] self.lineUpHeroIds[i] = 0 print(self.lineUpHeroIds) self:RefreshRightFormationHeroes() for i, id in ipairs(self.allHeroList) do if id == heroId then self.loopScroll_BossFormationHero:UpdateIndex(i - 1) return end end end end end end function UIPCSelectHeroView:OnCellSelect(scrollRect, index, cellTable, data) end function UIPCSelectHeroView:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loopScroll_BossFormationHero then UTL.Item.SetHeroIconByHeroId(cellTable.img_HeroHead, CTL.HeroAwaken.DecodeHeroId(data)) for i, v in ipairs(cellTable.group_Buffs) do UIUtils.SetActive(v, false) end local heroId = CTL.HeroAwaken.DecodeHeroId(data) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UIUtils.SetLabelText(cellTable.txt_HeroName, Const_IDS[heroData.NameIDS]) UIUtils.SetActive(cellTable.group_select, table.containValue(self.lineUpHeroIds, data)) UIUtils.SetActive(cellTable.img_TestBg, false) UIUtils.SetActive(cellTable.img_Free, false) UIUtils.SetActive(cellTable.img_experience, false) end end function UIPCSelectHeroView:OnCellClicked(scrollRect, index, cellTable, target, data) local isNotFull = false if scrollRect == self.loopScroll_BossFormationHero then if table.containValue(self.lineUpHeroIds, data) then for i, v in ipairs(self.lineUpHeroIds) do if v == data then self.lineUpHeroIds[i] = 0 isNotFull = true UIUtils.SetActive(cellTable.group_select, false) break end end else for i, v in ipairs(self.lineUpHeroIds) do if v == 0 then self.lineUpHeroIds[i] = data isNotFull = true UIUtils.SetActive(cellTable.group_select, true) break end end end if isNotFull then self:RefreshHeroInfo(data) self:RefreshRightFormationHeroes() else CTL.Tips.AddTipsMsg(Const_IDS["IDS_BossChallenge_ChooseHero_FullHero"]) end end end function UIPCSelectHeroView:RefreshHeroInfo(heroId) self.curHeroId = heroId self.currentSkillGroupIndex = 1 --重置技能组索引 UIUtils.SetActive(self.group_Bottom.gameObject, true) UIUtils.SetActive(self.group_MidInfo.gameObject, true) UIUtils.SetActive(self.group_UnHero.gameObject, false) local _heroId = CTL.HeroAwaken.DecodeHeroId(heroId) self:RefreshHeroSkills(_heroId) self:RefreshHeroBasicInfos(_heroId) self:RefreshHeroModel(heroId) end local SkillPath = ConstAssetPathConfig.SkillImagePath function UIPCSelectHeroView:RefreshHeroSkills(heroId) self.skillList = MDL.HeroSelect.GetHeroDisplaySkillIdList(heroId,true) --多套技能显示切换展示按钮 UIUtils.SetActive(self.btn_Change, #self.skillList > 1) for index, cell in ipairs(self.group_Skills) do local skillId = self.skillList[self.currentSkillGroupIndex][index] local skillIcon local skillData = (skillId and skillId>0) and DataSheetManager.SkillTipsData:GetDataByID(skillId) or nil if skillData then skillIcon = skillData.SkillIcon UIUtils.SetActive(cell.gameObject, true) UIUtils.SetImageByAssetBundle(cell.img_Skill, string.format(SkillPath, skillIcon)) else UIUtils.SetActive(cell.gameObject, false) end end end function UIPCSelectHeroView:RefreshHeroBasicInfos(heroId) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UIUtils.SetLabelText(self.txt_HeroName, Const_IDS[heroData.NameIDS]) -- 武将国别 CTL.HeroSelect.SetHeroCountry(heroId, self.obj_Country) -- 武将职业 CTL.HeroSelect.SetHeroProfession(heroId, self.obj_Profession, true) UIUtils.SetActive(self.obj_Country.gameObject, true) UIUtils.SetActive(self.obj_Profession.gameObject, true) for i, v in ipairs(self.group_BuffInfos) do UIUtils.SetActive(v.gameObject, false) end end function UIPCSelectHeroView:RefreshHeroModel(heroId) local heroId, isAwaken = CTL.HeroAwaken.DecodeHeroId(heroId) --加载新模型之前先卸载之前的模型 UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) if isAwaken then local awakenHeroData = DataSheetManager.AwakenHeroNum:GetDataByID(heroId) local heroData = DataSheetManager.HeroAppearance:GetDataByID(awakenHeroData.HeroAppearance) local monsterData = DataSheetManager.MonsterModelData:GetDataByID(heroData.PreviewModel) UTL.UIRender.CreatePlayerModel(self.modelComponentDataHandle, heroId, monsterData.Path, nil, true, monsterData.ModelPsEffect, awakenHeroData.WeaponAppearance) else UTL.UIRender.CreatePlayerModel(self.modelComponentDataHandle, heroId, nil, nil, true) end UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0.16, -1.2, 0) UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -10, 0) end function UIPCSelectHeroView:RefreshRightFormationHeroes() for i, v in ipairs(self.group_RightHero) do local heroId = self.lineUpHeroIds[i] local cell = self.group_RightHero[i] logging.log(LTAG.LOG,">>>>>>>>>", heroId) if heroId and heroId > 0 then UTL.Item.SetHeroIconByHeroId(cell.img_HeroHead, CTL.HeroAwaken.DecodeHeroId(heroId)) UIUtils.SetActive(cell.group_FormationHero, true) UIUtils.SetActive(cell.img_Empty, false) else UIUtils.SetActive(cell.group_FormationHero, false) UIUtils.SetActive(cell.img_Empty, true) end end end return UIPCSelectHeroView