From 244db761356038d21a2f2ed174b7653f3768a5c9 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 10 Feb 2022 17:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9B=9B=E5=85=83=E9=98=B5=E3=80=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A6=82=E7=8E=87=E5=9F=BA=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Hero/HeroManager.lua | 30 ++++++++++++ .../~Lua/Modules/Recruit/HeroPreviewPanel.lua | 46 ++++++++++++------- .../~Lua/Modules/Recruit/RecruitManager.lua | 20 ++++++++ 3 files changed, 79 insertions(+), 17 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua b/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua index 680d996b2d..846bfbec19 100644 --- a/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua @@ -4253,4 +4253,34 @@ function this.CalculatePvpBonusForShow(data) return data end +-- 判断英雄是否进入版本 +function this.InVersion(heroTid) + if not heroTid then + return + end + local con = heroConfig[heroTid] + if not con or not con.Version then + return + end + local serverOpenTime = PlayerManager.GetServerOpenTime() + local openDay = math.max(0, GetTimeStamp() - serverOpenTime)/(60*60*24)--当前是开服第几天 + if openDay >= con.Version then + return true + end +end + +-- 英雄碎片id转英雄id +function this.ChipIdToHeroId(chipId) + local item = itemConfig[chipId] + if not item then + return + end + local reward = rewardGroup[item.RewardGroup[1]] + if not reward or not reward.ShowItem or not reward.ShowItem[1] then + return + end + local heroId = reward.ShowItem[1][1] + return heroId +end + return this \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Modules/Recruit/HeroPreviewPanel.lua b/Assets/ManagedResources/~Lua/Modules/Recruit/HeroPreviewPanel.lua index 4a22151782..10e6b7ce11 100644 --- a/Assets/ManagedResources/~Lua/Modules/Recruit/HeroPreviewPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Recruit/HeroPreviewPanel.lua @@ -84,6 +84,7 @@ end --第一个参数是否是英雄或元素 --第二个参数是否显示tab 如果没有,则显示,如果有,则根据第二个参数 function HeroPreviewPanel:OnOpen(...) + this.AllWeightTemp = {} this.heroGrid.transform.anchoredPosition = Vector2.New(0,0) this.elementGrid.transform.anchoredPosition = Vector2.New(0,0) local temp={...} @@ -107,23 +108,27 @@ function HeroPreviewPanel:OnOpen(...) if RecruitManager.isFirstEnterElementScroll then --元素 RecruitManager.isFirstEnterElementScroll=false for i,v in pairs(RecruitManager.previewElementData) do - Log(v.Pool) - if(v.Pool==11) then - local view = SubUIManager.Open(SubUIConfig.ItemView,this.waterGrid.transform) - view:OnOpen(false, {v.Reward[1], v.Reward[2] },1.1,true) - view.name:GetComponent("Text").text=""..string.format("%.2f",(v.WeightShow/100000)*100) .."%" - elseif(v.Pool==12) then - local view = SubUIManager.Open(SubUIConfig.ItemView,this.fireGrid.transform) - view:OnOpen(false, {v.Reward[1], v.Reward[2] },1.1,true) - view.name:GetComponent("Text").text=""..string.format("%.2f",(v.WeightShow/100000)*100) .."%" - elseif(v.Pool==13) then - local view = SubUIManager.Open(SubUIConfig.ItemView,this.windyGrid.transform) - view:OnOpen(false, {v.Reward[1], v.Reward[2] },1.1,true) - view.name:GetComponent("Text").text=""..string.format("%.2f",(v.WeightShow/100000)*100) .."%" - elseif(v.Pool==14) then - local view = SubUIManager.Open(SubUIConfig.ItemView,this.groundGrid.transform) - view:OnOpen(false, {v.Reward[1], v.Reward[2] },1.1,true) - view.name:GetComponent("Text").text=""..string.format("%.2f",(v.WeightShow/100000)*100) .."%" + local chipId = v.Reward[1] + local heroId = HeroManager.ChipIdToHeroId(chipId) + if not heroId or HeroManager.InVersion(heroId) then + local allWeight = this.GetAllWeight(v.Pool) + if(v.Pool==11) then + local view = SubUIManager.Open(SubUIConfig.ItemView,this.waterGrid.transform) + view:OnOpen(false, {v.Reward[1], v.Reward[2] },1.1,true) + view.name:GetComponent("Text").text=""..string.format("%.2f",(v.WeightShow/allWeight)*100) .."%" + elseif(v.Pool==12) then + local view = SubUIManager.Open(SubUIConfig.ItemView,this.fireGrid.transform) + view:OnOpen(false, {v.Reward[1], v.Reward[2] },1.1,true) + view.name:GetComponent("Text").text=""..string.format("%.2f",(v.WeightShow/allWeight)*100) .."%" + elseif(v.Pool==13) then + local view = SubUIManager.Open(SubUIConfig.ItemView,this.windyGrid.transform) + view:OnOpen(false, {v.Reward[1], v.Reward[2] },1.1,true) + view.name:GetComponent("Text").text=""..string.format("%.2f",(v.WeightShow/allWeight)*100) .."%" + elseif(v.Pool==14) then + local view = SubUIManager.Open(SubUIConfig.ItemView,this.groundGrid.transform) + view:OnOpen(false, {v.Reward[1], v.Reward[2] },1.1,true) + view.name:GetComponent("Text").text=""..string.format("%.2f",(v.WeightShow/allWeight)*100) .."%" + end end end this.elementScroll:SetActive(true) @@ -132,6 +137,13 @@ function HeroPreviewPanel:OnOpen(...) end end +function this.GetAllWeight(pool) + if not this.AllWeightTemp[pool] then + this.AllWeightTemp[pool] = RecruitManager.GetAllWeightByPool(pool) + end + return this.AllWeightTemp[pool] +end + function HeroPreviewPanel:OnShow() end diff --git a/Assets/ManagedResources/~Lua/Modules/Recruit/RecruitManager.lua b/Assets/ManagedResources/~Lua/Modules/Recruit/RecruitManager.lua index 4a4c930019..a11b7ce812 100644 --- a/Assets/ManagedResources/~Lua/Modules/Recruit/RecruitManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Recruit/RecruitManager.lua @@ -650,4 +650,24 @@ function this.GetRecruitData() return dicData end +-- 获取某个奖池的总权重 +function this.GetAllWeightByPool(pool) + local all = 0 + for i, v in ConfigPairs(lotteryRewardConfig) do + if v.Pool == pool then + -- 四元阵需要判断是否进入版本 + local weight = v.WeightShow + if v.Pool==11 or v.Pool==12 or v.Pool==13 or v.Pool==14 then + local chipId = v.Reward[1] + local heroId = HeroManager.ChipIdToHeroId(chipId) + if heroId and not HeroManager.InVersion(heroId) then + weight = 0 + end + end + all = all + weight + end + end + return all +end + return this \ No newline at end of file