--[[ 神兽技能天赋界面 ]]-- local UIGodBeastTalent = UIViewClass() local RESET_ITEM_ID = DataSheetManager.ConstData:GetDataByID("GodBeastResetTalentItemID").IntValue local RESET_ITEM_COUNT = DataSheetManager.ConstData:GetDataByID("GodBeastResetTalentItemNum").IntValue local TALENT_ONE_LINE_COUNT = 4 --region ---------------------- 系统函数--------------------------- function UIGodBeastTalent:OnOpened(context) self:RegistSystemEvent(EventID.UI_GodBeastTalentRefresh, self.RefreshAll) self:RegistSystemEvent(EventID.UI_GodBeastTalentRefresh, self.OnLearnUpdate) self.config = context.config self.lastSelectTalentLevel = -1 self.curSelectTalentInfo, self.curTalentData = {}, {} -- 当前选中的点位信息, 当前选中的天赋点Data self:UpdateSelectPointInfo(1, 1) self:RefreshAll() end function UIGodBeastTalent:OnButtonClicked(comp) if comp == self.btn_Active then -- 学习 if MDL.GodBeast.GetCurTalentPointBeastID(self.config.ID) <= 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Godbeast_Talent9) else MDL.GodBeast.GodBeastLearnTalentReq(self.config.ID, self.curSelectTalentInfo.levelID) end elseif comp == self.btn_Reset then -- 重置 if not MDL.GodBeast.CanResetTalentPoint(self.config.ID) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Godbeast_Talent8) else local itemData = DataSheetManager.ItemData:GetDataByID(RESET_ITEM_ID) UTL.MessageBox.ShowOKCancelBox( nil, string.FormatByIdsId(Const_IDS.IDS_Godbeast_TalentReset, UIUtils.GetLocalizedTxt(Const_IDS[itemData.Name]), RESET_ITEM_COUNT), function() MDL.GodBeast.GodBeastResetTalentReq(self.config.ID) end ) end else for levelID, levelCollection in ipairs(self.template_TalentCol) do for pointID, pointCollection in ipairs(levelCollection) do if comp == pointCollection.img_Click then self:OnClickPoint(levelID, pointID) break end end end end end --endregion ------------------------------------------------------ function UIGodBeastTalent:RefreshAll() UIUtils.SetImageByAssetBundle(self.img_GodBeastPic, self.config.GodBeastTalentPicture) self:RefreshTalentUI() self:RefreshInfoPanel() end function UIGodBeastTalent:RefreshTalentUI() local lineCount = self.config.TalentCount if lineCount == 3 then UIUtils.SetActive(self.template_Talent_3.gameObject, true) UIUtils.SetActive(self.template_Talent_4.gameObject, false) self.template_TalentCol = self.template_Talent_3 else UIUtils.SetActive(self.template_Talent_3.gameObject, false) UIUtils.SetActive(self.template_Talent_4.gameObject, true) self.template_TalentCol = self.template_Talent_4 end self:RefreshAllPoints() end function UIGodBeastTalent:RefreshAllPoints() for levelID, levelCollection in ipairs(self.template_TalentCol) do for pointID, pointCollection in ipairs(levelCollection) do self:RefreshPoint(pointCollection, levelID, pointID) end end end -- 刷新单一point节点 function UIGodBeastTalent:RefreshPoint(collection, levelID, pointID) local talentInfo = MDL.GodBeast.GetTalentInfo(self.config.ID) -- 未学习的天赋为空 local talentLevelInfo for _, v in ipairs(talentInfo) do if v.talentId == levelID then talentLevelInfo = v end end if talentLevelInfo == nil then talentLevelInfo = {talentNums = 0, talentId = levelID} end local isSuccess, talentPointData = DataSheetManager.GodBeastTalent:TryGetDataByID_LevelID_PointId(self.config.ID, levelID, pointID) if isSuccess then -- 天赋点图标 UIUtils.SetImageByAssetBundle(collection.img_icon, talentPointData.Icon) -- 选中状态 collection.state_Select:SetState((levelID == self.curSelectTalentInfo.levelID and pointID == self.curSelectTalentInfo.pointID) and 1 or 0) if talentLevelInfo.talentNums == pointID - 1 then collection.state_Btn:SetState(1) -- 可激活 elseif talentLevelInfo.talentNums < pointID then collection.state_Btn:SetState(2) -- 未激活 else collection.state_Btn:SetState(0) -- 已激活 end end end function UIGodBeastTalent:OnClickPoint(levelID, pointID) -- 更新选中信息 local lastLevel, lastPoint = self.curSelectTalentInfo.levelID, self.curSelectTalentInfo.pointID self:UpdateSelectPointInfo(levelID, pointID) -- 更新新旧两个点 self:RefreshPoint(self.template_TalentCol[lastLevel][lastPoint], lastLevel, lastPoint) self:RefreshPoint(self.template_TalentCol[levelID][pointID], levelID, pointID) end function UIGodBeastTalent:RefreshInfoPanel() -- 天赋点图标 UIUtils.SetImageByAssetBundle(self.sprite_Skill, self.curTalentData.Icon) -- 天赋点名称 UIUtils.SetLabel(self.txt_SkillName, UTL.String.FormatCombineTextByID(self.curTalentData.Desc_2)) -- 天赋点述 UIUtils.SetLabel(self.txt_Introduction, UTL.String.FormatCombineTextByID(self.curTalentData.Desc_3)) -- 更新按钮 local finishPoint = MDL.GodBeast.GetTalentPointProgress(self.config.ID, self.curSelectTalentInfo.levelID) local curGodPoint = MDL.GodBeast.GetCurTalentPointBeastID(self.config.ID) UIUtils.SetLabel(self.txt_Talent, curGodPoint) local isNotValidPoint = finishPoint + 1 ~= self.curSelectTalentInfo.pointID local isNotPreRequestSatisfy = MDL.GodBeast.GetGodBeastStarLevel(self.config.ID) < self.curTalentData.Preconditions local notEnoughPoint = curGodPoint <= 0 if isNotPreRequestSatisfy or isNotValidPoint or notEnoughPoint then UIUtils.SetActive(self.btn_Active, false) UIUtils.SetActive(self.txt_TopTip, true) if isNotPreRequestSatisfy then UIUtils.SetLabel(self.txt_TopTip, string.FormatByIdsId(Const_IDS.IDS_Godbeast_Talent13, self.curTalentData.Preconditions)) elseif isNotValidPoint then if self.curSelectTalentInfo.pointID <= finishPoint then -- 小于当前学到点位 UIUtils.SetLabelText(self.txt_TopTip, Const_IDS.IDS_Godbeast_Talent11) else UIUtils.SetLabelText(self.txt_TopTip, Const_IDS.IDS_Godbeast_Talent10) end else UIUtils.SetLabelText(self.txt_TopTip, Const_IDS.IDS_Godbeast_Talent9) end else UIUtils.SetActive(self.txt_TopTip, false) UIUtils.SetActive(self.btn_Active, true) -- 天赋学习红点 self.btn_Active:SetRedPoint(MDL.GodBeast.GetCurTalentPointBeastID(self.config.ID) > 0) end end function UIGodBeastTalent:UpdateSelectPointInfo(levelID, pointID) CTL.Sound.PlayGameSound("UI_breakthrough_01") -- 当前选中的点位信息 self.curSelectTalentInfo.beastID = self.config.ID self.curSelectTalentInfo.levelID = levelID self.curSelectTalentInfo.pointID = pointID -- 当前选中的天赋点Data local isOk, talentData = DataSheetManager.GodBeastTalent:TryGetDataByID_LevelID_PointId(self.curSelectTalentInfo.beastID, levelID, pointID) if isOk then self.curTalentData = talentData else self.curTalentData = DataSheetManager.GodBeastTalent:GetDataByID_LevelID_PointId(self.curSelectTalentInfo.beastID, levelID, pointID) end self:RefreshInfoPanel() end function UIGodBeastTalent:OnLearnUpdate(isReset) if isReset == false then self:PlayLearnEffect(self.curSelectTalentInfo.levelID, self.curSelectTalentInfo.pointID) if self.curSelectTalentInfo.pointID == TALENT_ONE_LINE_COUNT then self:OnClickPoint(self.curSelectTalentInfo.levelID, self.curSelectTalentInfo.pointID) else self:OnClickPoint(self.curSelectTalentInfo.levelID, self.curSelectTalentInfo.pointID + 1) end else self:OnClickPoint(self.curSelectTalentInfo.levelID, self.curSelectTalentInfo.pointID) end end function UIGodBeastTalent:PlayLearnEffect(levelID, pointID) for level, collection in ipairs(self.template_TalentCol) do for point, subCollection in ipairs(collection) do if level == levelID and point == pointID then subCollection.effect_Activated:PlayUIEffect() return end end end end return UIGodBeastTalent