local UITalentSkillTips = UIViewClass() local SkillIconPath = ConstAssetPathConfig.SkillImagePath local TalentTipsPositionX = -100 local TalentTipsPositionY = 200 function UITalentSkillTips:OnOpened(context) local viewTf = self.group_TalentSkillInfo.transform.parent viewTf:SetParent(context.parentTf) viewTf:SetAnchoredPosition(TalentTipsPositionX, TalentTipsPositionY) self.state_Icon:SetState(0) self.txt_Lv = self.group_Square.txt_Lv self.group_Level = self.group_Square.group_Level self.img_Talent = self.group_Square.img_Talent self.group_Locked = self.group_Square.group_Locked self:RefreshTalentSkillInfo(context) end function UITalentSkillTips:RefreshTalentSkillInfo(context) if context.talentType == CTL.Tips.TalentType.AppearanceTalent then UIUtils.SetActive(self.group_LockInfo, false) UIUtils.SetActive(self.group_Level.gameObject, false) self:RefreshAppearanceTalentInfo(context.extraData) elseif context.talentType == CTL.Tips.TalentType.HeroAwakenTalent then self:RefreshHeroAwakenTalentInfo(context.heroId, context.extraData.pointId) else UIUtils.SetActive(self.group_LockInfo, true) UIUtils.SetActive(self.group_Level.gameObject, true) self:RefreshTalentInfo(context.heroId, context.talentId) end end function UITalentSkillTips:RefreshAppearanceTalentInfo(appearanceData) local passiveData = DataSheetManager.DevelopEffectData:GetDataByID(appearanceData.TalentID) UIUtils.SetActive(self.group_Locked.gameObject, false) UIUtils.SetActive(self.group_LockCondition.gameObject, false) UIUtils.SetActive(self.group_LevelUpHint.gameObject, false) UIUtils.SetActive(self.scroll_Talent, false) UIUtils.SetImageByAssetBundle(self.img_Talent, string.format(SkillIconPath, passiveData.Icon)) local name, desc = MDL.HeroStar.GetTalentNameAndDesc(appearanceData.TalentID) UIUtils.SetLabel(self.txt_TalentName, name) UIUtils.SetLabel(self.txt_TalentDes, desc) self:RefreshTalentTypeTag({{DisplayPic=ConstAssetPathConfig.Path41, DisplayIDs="IDS_TalentSkill_TypeText1"}}) end --武将觉醒天赋 function UITalentSkillTips:RefreshHeroAwakenTalentInfo(heroId, pointId) local talentList = {} local maxLevel = 0 local talentId local level = MDL.HeroAwaken.GetSkillLevel(heroId, 0, pointId) for i, v in DataSheetManager.HeroAwakenTalent:GetDataByHeroID_PointId_PointLevel(heroId, pointId) do if i == 1 then local name, desc = MDL.HeroStar.GetTalentNameAndDesc(v.TalentID) self.txt_TalentName.text = name self.txt_TalentDes.text = desc end if v.PointLevel > maxLevel then maxLevel = v.PointLevel end table.insert(talentList, v.TalentID) if not talentId then talentId = v.TalentID end end self.txt_Lv.text = level local isLock = level == 0 UIUtils.SetActive(self.group_Level, not isLock) UIUtils.SetActive(self.group_LockCondition.gameObject, isLock) UIUtils.SetActive(self.group_Locked.gameObject, isLock) UIUtils.SetActive(self.group_LevelUpHint.gameObject, not isLock) local passiveData = DataSheetManager.DevelopEffectData:GetDataByID(self.context.talentId) UIUtils.SetImageByAssetBundle(self.img_Talent, string.format(SkillIconPath, passiveData.Icon)) self.state_DesLock:SetState(isLock and 0 or 1) if isLock then UIUtils.SetLabelText(self.txt_LockInfo, Const_IDS.IDS_HeroAwaken_ThroughTianZi) elseif level < maxLevel then UIUtils.SetLabelText(self.txt_LevelUpHint, Const_IDS.IDS_HeroAwaken_ThroughTianZi) else UIUtils.SetLabelText(self.txt_LevelUpHint, Const_IDS.IDS_HeroAwaken_TianZiLevelMax) end local talentData = MDL.HeroStar.GetHeroTalentDataByTalentId(heroId, talentId) self:RefreshTalentTypeTag(talentData.Display_Table) self:RefreshTalentLevelList(heroId, talentList, level) if level > 1 then self.loop_TalentSkill:MoveIndex(level - 2) end end function UITalentSkillTips:RefreshTalentInfo(heroId, talentId) local talentData = MDL.HeroStar.GetHeroTalentDataByTalentId(heroId, talentId) local talentList = talentData.DevelopEffectID local name, desc = MDL.HeroStar.GetTalentNameAndDesc(talentList[1]) self.txt_TalentName.text = name self.txt_TalentDes.text = desc local developEffectData = DataSheetManager.DevelopEffectData:GetDataByID(talentId) UIUtils.SetImageByAssetBundle(self.img_Talent, string.format(SkillIconPath, developEffectData.Icon)) local level = MDL.HeroStar.GetHeroTalentLevel(heroId, talentId) self.txt_Lv.text = level local isLock = not CTL.HeroStar.IsDevelopEffectUnlock(heroId, talentId) UIUtils.SetActive(self.group_Level, not isLock and level > 0) UIUtils.SetActive(self.group_LockCondition.gameObject, isLock) UIUtils.SetActive(self.group_Locked.gameObject, isLock) UIUtils.SetActive(self.group_LevelUpHint.gameObject, not isLock) self.state_DesLock:SetState(isLock and 0 or 1) if isLock then self.txt_LockInfo.text = string.FormatByIdsId(Const_IDS["IDS_TalentSkill_UnlockHint"], MDL.HeroStar.GetHeroStarByTalentId(heroId, talentId)) else if CTL.HeroStar.IsHeroReachMaxStar(heroId) then UIUtils.SetLabelText(self.txt_LevelUpHint, Const_IDS.IDS_TalentSkill_UnlockHint3) else UIUtils.SetLabel(self.txt_LevelUpHint, string.FormatByIdsId(Const_IDS.IDS_TalentSkill_UnlockHint2, UTL.Attr.GetHeroBreakTargetLevelByTalentId(heroId, talentId))) end end self:RefreshTalentTypeTag(talentData.Display_Table) self:RefreshTalentLevelList(heroId, talentList, level) if level > 1 then self.loop_TalentSkill:MoveIndex(level - 2) end end -- 技能类型标签 function UITalentSkillTips:RefreshTalentTypeTag(typeTable) for i, v in ipairs(self.group_Type) do local data = typeTable[i] if data and not string.isNilOrEmpty(data.DisplayPic) and not string.isNilOrEmpty(data.DisplayIDs) then UIUtils.SetActive(v.gameObject, true) UIUtils.SetLabelText(v.txt_Type, Const_IDS[data.DisplayIDs]) UIUtils.SetImageByAssetBundle(v.img_Bg, data.DisplayPic) else UIUtils.SetActive(v.gameObject, false) end end end -- 技能升级预览 function UITalentSkillTips:RefreshTalentLevelList(heroId, talentList, level) UIUtils.SetActive(self.scroll_Talent, true) for i, v in ipairs(talentList) do if i ~= 1 then self.loop_TalentSkill:AddData({talentId = v, level = level}, 0) end end end function UITalentSkillTips:OnButtonClicked(comp) if comp == self.btn_Back then self:CloseView() end end function UITalentSkillTips:OnCellInit(scrollRect, index, cellTable, data) local level = data.level local talentId = data.talentId local isUnlock = (index + 2) <= level local isInLevel = (index + 2) == level local name, desc = MDL.HeroStar.GetTalentNameAndDesc(talentId) cellTable.txt_Level.text = string.FormatByIdsId(Const_IDS["IDS_TalentSkill_Level"], index + 2) cellTable.txt_Talent.text = desc if isUnlock then if isInLevel then cellTable.state_Talent:SetState(2) else cellTable.state_Talent:SetState(1) end else cellTable.state_Talent:SetState(0) end end return UITalentSkillTips