local UIGoldenHeroPreview = UIViewClass() local SCROLL_SPEED = 0.6 -- 武将技能滚动速度 local SkillPath = ConstAssetPathConfig.SkillImagePath function UIGoldenHeroPreview:OnOpened(context) self:RegistSystemEvent(EventID.UI_UpdateServerDay, self.RefreshUI) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.OnFunctionUnlockUpdate) self:InitPreview() end function UIGoldenHeroPreview:OnFunctionUnlockUpdate(id, state) if id == MDL.Unlock.FunctionType.GoldHeroPreview then if not state then self:CloseView() end end end function UIGoldenHeroPreview:OnButtonClicked(comp) if comp == self.btn_Close then CTL.PushInterface.HidePushInterface(self.__viewClassPath) self:CloseView() end end function UIGoldenHeroPreview:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_GoldenHeroPreviewSkills then self:RefreshSkillIconShow(cellTable, self.goldHeroData.SynergyBossHeroID, data, false) elseif scrollRect == self.loop_GoldenHeroPreviewPassiveSkills then local passiveData = DataSheetManager.DevelopEffectData:GetDataByID(data.skillId) UIUtils.SetImageByAssetBundle(cellTable.sprite_Skill, string.format(SkillPath, passiveData.Icon)) UIUtils.SetActive(cellTable.img_Appearance, data.isAppearancePassiveSkill) if data.isAppearancePassiveSkill then UIUtils.SetActive(cellTable.group_Locked, false) local skillName, _ = MDL.HeroStar.GetTalentNameAndDesc(data.appearanceData.TalentID) cellTable.txt_SkillName:SetScrollSpeed(SCROLL_SPEED) cellTable.txt_SkillName:SetText(skillName) else local skillName, _ = MDL.HeroStar.GetTalentNameAndDesc(data.skillId) cellTable.txt_SkillName:SetScrollSpeed(SCROLL_SPEED) cellTable.txt_SkillName:SetText(skillName) end end end function UIGoldenHeroPreview:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_GoldenHeroPreviewSkills then self.ActiveSkillTips:CloseAll() self.PassiveSkillTips:CloseAll() CTL.Tips.OpenHeroSkillTipsPreview(true, self.ActiveSkillTips, self.goldHeroData.SynergyBossHeroID, data) elseif scrollRect == self.loop_GoldenHeroPreviewPassiveSkills then self.ActiveSkillTips:CloseAll() self.PassiveSkillTips:CloseAll() CTL.Tips.OpenTalentTipsPreview(true, self.PassiveSkillTips, self.goldHeroData.SynergyBossHeroID, data.skillId, data.appearanceData) end end function UIGoldenHeroPreview:InitPreview() self.previewData = MDL.GoldHeroPreview.GetOpenGoldenHeroPreviewData() self.goldHeroData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.previewData.GoldHeroType) local heroID = self.goldHeroData.SynergyBossHeroID local heroData = DataSheetManager.HeroNum:GetDataByID(heroID) self:SetTime() self:StartRepeatFunc(self.SetTime, 1, -1) UIUtils.SetLabelText(self.group_TitleName, Const_IDS[self.goldHeroData.LevelName]) UIUtils.SetImageByAssetBundle(self.img_HeroShow, self.previewData.VerticalPainting) local pos = self.previewData.VerticalPaintingCoordinate self.img_HeroShow.transform:SetAnchoredPosition(pos[1], pos[2]) self.img_HeroShow:SetNativeSize() UIUtils.SetImageByAssetBundle(self.img_HeroShow, self.previewData.VerticalPainting) if Localization.IsAllChinese() or Localization.IsJapanese() then self.loc_Slogan:SetState(0) UIUtils.SetLocalizationImage(self.img_Slogan, self.previewData.Definition) else self.loc_Slogan:SetState(1) local des = self.previewData.DefinitionDes for i, v in ipairs(self.group_SloganDes) do UIUtils.SetLabelText(v, Const_IDS[des[i]]) end end if GameAppInfo.IsChinesePackage() then UIUtils.SetLabelText(self.group_CN.txt_CVName, Const_IDS[heroData.CVCN]) UIUtils.SetActive(self.group_CN.group_CV, true) elseif GameAppInfo.IsJapanesePackage() then UIUtils.SetLabelText(self.group_Loc.txt_CVName, Const_IDS[heroData.CVJP]) UIUtils.SetActive(self.group_Loc.group_CV, true) else UIUtils.SetActive(self.group_CN.group_CV, false) UIUtils.SetActive(self.group_Loc.group_CV, false) end local professionData = DataSheetManager.HeroProfession:GetDataByID(heroData.TypeID) if self.loc_Name.CurState == 0 then -- state = 0 国服使用图片,state = 1 海外使用多语言文字,不放在判断内会报错。 UIUtils.SetLocalizationImage(self.group_CN.img_Name, self.previewData.NameCard) UIUtils.SetLocalizationImage(self.group_CN.img_Country, "country_" .. heroData.Kingdom .. ".png") UIUtils.SetLocalizationImage(self.group_CN.img_Profession, professionData.IconWords) self.group_CN.txt_Qua.text = heroData.HeroIntelligence else UIUtils.SetLabelText(self.group_Loc.txt_Name, Const_IDS[heroData.NameIDS]) UIUtils.SetLocalizationImage(self.group_Loc.img_Country, "country_" .. heroData.Kingdom .. ".png") UIUtils.SetLocalizationImage(self.group_Loc.img_Profession, professionData.IconWords) self.group_Loc.txt_Qua.text = heroData.HeroIntelligence end -- 技能 self.loop_GoldenHeroPreviewSkills:ClearCells() self.activeSkillList = MDL.HeroSelect.GetHeroDisplaySkillIdList(heroID) for k,v in ipairs(self.activeSkillList[1]) do self.loop_GoldenHeroPreviewSkills:AddData(v, 0) end -- 武将天赋 self.loop_GoldenHeroPreviewPassiveSkills:ClearCells() self.passiveSkillList = MDL.HeroStar.GetCurrentDevelopEffectIdTableByHeroId(heroID) self.attrAppearanceWearID = MDL.HeroSelect.GetAttrAppearanceIDByHeroID(heroID) if self.attrAppearanceWearID > 0 then local appearanceData = DataSheetManager.HeroAppearance:GetDataByID(self.attrAppearanceWearID) if appearanceData.TalentID > 0 then self.loop_GoldenHeroPreviewPassiveSkills:AddData({heroId = heroID, skillId = appearanceData.TalentID, isAppearancePassiveSkill = true, appearanceData = appearanceData}, 0) end end for k,v in ipairs(self.passiveSkillList) do self.loop_GoldenHeroPreviewPassiveSkills:AddData({heroId = heroID, skillId = v, isAppearancePassiveSkill = false}, 0) end end function UIGoldenHeroPreview:SetTime() local offsetDay = self.previewData.EndDay - 1 - MDL.Player.GetPersonalServerDayCount() local timeText UIUtils.SetActive(self.text_Time, true) if offsetDay > 0 then timeText = string.FormatByIdsKey("IDS_Item_Time_Day", offsetDay) elseif offsetDay == 0 then local time = UTL.Time.GetServerIntervalTimeToRefresh(1) if time >= UTL.Time.TotalSecondsOneHour then timeText = string.FormatByIdsKey("IDS_Item_Time_Hour", math.floor(time / UTL.Time.TotalSecondsOneHour)) elseif time >= 0 then timeText = os.date(UTL.Time.FormatDateEnum.MS, time) else self:CloseView() return end else self:CloseView() return end self.text_Time.text = string.FormatByIdsId(Const_IDS.IDS_GoldGeneralPreview_Open, timeText) end function UIGoldenHeroPreview:RefreshUI() self.previewData = MDL.GoldHeroPreview.GetOpenGoldenHeroPreviewData() if not self.previewData then self:CloseView() end end function UIGoldenHeroPreview:RefreshSkillIconShow(cell, heroId, skillId) local skillIcon, skillTips local isLock,currentSkillId,currentSkillLevel = MDL.HeroSelect.GetSkillTipsOfCurrentLevel(heroId,skillId) local skillData = DataSheetManager.SkillTipsData:GetDataByID(currentSkillId) if skillData then skillIcon = skillData.SkillIcon skillTips = skillData.SkillFuncType end UIUtils.SetImageByAssetBundle(cell.sprite_Skill, string.format(SkillPath, skillIcon)) UIUtils.SetLabelText(cell.txt_SkillType, Const_IDS[skillTips]) end return UIGoldenHeroPreview