local UIDivineWeaponAwakenSkillTreePanel = require("View/HeroAwaken/UIDivineWeaponAwakenSkillTreePanel") local UIFairAwakenSkillTreePanel = UIViewClass(UIDivineWeaponAwakenSkillTreePanel) local hero_awaken_info = require 'Proto/hero_awaken_info_pb' local DEFAULT_SELECT_POINT = 101 --@OVERRIDE function UIFairAwakenSkillTreePanel:Init(context) self:RegistSystemEvent(EventID.UI_HeroAwaken_FairAwakenSkillPlan_SelectPlan, self.OnSelectPlan) self:RegistSystemEvent(EventID.UI_HeroAwaken_FairAwakenSkillPlan_UpdatePlanInfo, self.OnUpdateWeaponAwakenSkillInfo) self:RegistSystemEvent(EventID.UI_HeroAwaken_FairAwakenSkillPlan_LevelUpSkill, self.OnUpdateWeaponAwakenSkillInfo) self:RegistSystemEvent(EventID.UI_HeroAwaken_FairAwakenSkillPlan_Reset, self.OnUpdateWeaponAwakenSkillInfo) self.weaponId = context.weaponId self.planId = context.planId self:RefreshPointIcon() self:RefreshTree() self:OnSelectPoint(DEFAULT_SELECT_POINT, self.pointDataMap[DEFAULT_SELECT_POINT]) end function UIFairAwakenSkillTreePanel:OnSelectPlan(weaponId, planId) self.weaponId = weaponId self.planId = planId self:RefreshPointIcon() self:RefreshTree() self:RefreshPointInfo() end --@OVERRIDE function UIFairAwakenSkillTreePanel:GetPointLevel(pointId) return MDL.HeroAwaken.GetPlanSkillLevel(self.weaponId, self.planId, pointId) end --@OVERRIDE function UIFairAwakenSkillTreePanel:GetCurrPointNum() return MDL.HeroAwaken.GetPlanCurrPointNum(self.weaponId, self.planId) end --@OVERRIDE function UIFairAwakenSkillTreePanel:GetUsedPointNum() return MDL.HeroAwaken.GetPlanUsedPointNum(self.weaponId, self.planId) end --@OVERRIDE function UIFairAwakenSkillTreePanel:ButtonClicked(comp) if comp == self.btn_Upgrade then if not self:canUpgrade() then return end MDL.HeroAwaken.FairAwakenSkillPlanReq(self.weaponId, hero_awaken_info.LevelUpSkill, self.planId, self.pointId) elseif comp == self.btn_Reset then if not self:canReset() then return end MDL.HeroAwaken.FairAwakenSkillPlanReq(self.weaponId, hero_awaken_info.Reset, self.planId, self.pointId) elseif comp == self.btn_Guide then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.WeaponAwakenSkill}) end end --@OVERRIDE function UIFairAwakenSkillTreePanel:canUpgrade() if not CTL.HeroAwaken.CheckPlanUpgradePrecondition(self.weaponId, self.planId, self.pointId, CTL.HeroAwaken.SkillUpgradePrecondition.UsedPointNum) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_44373_InfoCode_HeroAwaken_NeedPrecondition) return false end if not CTL.HeroAwaken.CheckPlanUpgradePrecondition(self.weaponId, self.planId, self.pointId, CTL.HeroAwaken.SkillUpgradePrecondition.NeedPoint) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_44373_InfoCode_HeroAwaken_NeedPrecondition) return false end if not CTL.HeroAwaken.CheckPlanUpgradePrecondition(self.weaponId, self.planId, self.pointId, CTL.HeroAwaken.SkillUpgradePrecondition.NoNeedPoint) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_44373_InfoCode_HeroAwaken_NeedPrecondition) return false end if not CTL.HeroAwaken.CheckPlanUpgradePrecondition(self.weaponId, self.planId, self.pointId, CTL.HeroAwaken.SkillUpgradePrecondition.Cost) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_44375_InfoCode_HeroAwaken_WeaponSklllLack) return false end return true end --@OVERRIDE function UIDivineWeaponAwakenSkillTreePanel:canReset() if self:GetUsedPointNum() <= 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroAwaken_ResetLingshiTips) return false end return true end --@OVERRIDE function UIFairAwakenSkillTreePanel:CanPlayEffect(pointId) for _, v in pairs(CTL.HeroAwaken.SkillUpgradePrecondition) do if v ~= CTL.HeroAwaken.SkillUpgradePrecondition.Star and not CTL.HeroAwaken.CheckPlanUpgradePrecondition(self.weaponId, self.planId, pointId, v) then return false end end return true end --@OVERRIDE function UIFairAwakenSkillTreePanel:RefreshPointInfo() local level = self:GetPointLevel(self.pointId) --信息 local cfg = DataSheetManager.MagicWeaponAwakenTalent:GetDataByMagicWeaponID_PointID_PointLevel(self.weaponId, self.pointId, level == 0 and 1 or level) UIUtils.SetImageByAssetBundle(self.img_SkillIcon, cfg.Icon) UIUtils.SetLabel(self.txt_SkillName, UTL.String.FormatCombineTextByID(cfg.Desc_2)) --不同等级的效果 local maxLevel = DataSheetManager.MagicWeaponAwakenTalent:GetDataLengthByMagicWeaponID_PointID_PointLevel(self.weaponId, self.pointId) self.loop_TalentSkill:ClearCells() local nextLevelCfg for i = 1, maxLevel do local cfg = DataSheetManager.MagicWeaponAwakenTalent:GetDataByMagicWeaponID_PointID_PointLevel(self.weaponId, self.pointId, i) self.loop_TalentSkill:AddData(cfg, 0) if i == level + 1 then nextLevelCfg = cfg end end if nextLevelCfg then local allHasMetCondition = true local conditionTextList = {} local color = UTL.Color.White local text --花费的灵识点数 if CTL.HeroAwaken.CheckPlanUpgradePrecondition(self.weaponId, self.planId, self.pointId, CTL.HeroAwaken.SkillUpgradePrecondition.UsedPointNum) then color = UTL.Color.White else allHasMetCondition = false color = UTL.Color.Red end local num = self:GetUsedPointNum() text = UTL.Color.FormatTextByColor(color, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_SkillSpended"], string.format("%s/%s", num, nextLevelCfg.NeedPointNum))) table.insert(conditionTextList, text) --前置结点 if #nextLevelCfg.NeedPoint > 0 then local nameList = {} color = UTL.Color.White for i, v in ipairs(nextLevelCfg.NeedPoint) do local needPointCfg = DataSheetManager.MagicWeaponAwakenTalent:GetDataByMagicWeaponID_PointID_PointLevel(self.weaponId, v, nextLevelCfg.NeedPointLevel[i]) table.insert(nameList, UTL.String.FormatCombineTextByID(needPointCfg.Desc_2)) local level = self:GetPointLevel(v) if level < nextLevelCfg.NeedPointLevel[i] then allHasMetCondition = false color = UTL.Color.Red break end end text = UTL.Color.FormatTextByColor(color, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_SkillLearned"], table.concat(nameList, " "))) table.insert(conditionTextList, text) end --互斥结点 local nameList = {} color = UTL.Color.White local hasMetNoNeedPointCondition = true local _, cfg = DataSheetManager.MagicWeaponAwakenNoNeedPoint:TryGetDataByMagicWeaponID(self.weaponId) UIUtils.SetLabel(self.txt_ExclusiveSkills, "") if cfg then for i, v in ipairs(cfg.NoNeedPoint_Table) do local isFound = false for _, pointId in ipairs(v.PointID) do if pointId == self.pointId then isFound = true break end end if isFound then for _, pointId in ipairs(v.PointID) do if pointId ~= self.pointId then local level = self:GetPointLevel(pointId) if level > 0 and hasMetNoNeedPointCondition then allHasMetCondition = false hasMetNoNeedPointCondition = false color = UTL.Color.Red end local noNeedPointCfg = DataSheetManager.MagicWeaponAwakenTalent:GetDataByMagicWeaponID_PointID_PointLevel(self.weaponId, pointId, 1) table.insert(nameList, UTL.String.FormatCombineTextByID(noNeedPointCfg.Desc_2)) end end text = UTL.Color.FormatTextByColor(color, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_SkillNotLearned"], table.concat(nameList, " "))) text = string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_SkillNotLearned"], table.concat(nameList, " ")) UIUtils.SetLabel(self.txt_ExclusiveSkills, text) text = UTL.Color.FormatTextByColor(color, text) table.insert(conditionTextList, text) break end end end if not allHasMetCondition then self.state_Upgrade:SetState(2) local index = 0 for i, v in ipairs(conditionTextList) do local cell = self.group_Condition[i] if not cell then cell = self:InstantiateCollection(self.group_Condition, self.group_Condition[1].gameObject) end UIUtils.SetActive(cell.gameObject, true) UIUtils.SetLabel(cell.txt_Condition, v) index = i end for i = index + 1, #self.group_Condition do UIUtils.SetActive(self.group_Condition[i].gameObject, false) end else self.state_Upgrade:SetState(0) local text = UTL.Color.FormatTextByColor(self:GetCurrPointNum() >= nextLevelCfg.Cost and UTL.Color.Green or UTL.Color.Red, nextLevelCfg.Cost) UIUtils.SetLabel(self.txt_Cost, text) end else self.state_Upgrade:SetState(1) end --当前灵识点数 UIUtils.SetLabel(self.txt_Point, self:GetCurrPointNum()) end return UIFairAwakenSkillTreePanel