local UIHeroExpression = UIViewClass() local NameAppearAnim = "NameAppear" function UIHeroExpression:OnOpened(context) self:InitParams(context) self:ShowHeroExpression() UIManager.ActiveUIModle(false, "UIHeroExpression") CTL.Setting.SetUIShadowDistance(8) CTL.Setting.Set5SSkin(true) end function UIHeroExpression:InitParams(context) self.heroId = context.heroId self.appearanceId = context.appearanceId self.isCanSkip = context.isCanSkip self.callBack = context.callBack self.callBackParam = context.callBackParam end function UIHeroExpression:ShowHeroExpression() self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.heroSelect) local heroData = DataSheetManager.HeroNum:GetDataByID(self.heroId) self.drawCardSkipCD = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("DrawCardSkipCD").FloatValue) self.timelineEndTime = heroData.DrawNameTime UIUtils.SetActive(self.group_HeroIntro, false) UIUtils.SetActive(self.group_Turn, false) UIUtils.SetActive(self.event_ClickCount, self.isCanSkip) UIUtils.SetActive(self.event_Skip, false) UIUtils.SetLabel(self.txt_fragment, heroData.WreckPiece) local heroConfig = MDL.HeroSelect.GetHeroDataById(self.heroId) if self.appearanceId then local tlPath, modelPath, weaponId, isDy = UTL.UIRender.GetHeroTimelineParam(self.heroId, self.appearanceId, CTL.HeroSelect.GetWeaponAppearanceId(self.heroId, self.appearanceId)) if isDy then UTL.UIRender.CreateDynamicHeroTimeline(self.modelComponentDataHandle, tlPath, modelPath, self.appearanceId, weaponId, 0, 1600, 0) else UTL.UIRender.CreateHeroTimelineTrans(self.modelComponentDataHandle, tlPath, 0, 1600, 0) end local appearanceIntelligence = DataSheetManager.HeroAppearance:GetDataByID(self.appearanceId) if appearanceIntelligence and appearanceIntelligence.Intelligence > 0 then self.txt_Intelligence.text = appearanceIntelligence.Intelligence else self.txt_Intelligence.text = heroData.HeroIntelligence end self.soundId = CTL.Sound.PlayGameSound(appearanceIntelligence.ShowSound) else UTL.UIRender.CreateHeroTimelineTrans(self.modelComponentDataHandle, UTL.UIRender.LoadSelectHero(self.heroId, false), 0, 1600, 0) self.txt_Intelligence.text = heroData.HeroIntelligence self.soundId = CTL.Sound.PlayGameSound(heroConfig.ShowSound) end CTL.HeroSelect.SetHeroName(self.heroId, self.loc_Name, self.img_Name, self.txt_Name) if self.loc_Name.CurState == 0 then UIUtils.SetLocalizationImage(self.img_Country,"country_".. heroConfig.Kingdom..".png") local heroName = UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS]) local count = UTL.String.GetStrCharCount(heroName, 1) self.uistate:SetState(count - 2) -- 组件从2个字名字开始放位置 else UIUtils.SetLocalizationImage(self.img_CountryEn,"country_".. heroConfig.Kingdom..".png") end -- 设置职业 CTL.HeroSelect.SetHeroProfession(self.heroId, self.obj_Profession, false) CTL.HeroSelect.ShowCV(self.txt_CV, self.heroId) self:StartRepeatFunc(self.OnUpdateFun, 0.03) AuxUtil.SetSSSCameraClipParams(true, 0.3, 750) end function UIHeroExpression:OnUpdateFun(deltaTime, timeSinceUpdate) if timeSinceUpdate >= self.timelineEndTime and not self.nameAppearAnim then UIUtils.SetActive(self.group_HeroIntro, true) UIUtils.SetActive(self.group_Turn, self.isCanSkip) self.nameAppearAnim = self:PlayUIAnimation(NameAppearAnim) elseif timeSinceUpdate >= self.timelineEndTime + self.drawCardSkipCD then UIUtils.SetActive(self.event_ClickCount, false) UIUtils.SetActive(self.event_Skip, true) self:StopRepeatFunc(self.OnUpdateFun) end end function UIHeroExpression:OnButtonClicked(comp) if comp == self.event_Skip then if self.callBack then self.callBack(self.callBackParam) end self:CloseView(true) elseif comp == self.event_ClickCount then UIUtils.SetActive(self.event_ClickCount, false) UIUtils.SetActive(self.event_Skip, true) end end function UIHeroExpression:OnClosed() CTL.Setting.SetUIShadowDistance(0) UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) AuxUtil.SetSSSCameraClipParams(false, 1, 750) CTL.Setting.Set5SSkin(false) UIManager.ActiveUIModle(true, "UIHeroExpression") if self.soundId then CTL.Sound.StopById(self.soundId) end end ----------------------------------------------------------------------------------- return UIHeroExpression