local UIEquipmentCommon = require "View/Equipment/UIEquipmentCommon" local resonance_info = require 'Proto/resonance_info_pb' local UIEquipStarMain = UIViewClass(UIEquipmentCommon) --未激活技能时隐藏技能描述位置 function UIEquipStarMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_EquipStarLevelUpSuccess, self.OnEquipStarLevelUpSuccess) self:RegistSystemEvent(EventID.UI_EquipStarSkillOpt, self.OnEquipStarLevelUpSuccess) end function UIEquipStarMain:OnEquipStarLevelUpSuccess() self:RefreshEquipInfo(self.equipInfo) end function UIEquipStarMain:RefreshEquipInfo(equipInfo) if self.equipInfo and self.equipInfo.ID == equipInfo.ID then local curStage, curStar = MDL.Equipment.GetEquipStarInfo(equipInfo.ID) if curStage ~= self.starStage or curStar ~= self.starNum then self.effect_Up:PlayUIEffect() self.lastStage = self.starStage self.lastStarNum = self.starNum else self.lastStage = nil self.lastStarNum = nil end end self.equipInfo = equipInfo self.starStage, self.starNum = MDL.Equipment.GetEquipStarInfo(equipInfo.ID) self.starLevel = MDL.Equipment.GetEquipStarCount(equipInfo.ID) self.lab_Max.text = nil self.state_Max:SetState(0) self:OnShowEquipStar() if self.loop_Star.Count > 0 then self.loop_Star:RefreshCells() else for i = 1, 10 do self.loop_Star:AddData(i, 0) end end self:ShowSkill() if self:IsAllMax() then --self.btn_QuickUpgrade:SetGray(true) self.state_Max:SetState(1) else self.btn_QuickUpgrade:SetGray(false) end end function UIEquipStarMain:SetResonanceLvType() self.resonanceLvType = resonance_info.Equip_Star end function UIEquipStarMain:RefreshResonanceLv() end function UIEquipStarMain:OnShowEquipStar() self.levelUpMax = false self.btn_Upgrade:SetGray(false) UIUtils.SetActive(self.group_Cost, true) local data = nil if self.starStage == 0 then data = DataSheetManager.EquipStar:GetDataByStarStage_StarLevel(1, 1) UIUtils.SetActive(self.img_StarBg, false) self.state_Attr:SetState(1) self.equipStarData = data else UIUtils.SetActive(self.img_StarBg, true) self.state_Attr:SetState(0) local stageData = DataSheetManager.EquipStarStage:GetDataByStarStage(self.starStage) UIUtils.SetImageByAssetBundle(self.img_Star, stageData.Icon) data = DataSheetManager.EquipStar:GetDataByStarStage_StarLevel(self.starStage, self.starNum) self.equipStarData = data self.loop_EquipAttr:ReloadAll({1,2,4}) end local nextData = data local isHasData = false if self.starStage > 0 then local nextStarStage, nextStarNum = CTL.Equipment.GetNextStageAndNum(self.starStage, self.starNum) isHasData, nextData = DataSheetManager.EquipStar:TryGetDataByStarStage_StarLevel(nextStarStage, nextStarNum) end self.enoughCost = false if nextData then self.enoughCost = true UTL.Item.ItemIconWithoutBg(self.icon_Cost1, nextData.item_Table[1].ItemID) UTL.Item.ItemIconWithoutBg(self.icon_Cost2, nextData.item_Table[2].ItemID) self.txt_Cost1.text = nextData.item_Table[1].ItemNum self.txt_Cost2.text = nextData.item_Table[2].ItemNum local hasCount = CTL.Bag.GetHasCountByItemCfgID(nextData.item_Table[1].ItemID) if hasCount >= nextData.item_Table[1].ItemNum then self.txt_Cost1.text = UTL.Color.FormatWhiteColor(nextData.item_Table[1].ItemNum) else self.txt_Cost1.text = UTL.Color.FormatRedColor(nextData.item_Table[1].ItemNum) self.enoughCost = false end local hasCount = CTL.Bag.GetHasCountByItemCfgID(nextData.item_Table[2].ItemID) if hasCount >= nextData.item_Table[2].ItemNum then self.txt_Cost2.text = UTL.Color.FormatWhiteColor(nextData.item_Table[2].ItemNum) else self.txt_Cost2.text = UTL.Color.FormatRedColor(nextData.item_Table[2].ItemNum) self.enoughCost = false end UIUtils.SetActive(self.group_Cost, true) self.btn_Upgrade:SetGray(false) else UIUtils.SetLabelText(self.lab_Max,Const_IDS.IDS_EquipStar_Tips9) UIUtils.SetActive(self.group_Cost, false) self.btn_Upgrade:SetGray(true) end self.btn_Upgrade:SetRedPoint(self.enoughCost) if self.enoughCost then if CTL.Equipment.CanOneKeyEquipStarLevelUp(self.equipInfo.ID) then self.btn_QuickUpgrade:SetRedPoint(self.enoughCost) else self.btn_QuickUpgrade:SetRedPoint(false) end else self.btn_QuickUpgrade:SetRedPoint(false) end end function UIEquipStarMain:OnButtonClicked(comp) if comp == self.btn_QuickUpgrade then CTL.Equipment.OneKeyEquipStarLevelUp(self.equipInfo.ID) elseif comp == self.btn_Upgrade then if self.isUnlock then CTL.Tips.AddTipsMsg(self.unlockDesc) elseif not self.enoughCost then CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipStar_Tips11) else MDL.Equipment.EquipStarLevelUpReq(self.equipInfo) end elseif comp == self.btn_View then local heroId = MDL.Equipment.GetEquipHeroId(self.equipInfo.ID) UIManager.OpenView(Const_UI_Lua.UIEnum.UIEquipStarAttrPreview, { heroId = heroId, isShowNext = true }) elseif comp == self.btn_Change then local heroId = MDL.Equipment.GetEquipHeroId(self.equipInfo.ID) UIManager.OpenView(Const_UI_Lua.UIEnum.UIEquipStarSpecialAttr, { heroId = heroId, nextStage = self.nextStage, curSkillMax = self.curSkillMax }) end end function UIEquipStarMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Star then if index < self.starNum then cellTable.state_Star:SetState(1) else cellTable.state_Star:SetState(0) end local stageData = DataSheetManager.EquipStarStage:GetDataByStarStage(self.starStage > 0 and self.starStage or 1) UIUtils.SetImageByAssetBundle(cellTable.img_Light, stageData.Icon) UIUtils.SetImageByAssetBundle(cellTable.img_Dark, stageData.Icon_2) if self.lastStage then if self.lastStage < self.starStage or (self.lastStage == self.starStage and self.lastStarNum < index + 1) then cellTable.ani_Star:PlayAnim() end end elseif self.loop_AttrInfo == scrollRect then UIUtils.SetImageByAssetBundle(cellTable.img_AttrLevel, data.SkillLevelIcon) cellTable.txt_AttrInfo.text = string.gsub(UIUtils.GetLocalizedTxt(Const_IDS[data.EquipSkillDes]), " ", " ") else UIUtils.SetActive(cellTable.img_Active, self:IsActiveEquipStar(index)) if self:IsActiveEquipStar(index) then cellTable.state_Color:SetState(1) else cellTable.state_Color:SetState(0) end cellTable.txt_Equip.text = string.FormatByIdsId(Const_IDS.IDS_EquipStar_Tips25, data) local attrList = {} for i, v in ipairs(self.equipStarData.StarLevelAttr_Table) do if v.StarSuitNum == data then table.insert(attrList, v) end end UIUtils.SetActive(cellTable.txt_Attr2, false) for i, v in ipairs(attrList) do local attrData = DataSheetManager.AttrData:GetDataByID(v.AttrType1) cellTable["txt_Attr"..i].text = UIUtils.GetLocalizedTxt(Const_IDS[attrData.Name]) UIUtils.SetActive(cellTable["txt_Attr"..i], true) if self.starStage == 0 then self:ShowAttr(cellTable["txt_Num"..i], 0, v.IsSpecialAttr1) else self:ShowAttr(cellTable["txt_Num"..i], v.AttrNum1, v.IsSpecialAttr1) end end if self.starStage == 0 then data = DataSheetManager.EquipStar:GetDataByStarStage_StarLevel(1, 1) UIUtils.SetActive(cellTable.img_StarBg, false) else UIUtils.SetActive(cellTable.img_StarBg, true) cellTable.txt_Num.text = self.starNum local stageData = DataSheetManager.EquipStarStage:GetDataByStarStage(self.starStage) UIUtils.SetImageByAssetBundle(cellTable.img_Star, stageData.Icon) data = DataSheetManager.EquipStar:GetDataByStarStage_StarLevel(self.starStage, self.starNum) end end end function UIEquipStarMain:ShowAttr(txt, num, IsSpecialAttr) if IsSpecialAttr then txt.text = "+" .. UTL.Attr.FormatNumberToPercentage(num, 0) else txt.text = "+" .. num end end function UIEquipStarMain:ShowSkill() self.lab_unlock.text = nil local heroId = MDL.Equipment.GetEquipHeroId(self.equipInfo.ID) local heroInfo = MDL.HeroSelect.GetHeroInfo(heroId) local isSuccess, skillData = DataSheetManager.EquipSkillLib:TryGetDataByEquipSkillID(heroInfo.equipStarSkillId) self.curSkillMax = false UIUtils.SetActive(self.title_StarBg, true) if heroInfo.equipStarSkillId > 0 then local stage = nil for i, v in DataSheetManager.EquipStarStage:GetEnumerator() do if v.EquipSkillLibID > skillData.EquipSkillLibID then stage = v.StarStage break end end self.loop_AttrInfo:ClearCells() self.curSkillMax = false self.loop_AttrInfo:AddData(skillData, 0) if stage then self.nextStage = stage if self:IsAllMax() then UIUtils.SetLabelText(self.lab_Notice1, Const_IDS.IDS_EquipStar_Tips8) UIUtils.SetActive(self.title_StarBg, false) self.lab_Notice2.text = nil else UIUtils.SetLabelText(self.lab_Notice1,Const_IDS.IDS_EquipStar_Tips1) UIUtils.SetLabelText(self.lab_Notice2,Const_IDS.IDS_EquipStar_Tips24) local stageData = DataSheetManager.EquipStarStage:GetDataByStarStage(stage) UIUtils.SetImageByAssetBundle(self.titleImg_Star, stageData.Icon) self.titleTxt_Num.text = 10 end else if CTL.Equipment.CheckEquipSkillIfLevelUp(self.equipInfo, heroId) then UIUtils.SetLabelText(self.lab_Notice1, Const_IDS.IDS_EquipStar_Tips8) else UIUtils.SetLabelText(self.lab_Notice1, Const_IDS.IDS_EquipStar_Tips6) end UIUtils.SetActive(self.title_StarBg, false) self.lab_Notice2.text = nil self.curSkillMax = true end UIUtils.SetActive(self.group_Skill, true) else UIUtils.SetLabelText(self.lab_Notice1,Const_IDS.IDS_EquipStar_Tips7) UIUtils.SetLabelText(self.lab_Notice2,Const_IDS.IDS_EquipStar_Tips23) local stageData = DataSheetManager.EquipStarStage:GetDataByStarStage(1) UIUtils.SetImageByAssetBundle(self.titleImg_Star, stageData.Icon) self.titleTxt_Num.text = 10 UIUtils.SetActive(self.group_Skill, false) end self.isUnlock = false local nextStarStage, nextStarNum = CTL.Equipment.GetNextStageAndNum(self.starStage, self.starNum) local __, nextData = DataSheetManager.EquipStar:TryGetDataByStarStage_StarLevel(nextStarStage, nextStarNum) if nextData and not MDL.Unlock.IsTriggerIdComplete(nextData.TriggerID) then local triggerData = DataSheetManager.TriggerID:GetDataByID(nextData.TriggerID) local unlockLevel = UTL.Color.FormatLightRedColor(UTL.Item.GetNobilityByTeamLevel(tonumber(triggerData.Unlock_Table[1].UnlockConditionParamA))) local unlockDesc = UTL.Color.FormatGrayColor(string.FormatByIdsId(Const_IDS.IDS_EquipStar_Tips10, unlockLevel)) self.lab_unlock.text = unlockDesc self.unlockDesc = string.FormatByIdsId(Const_IDS.IDS_EquipStar_Tips10, unlockLevel) self.isUnlock = true self.btn_QuickUpgrade:SetRedPoint(false) self.btn_Upgrade:SetRedPoint(false) end if not self.curSkillMax then local heroId = MDL.Equipment.GetEquipHeroId(self.equipInfo.ID) UIUtils.SetActive(self.img_Up, CTL.Equipment.CheckEquipSkillIfLevelUp(self.equipInfo, heroId)) else UIUtils.SetActive(self.img_Up, false) end end function UIEquipStarMain:IsAllMax() local heroId = MDL.Equipment.GetEquipHeroId(self.equipInfo.ID) local heroInfo = MDL.HeroSelect.GetHeroInfo(heroId) for i, v in ipairs(heroInfo.equipInfos) do if v.starStage > 0 then local nextStarStage, nextStarNum = CTL.Equipment.GetNextStageAndNum(v.starStage, v.starNum) local __, nextData = DataSheetManager.EquipStar:TryGetDataByStarStage_StarLevel(nextStarStage, nextStarNum) if nextData then return false end else return false end end return true end function UIEquipStarMain:IsActiveEquipStar(index) if self.starLevel == MDL.Equipment.EquipStarCountType.None then return false elseif self.starLevel == MDL.Equipment.EquipStarCountType.One and index == 0 then return true elseif self.starLevel == MDL.Equipment.EquipStarCountType.Two and index == 1 then return true elseif self.starLevel == MDL.Equipment.EquipStarCountType.OneAndTwo and index <= 1 then return true elseif self.starLevel == MDL.Equipment.EquipStarCountType.Four and index == 2 then return true elseif self.starLevel == MDL.Equipment.EquipStarCountType.FourAndTwo and (index == 2 or index == 1) then return true elseif self.starLevel == MDL.Equipment.EquipStarCountType.All then return true end return false end return UIEquipStarMain