--[[ 宠物符文突破 ]]-- local UIGodPetRuneBreak = UIViewClass() function UIGodPetRuneBreak:OnCreated() local width = self.rect_Circle:GetSizeDelta() self.radius_BigCircle = width / 2 local smallWidth = self.rect_SmallCircle:GetSizeDelta() self.radius_SmallCircle = smallWidth / 2 end function UIGodPetRuneBreak:OnOpened(context) self:RegistSystemEvent(EventID.UI_Pet_RefreshRuneSubView, self.UpdateInfo) self:RegistSystemEvent(EventID.BagItem_Update, self.UpdateCostMat) self:RegistSystemEvent(EventID.UI_Pet_RuneBreakSuccess, self.OnRuneBreakSuccess) self:InitBigCircleShow() self.isItemEnough = false self.attrList = {} self.slotId = context.slotId self:UpdateInfo() end function UIGodPetRuneBreak:UpdateInfo() local slotInfo = MDL.Pet.GetSlotInfoBySlotId(self.slotId) --因为初始值是读不到配置的,因此用TryGet来读表 local _, curRuneCfg = DataSheetManager.PetRuneStar:TryGetDataByID_PointId(slotInfo.talismanBigBreak, slotInfo.talismanSmallBreak) local nextRuneCfg = CTL.Pet.GetNextRuneCfg(slotInfo) if curRuneCfg == nil then --当前无配置,说明当前是0阶0突破,判断1阶是否大于0阶 UIUtils.SetActive(self.group_Skill, CTL.Pet.CompareRuneNum(1, 0)) else UIUtils.SetActive(self.group_Skill, CTL.Pet.CompareRuneNum(slotInfo.talismanBigBreak + 1, slotInfo.talismanBigBreak)) end UIUtils.SetLabel(self.lab_RuneBreak, string.FormatByIdsId(Const_IDS.IDS_Pet_NowRuneLevel, slotInfo.talismanBigBreak)) UIUtils.SetLabel(self.txt_OldStar, string.FormatByIdsId(Const_IDS.IDS_Horse_Star_2, slotInfo.talismanSmallBreak)) self.curRuneCfg = curRuneCfg self.nextRuneCfg = nextRuneCfg if self.nextRuneCfg then UIUtils.SetLabel(self.txt_Info2Title, string.FormatByIdsId(Const_IDS.IDS_Pet_RuneLevelActive, slotInfo.talismanBigBreak + 1)) if self.nextRuneCfg.ID > slotInfo.talismanBigBreak then UIUtils.SetLabel(self.txt_OldStar, string.FormatByIdsId(Const_IDS.IDS_EquipData_StageShow, slotInfo.talismanBigBreak)) UIUtils.SetLabel(self.txt_NewStar, string.FormatByIdsId(Const_IDS.IDS_EquipData_StageShow, slotInfo.talismanBigBreak + 1)) else UIUtils.SetLabel(self.txt_NewStar, string.FormatByIdsId(Const_IDS.IDS_Horse_Star_2, self.nextRuneCfg.PointId)) end UIUtils.SetActive(self.img_Arrow, true) self.state_Info3:SetState(0) self.effect_Full:StopUIEffect() else --当前是最高等级 UIUtils.SetLabel(self.txt_NewStar, nil) UIUtils.SetActive(self.img_Arrow, false) self.state_Info3:SetState(1) UIUtils.SetActive(self.group_Skill, false) UIUtils.SetLabel(self.txt_OldStar, nil) self.effect_Full:PlayUIEffect() end self:UpdateCostMat() self:UpdateAttrInfo() self:UpdateCircleShow() end function UIGodPetRuneBreak:UpdateAttrInfo() local curLev = self.curRuneCfg and self.curRuneCfg.ID or 0 local _, nextLevelMinCfg = DataSheetManager.PetRuneStar:TryGetDataByID_PointId(curLev + 1, 0) if nextLevelMinCfg then local index = 0 for _, attr in ipairs(nextLevelMinCfg.Attr_Table) do if attr.IsBasic == true then index = index + 1 local item = self.group_Attr[index] if item then local attrData = DataSheetManager.AttrData:GetDataByID(attr.AttrType) local attrValue = attrData.IsPercentShow and UTL.Attr.FormatNumberToPercentage(attr.AttrNum, 0) or attr.AttrNum UIUtils.SetLabel(item, UIUtils.GetLocalizedTxt(Const_IDS[attrData.Name]) .. UTL.Color.FormatGreenColor("+" .. attrValue)) end end end end table.clearArray(self.attrList) local attrList = self.curRuneCfg and self.curRuneCfg.Attr_Table or self.nextRuneCfg.Attr_Table for i, v in ipairs(attrList) do if v.IsBasic == false then table.insert(self.attrList, v) end end self.loop_PetBreakAttr:ReloadAll(self.attrList) end function UIGodPetRuneBreak:UpdateCostMat() if self.nextRuneCfg then self.isItemEnough = true for i, v in ipairs(self.group_Item) do local itemCfg = self.nextRuneCfg.Item_Table[i] if itemCfg then UIUtils.SetActive(v.gameObject, true) local count = MDL.Bag.GetItemCount(itemCfg.ItemID) or 0 if count >= itemCfg.ItemNum then count = UTL.Color.FormatGreenColor(UTL.String.GetCountStr(count)) .. "/" .. UTL.String.GetCountStr(itemCfg.ItemNum) else count = UTL.Color.FormatRedColor(UTL.String.GetCountStr(count)) .. "/" .. UTL.String.GetCountStr(itemCfg.ItemNum) self.isItemEnough = false end UTL.Item.SetItemCell(v, itemCfg.ItemID, count) else UIUtils.SetActive(v.gameObject, false) end end end self.btn_Break:SetRedPoint(self.isItemEnough) end function UIGodPetRuneBreak:OnCellInit(scrollRect, index, cellTable, data) local attrData = DataSheetManager.AttrData:GetDataByID(data.AttrType) local offsetAttrValue = 0 local attrValue if self.curRuneCfg == nil then if attrData.IsPercentShow then offsetAttrValue = UTL.Attr.FormatNumberToPercentage(data.AttrNum, 0) else offsetAttrValue = data.AttrNum end --当前读不到配置,当前属性全是0 attrValue = 0 else if self.nextRuneCfg then for i, v in ipairs(self.nextRuneCfg.Attr_Table) do if v.AttrType == data.AttrType then if attrData.IsPercentShow then offsetAttrValue = UTL.Attr.FormatNumberToPercentage(v.AttrNum, 0) else offsetAttrValue = v.AttrNum end break end end end attrValue = attrData.IsPercentShow and UTL.Attr.FormatNumberToPercentage(data.AttrNum, 0) or data.AttrNum end UTL.Attr.SetAttrIconByAttrIcon(cellTable.img_AttrIcon, attrData.Icon) UIUtils.SetLabelText(cellTable.txt_Attr, Const_IDS[attrData.Name]) cellTable.txt_AttrValue.text = attrValue if offsetAttrValue > 0 then cellTable.txt_NextAttrValue.text = offsetAttrValue UIUtils.SetActive(cellTable.img_Arrow, true) else cellTable.txt_NextAttrValue.text = nil UIUtils.SetActive(cellTable.img_Arrow, false) end end --初始化外圈孔数 function UIGodPetRuneBreak:InitBigCircleShow() local bigCount = 0 for i, v in DataSheetManager.PetRuneStar:GetEnumerator() do if v.PointType == 2 then bigCount = bigCount + 1 end end self:LoadPointPosition(self.content_BreakPoint, self.rect_Circle, self.radius_BigCircle, bigCount) end function UIGodPetRuneBreak:UpdateCircleShow() if self.nextBreakSmallPointItem then self.nextBreakSmallPointItem.effect_Light:PlayUIEffect() self.nextBreakSmallPointItem = nil end local hasBigBreakCount, hasSmallBreakCount, totalSmallBreakCount = 0, 0, 0 if self.curRuneCfg == nil then for i, v in DataSheetManager.PetRuneStar:GetDataByID_PointId(0) do if v.PointId > 0 then totalSmallBreakCount = totalSmallBreakCount + 1 end end hasBigBreakCount = 0 hasSmallBreakCount = 0 else for i, v in DataSheetManager.PetRuneStar:GetDataByID_PointId(self.curRuneCfg.ID) do if v.PointId > 0 then totalSmallBreakCount = totalSmallBreakCount + 1 end end hasBigBreakCount = self.curRuneCfg.ID hasSmallBreakCount = self.curRuneCfg.PointId end --已突破孔数的表现 self:LoadHasBigBreakPoint(hasBigBreakCount) self:LoadSmallBreakPoint(totalSmallBreakCount, hasSmallBreakCount) if totalSmallBreakCount == hasSmallBreakCount then self.effect_Full:PlayUIEffect() else self.effect_Full:StopUIEffect() end end function UIGodPetRuneBreak:LoadHasBigBreakPoint(hasBreakCount) local totalNum = #self.content_BreakPoint for i = 1, totalNum do if i <= hasBreakCount then UIUtils.SetActive(self.content_BreakPoint[i].effect_Light, true) else UIUtils.SetActive(self.content_BreakPoint[i].effect_Light, false) end end local progress = hasBreakCount == totalNum and 1 or (1 - (totalNum - hasBreakCount + 1) / totalNum) UIUtils.SetAtlasImageFillAmount(self.img_BreakBar, progress) end function UIGodPetRuneBreak:LoadSmallBreakPoint(num, hasBreakCount) self:LoadPointPosition(self.content_SmallBreakPoint, self.rect_SmallCircle, self.radius_SmallCircle, num) for i = 1, num do if i <= hasBreakCount then UIUtils.SetActive(self.content_SmallBreakPoint[i].group_UnBreak, false) UIUtils.SetActive(self.content_SmallBreakPoint[i].group_Break, true) else UIUtils.SetActive(self.content_SmallBreakPoint[i].group_UnBreak, true) UIUtils.SetActive(self.content_SmallBreakPoint[i].group_Break, false) if i == hasBreakCount + 1 then self.nextBreakSmallPointItem = self.content_SmallBreakPoint[i] end end end end function UIGodPetRuneBreak:LoadPointPosition(content, circle, radius, num) local perAngle = 360 / num local contentRoot = content.gameObject.transform for i = 1, num do circle:SetLocalEulerAngles(0, 0, 0) local item = content[i] if item == nil then item = self:InstantiateCollection(content, content[1].gameObject) else UIUtils.SetActive(content[i].gameObject, true) end local trans = item.gameObject.transform trans:SetParent(circle, true) trans:SetAnchoredPosition(0, radius) local tarAngle = -perAngle * (i - 1) circle:SetLocalEulerAngles(0, 0, tarAngle) trans:SetParent(contentRoot, true) trans:SetLocalEulerAngles(0, 0, 0) end for i = num + 1, #content do UIUtils.SetActive(content[i].gameObject, false) end end function UIGodPetRuneBreak:OnButtonClicked(comp) if comp == self.btn_Cheak then local slotInfo = MDL.Pet.GetSlotInfoBySlotId(self.slotId) UIManager.OpenView(Const_UI_Lua.UIEnum.UIPetRuneBreakDetail, { Level = slotInfo.talismanBigBreak }, Const_UI_Lua.UIEnum.UIHeroInfoView) elseif comp == self.btn_Break then if self.isItemEnough == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroStar_NotEngouh) return end CTL.Sound.PlayGameSound("UI_breakthrough_01") MDL.Pet.PetTalismanBreakReq(self.slotId) else for i, v in ipairs(self.group_Item) do if comp == v.event_Click then local itemCfg = self.nextRuneCfg.Item_Table[i] UTL.ItemTips.ShowCommonTipsById(itemCfg.ItemID) end end end end function UIGodPetRuneBreak:OnRuneBreakSuccess() self.effect_BreakSuccess:PlayUIEffect() end return UIGodPetRuneBreak