local UIRogueSelectHeroPanel = UIViewClass() local SkillImagePath = ConstAssetPathConfig.SkillImagePath local Common2DScenePrefab = ConstAssetPathConfig.Common2DScenePrefab local bgTexturePath = ConstAssetPathConfig.bgTexturePath function UIRogueSelectHeroPanel:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_FairPlayReplay_HeroChoose) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.heroShow) UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, Common2DScenePrefab, 1600, 0, 1600, bgTexturePath, false) self:RefreshSelectList() self.loopscroll_Head:SelectIndex(0) end function UIRogueSelectHeroPanel:RefreshSelectList() if self.loopscroll_Head.Count > 0 then self.loopscroll_Head:ClearCells() end for _, v in DataSheetManager.RogueHeroData:GetEnumerator() do self.loopscroll_Head:AddData(v, 0) end end function UIRogueSelectHeroPanel:ShowHeroModel(heroId) UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0.16,-1.2,0) -- 设置模型位移信息 UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -10, 0) -- 设置模型位移信息 UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -10, 0) -- 设置模型位移信息 local modelPath, equipTable, modelScale, lightPath, heroEffectPath, heroLightEffects = UTL.UIRender.LoadShowHero(heroId, false, nil, true) UTL.UIRender.CreatePlayerModel(self.modelComponentDataHandle, heroId, modelPath, lightPath, true) if not self.effectResult then self.effectResult = CTL.FairPlay.CreateFogEffectInScene(UTL.UIRender.GetModelRootTrans(self.modelComponentDataHandle)) end end function UIRogueSelectHeroPanel: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_ChooseHero then UIManager.OpenView(Const_UI_Lua.UIEnum.UIRogueSelectLevelPanel, {heroId = self.selectedHeroId}, "LevelSelect/UILevelSelectChapterPanel") end end function UIRogueSelectHeroPanel:OnCellInit(scrollRect, index, cellTable, data) local heroId = data.HeroID UIUtils.SetActive(cellTable.img_Experience, CTL.FairPlayCard.IsUsedExperienceCard(heroId)) UIUtils.SetActive(cellTable.img_TestBg, false) UIUtils.SetActive(cellTable.img_FreeBg, false) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UTL.Item.SetHeroIconByHeroId(cellTable.img_Head, heroId) UIUtils.SetLabelText(cellTable.lab_Name, Const_IDS[heroData.NameIDS]) if self.mainHeroSelectId == heroId or self.viceHeroSelectId == heroId then UIUtils.SetActive(cellTable.img_BeSelected.gameObject, true) UIUtils.SetActive(cellTable.group_FriendSelected.gameObject, false) elseif self.role1SelectMainId == heroId or self.role1SelectViceId == heroId or self.role2SelectMainId == heroId or self.role2SelectViceId == heroId then UIUtils.SetActive(cellTable.group_FriendSelected.gameObject, true) UIUtils.SetActive(cellTable.img_BeSelected.gameObject, false) else UIUtils.SetActive(cellTable.group_FriendSelected.gameObject, false) UIUtils.SetActive(cellTable.img_BeSelected.gameObject, false) end end function UIRogueSelectHeroPanel:OnCellClicked(scrollRect, index, cellTable, target, data) local heroId = data.HeroID self.selectedHeroId = heroId self:ShowHeroModel(heroId) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UIUtils.SetLocalizationImage(self.img_Name, "UI_HeroName/" .. heroData.HeadImage .. ".png") UIUtils.SetLocalizationImage(self.img_Country, "country_" .. heroData.Kingdom .. ".png") CTL.HeroSelect.SetHeroProfession(heroId, self.obj_Profession, false) local skillDataCfg = DataSheetManager.RogueSkillData:GetDataBySkillID(data.SkillID) UIUtils.SetImageByAssetBundle(self.icon_Skill, string.format(SkillImagePath, skillDataCfg.SkillIcon)) UIUtils.SetLabelText(self.txt_skillinfo, Const_IDS[data.SkillIDS]) UIUtils.SetLabelText(self.txt_buffinfo, Const_IDS[data.BuffIDS]) end function UIRogueSelectHeroPanel:OnClosed() UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end return UIRogueSelectHeroPanel