local UISubjectMonthSkillPop = UIViewClass() local TalentType = { Attr = 1, Special = 2, } local LevelFormatStr = "%s/%s" local EffectFormatStr = "%s +%s" function UISubjectMonthSkillPop:OnOpened(context) self:RegistSystemEvent(EventID.UI_SubjectMonth_Rogue_UpdateHeroInfo,self.RefreshPanel) self:RegistSystemEvent(EventID.UI_SubjectMonth_Rogue_SkillLevelUpSuccess,self.PlayLevelUpEffect) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.activityId = MDL.SubjectMonth.GetActivityId() UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_VersionsActivity_SkillTree) self.heroId = context.heroId self.skillDataMap = {} local levelModeId = DataSheetManager.RogueHeroData:GetDataByHeroID(self.heroId).LevelMode local defaultSelectCell for _, v in DataSheetManager.RogueHeroSkillData:GetEnumerator() do if v.SkillMode == levelModeId then if not self.skillDataMap[v.TalentType] then self.skillDataMap[v.TalentType] = {} end if v.TalentLevel == 0 then table.insert(self.skillDataMap[v.TalentType], v.TalentGroupID) end end end for _, type in pairs(TalentType) do for i, cell in ipairs(self["group_Skill" .. type]) do if not defaultSelectCell then defaultSelectCell = cell end local skillId = self.skillDataMap[type][i] local level = MDL.Rogue.GetSkillLevel(self.heroId, skillId) local cfg = CTL.Rogue.GetRogueHeroSkillDataByTalentGroupID(self.heroId, skillId, level) UIUtils.SetImageByAssetBundle(cell.icon, cfg.TalentIcon) end end UTL.Item.SetHeroIconByHeroId(self.img_Head, self.heroId) self:RefreshSkillPoint() self:OnButtonClicked(defaultSelectCell.event_Click) end function UISubjectMonthSkillPop:RefreshPanel() self:RefreshSkillPoint() self:SelectSkill() end function UISubjectMonthSkillPop:RefreshSkillPoint() UIUtils.SetLabel(self.txt_LeftSkillPoints, MDL.Rogue.GetLeftSkillPoint(self.heroId)) local heroLevel = MDL.Rogue.GetHeroLevel(self.heroId) for _, type in pairs(TalentType) do for i, cell in ipairs(self["group_Skill" .. type]) do local skillId = self.skillDataMap[type][i] local level = MDL.Rogue.GetSkillLevel(self.heroId, skillId) local cfg = CTL.Rogue.GetRogueHeroSkillDataByTalentGroupID(self.heroId, skillId, level) local maxLevel = CTL.Rogue.GetSkillMaxLevel(self.heroId, cfg.TalentGroupID) UIUtils.SetLabel(cell.txt_SkillLv, string.format(LevelFormatStr, level, maxLevel)) UIUtils.SetActive(cell.mask_Lock.gameObject, heroLevel < cfg.FrontHeroLevel) end end end function UISubjectMonthSkillPop:SelectSkill(skillId) self.skillId = skillId or self.skillId self:RefreshSkillInfo() end function UISubjectMonthSkillPop:PlayLevelUpEffect(skillId) self.effect:PlayUIEffect() end function UISubjectMonthSkillPop:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthRogueHeroLvReward, {heroId = self.heroId}) elseif comp == self.btn_LevelUp then local level = MDL.Rogue.GetSkillLevel(self.heroId, self.skillId) local cfg = CTL.Rogue.GetRogueHeroSkillDataByTalentGroupID(self.heroId, self.skillId, level) local leftSkillPoints = MDL.Rogue.GetLeftSkillPoint(self.heroId) if leftSkillPoints < cfg.PointNum then CTL.Tips.AddTipsMsg(Const_IDS.IDS_VersionsActivity_Roguelike_Hint9) return end MDL.Rogue.SubjectMonthHeroSkillLevelUpReq(self.heroId, self.skillId) elseif comp == self.btn_Reset then MDL.Rogue.SubjectMonthResetHeroSkillReq(self.heroId) else for _, type in pairs(TalentType) do for i, cell in ipairs(self["group_Skill" .. type]) do if comp == cell.event_Click then self:SelectSkill(self.skillDataMap[type][i]) UIUtils.SetActive(cell.choice.gameObject, true) else UIUtils.SetActive(cell.choice.gameObject, false) end end end end end function UISubjectMonthSkillPop:RefreshSkillInfo() local level = MDL.Rogue.GetSkillLevel(self.heroId, self.skillId) local cfg = CTL.Rogue.GetRogueHeroSkillDataByTalentGroupID(self.heroId, self.skillId, level) UIUtils.SetImageByAssetBundle(self.icon, cfg.TalentIcon) UIUtils.SetLabelText(self.skill_name, Const_IDS[cfg.TalentName]) local maxLevel = CTL.Rogue.GetSkillMaxLevel(self.heroId, cfg.TalentGroupID) UIUtils.SetLabel(self.txt_SkillLv, string.format(LevelFormatStr, level, maxLevel)) if level == 0 then self.state_LevelEffect:SetState(1) local nextCfg = CTL.Rogue.GetRogueHeroSkillDataByTalentGroupID(self.heroId, self.skillId, level + 1) if cfg.TalentType == TalentType.Attr then local talentAddParam = nextCfg.ParameterRule_Table[1] local attrNameIDS = DataSheetManager.AttrData:GetDataByID(talentAddParam.TalentAddParameter1).Name local attrName = UIUtils.GetLocalizedTxt(Const_IDS[attrNameIDS]) UIUtils.SetLabel(self.txt_Effect, string.format(EffectFormatStr, attrName, talentAddParam.TalentAddParameter2)) elseif cfg.TalentType == TalentType.Special then UIUtils.SetLabelText(self.txt_Effect, Const_IDS[cfg.SpecialTalentDes]) end elseif level < maxLevel then local nextCfg = CTL.Rogue.GetRogueHeroSkillDataByTalentGroupID(self.heroId, self.skillId, level + 1) self.state_LevelEffect:SetState(0) if cfg.TalentType == TalentType.Attr then local talentAddParam = cfg.ParameterRule_Table[1] local curValue = talentAddParam.TalentAddParameter2 local nextValue = nextCfg.ParameterRule_Table[1].TalentAddParameter2 local attrNameIDS = DataSheetManager.AttrData:GetDataByID(talentAddParam.TalentAddParameter1).Name local attrName = UIUtils.GetLocalizedTxt(Const_IDS[attrNameIDS]) UIUtils.SetLabel(self.txt_CurEffect, string.format(EffectFormatStr, attrName, talentAddParam.TalentAddParameter2)) local addStr = UTL.Color.FormatGreenColor(string.format(" (+%s)", nextValue - curValue)) UIUtils.SetLabel(self.txt_nextEffect, string.format(EffectFormatStr, attrName, nextValue) .. addStr) elseif cfg.TalentType == TalentType.Special then UIUtils.SetLabelText(self.txt_CurEffect, Const_IDS[cfg.SpecialTalentDes]) UIUtils.SetLabelText(self.txt_nextEffect, Const_IDS[nextCfg.SpecialTalentDes]) end else self.state_LevelEffect:SetState(2) if cfg.TalentType == TalentType.Attr then local talentAddParam = cfg.ParameterRule_Table[1] local attrNameIDS = DataSheetManager.AttrData:GetDataByID(talentAddParam.TalentAddParameter1).Name local attrName = UIUtils.GetLocalizedTxt(Const_IDS[attrNameIDS]) UIUtils.SetLabel(self.txt_MaxLevelEffect, string.format(EffectFormatStr, attrName, talentAddParam.TalentAddParameter2)) elseif cfg.TalentType == TalentType.Special then UIUtils.SetLabelText(self.txt_MaxLevelEffect, Const_IDS[cfg.SpecialTalentDes]) end end UIUtils.SetActive(self.mask_Lock.gameObject, false) local heroLevel = MDL.Rogue.GetHeroLevel(self.heroId) if level == maxLevel then self.state_Btn:SetState(2) elseif heroLevel < cfg.FrontHeroLevel then self.state_Btn:SetState(0) UIUtils.SetActive(self.mask_Lock.gameObject, true) UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS.IDS_VersionsActivity_SkillPrerequisite, cfg.FrontHeroLevel)) else self.state_Btn:SetState(1) local leftSkillPoints = MDL.Rogue.GetLeftSkillPoint(self.heroId) UIUtils.SetLabel(self.txt_Cost, UTL.Color.FormatTextByColor(leftSkillPoints >= cfg.PointNum and UTL.Color.White or UTL.Color.Red, cfg.PointNum)) end self.btn_Reward:SetRedPoint(CTL.Rogue.CanReceiveAnyLevelRewardByHeroID(self.heroId)) end function UISubjectMonthSkillPop:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end return UISubjectMonthSkillPop