local UISlgGvETalentLvUp = UIViewClass() function UISlgGvETalentLvUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_SlgGvE_Talent_Update_Info, self.RefreshUI) self:RegistSystemEvent(EventID.UI_SlgGve_Talent_UpLv, self.PlayUpLvEffect) self:RegistSystemEvent(EventID.UI_SlgGvE_Material_Update_Info, self.RefreshComsumeUpLv) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_SlgGve_Talent_Title) self.talentIndex = context.talentIndex self.officailLv = context.officailLv self:RefreshUI() self:RefreshComsumeUpLv() end function UISlgGvETalentLvUp:RefreshUI() local talentInfoList = MDL.SlgGvE.GetTalentInfoList(self.officailLv) self.talentInfo = talentInfoList[self.talentIndex] self.talentCfg = self.talentInfo.talentCfg self.isMaxLv = #self.talentCfg.CostItem_Table <= 0 self:RefreshTalentInfo() end function UISlgGvETalentLvUp:RefreshTalentInfo() UIUtils.SetImageByAssetBundle(self.icon_talent, self.talentCfg.GveTalentIcon) UIUtils.SetImageByAssetBundle(self.icon_talent_bg, self.talentCfg.GveTalentColorBG) local maxLv = CTL.SlgGvE.GetTalentGroupMaxLv(self.talentCfg.GveTalentGroupID) local str = string.FormatByIdsKey("IDS_BreakThrough_Lv", self.talentCfg.GveTalentLevel.."/"..maxLv) self.txt_level.text = str self.talent_name.text = UIUtils.GetLocalizedTxt(Const_IDS[self.talentCfg.GveTalentName]) self.talentDes.text = UIUtils.GetLocalizedTxt(Const_IDS[self.talentCfg.GveTalentDes]) if self.talentCfg.IsSpeTalentType == 1 then self.state_detail:SetState(0) self.special_talent_name.text = UIUtils.GetLocalizedTxt(Const_IDS[self.talentCfg.GveTalentName]) self.txt_detail.text = UIUtils.GetLocalizedTxt(Const_IDS[self.talentCfg.GveSpecialTalentDes]) else if self.isMaxLv then self.state_detail:SetState(2) self:RefreshTalentAdd(self.group_cur_add, self.talentCfg) else self.state_detail:SetState(1) self.txt_change.text = string.FormatByIdsKey("IDS_SlgGve_Talent_Hint_3", self.talentCfg.GveTalentLevel + 1) self:RefreshTalentAdd(self.group_cur_add, self.talentCfg) local nextTalentCfg = DataSheetManager.SlgGvETalentData:GetDataByGveTalentID(self.talentCfg.GveTalentID + 1) self:RefreshTalentAdd(self.group_next_add, nextTalentCfg) end end end function UISlgGvETalentLvUp:RefreshTalentAdd(collection, talentCfg) local addInfos = talentCfg.ParameterRule_Table local talentAddInfoList = CTL.SlgGvE.GetNormalTalentAddInfoList(talentCfg) for i = 1, 4 do if i > #addInfos then UIUtils.SetActive(collection[i].gameObject, false) else UIUtils.SetActive(collection[i].gameObject, true) collection[i].txt_add_name.text = talentAddInfoList[i].addName collection[i].txt_num.text = talentAddInfoList[i].addValue end end end function UISlgGvETalentLvUp:RefreshComsumeUpLv() --已满级 if self.isMaxLv then self.state_update:SetState(0) return end self:RefreshUpComsume() self:RefreshUpCondition() end function UISlgGvETalentLvUp:RefreshUpComsume() local costItem = self.talentCfg.CostItem_Table self.isMaterialEnough = true for i = 1, 3 do if i <= #costItem then local itemId = costItem[i].Item UTL.Item.ItemSquareIcon(self.group_meterail[i].icon_material, nil, itemId) local itemNameAndDesc = UTL.Item.GetItemDataSpliceByType(itemId) self.group_meterail[i].lab_name.text = itemNameAndDesc.Name local ownedNum = MDL.SlgGvE.GetMaterialNum(itemId) local needNum = costItem[i].ItemNum if ownedNum < needNum then self.isMaterialEnough = false end local ownedNumStr = ownedNum >= needNum and UTL.Color.FormatGreenColor(ownedNum) or UTL.Color.FormatRedColor(ownedNum) self.group_meterail[i].lab_num.text = ownedNumStr.."/"..needNum UIUtils.SetActive(self.group_meterail[i].gameObject, true) else UIUtils.SetActive(self.group_meterail[i].gameObject, false) end end end function UISlgGvETalentLvUp:RefreshUpCondition() local isCanUnlock, conditionStr1, conditionStr2 = CTL.SlgGvE.GetTalentUnlockStatusAndConditions(self.talentCfg) if isCanUnlock then self.state_update:SetState(1) self.btn_update:SetRedPoint(self.isMaterialEnough and MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.Playing) if self.talentCfg.GveTalentLevel > 0 then self.labLocal_update.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_SlgGve_Talent_Hint_7) else self.labLocal_update.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_Nobility_Activation) end else self.state_update:SetState(2) if string.isNilOrEmpty(conditionStr1) then UIUtils.SetActive(self.txt_commend01.gameObject, false) else UIUtils.SetActive(self.txt_commend01.gameObject, true) self.txt_commend01.text = conditionStr1 end if string.isNilOrEmpty(conditionStr2) then UIUtils.SetActive(self.txt_commend02.gameObject, false) else UIUtils.SetActive(self.txt_commend02.gameObject, true) self.txt_commend02.text = conditionStr2 end end end function UISlgGvETalentLvUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UISlgGvETalentLvUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_update then if MDL.SlgGvE.GetSeasonState() ~= MDL.SlgGvE.SeasonState.Playing then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SlgGve_Season_Hint_4"]) return end MDL.SlgGvE.GVETalentLevelUpReq(self.talentCfg.GveTalentID) end end function UISlgGvETalentLvUp:PlayUpLvEffect() self.effect_talent:PlayUIEffect() CTL.Sound.PlayGameSound("UI_upgrade_01") end return UISlgGvETalentLvUp