405 lines
16 KiB
Lua
405 lines
16 KiB
Lua
require("Base/BasePanel")
|
|
HeroPreviewNewPanel = Inherit(BasePanel)
|
|
local this=HeroPreviewNewPanel
|
|
local roleData={}
|
|
local viewList={}
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
--Tab
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabData={[1] = { default = "UI_hz_gonghui_19", select = "UI_hz_gonghui_18", name = Language[10536] },
|
|
[2] = { default = "UI_hz_gonghui_19", select = "UI_hz_gonghui_18", name = "生命卡" },
|
|
--[3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[10306] }
|
|
}
|
|
local _TabFontColor = { default = Color.New(255 / 255, 255 / 255, 255 / 255, 1),
|
|
select = Color.New(255 / 255, 255 / 255, 255 / 255, 1)}
|
|
--上一模块索引
|
|
local curIndex=0
|
|
|
|
local dataType={
|
|
[1]=PRE_REWARD_POOL_TYPE.RECRUIT,
|
|
[2]=PRE_REWARD_POOL_TYPE.FRIEND,
|
|
[3]=PRE_REWARD_POOL_TYPE.NORMAL,
|
|
[4]=PRE_REWARD_POOL_TYPE.TIME_LIMITED_NEW_UP,
|
|
}
|
|
local itemList={}
|
|
function HeroPreviewNewPanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.cardPre = Util.GetGameObject(self.gameObject, "item")
|
|
this.ScrollBar = Util.GetGameObject(self.gameObject, "bg/Scrollbar"):GetComponent("Scrollbar")
|
|
this.BtnBack = Util.GetGameObject(self.transform, "bg/btnBack")
|
|
this.titleItem=Util.GetGameObject(self.transform, "titleItem")
|
|
this.heroScroll=Util.GetGameObject(self.transform, "bg/heroScroll")
|
|
this.heroScrollGrid=Util.GetGameObject(self.transform,"bg/heroScroll/grid")
|
|
this.elementScroll=Util.GetGameObject(self.transform, "bg/elementScroll")
|
|
|
|
this.sevenGrid=Util.GetGameObject(self.transform, "bg/heroScroll/grid/sevenGrid")
|
|
this.sevenStarNum=Util.GetGameObject(self.transform, "bg/heroScroll/grid/sevenStarNum")
|
|
this.sixGrid=Util.GetGameObject(self.transform, "bg/heroScroll/grid/sixGrid")
|
|
this.sixStarNum=Util.GetGameObject(self.transform, "bg/heroScroll/grid/sixStarNum")
|
|
this.fiveGrid=Util.GetGameObject(self.transform, "bg/heroScroll/grid/fiveGrid")
|
|
this.fiveStarNum=Util.GetGameObject(self.transform, "bg/heroScroll/grid/fiveStarNum")
|
|
this.fourGrid=Util.GetGameObject(self.transform, "bg/heroScroll/grid/fourGrid")
|
|
this.fourStarNum=Util.GetGameObject(self.transform, "bg/heroScroll/grid/fourStarNum")
|
|
this.threeGrid=Util.GetGameObject(self.transform, "bg/heroScroll/grid/threeGrid")
|
|
this.threeStarNum=Util.GetGameObject(self.transform, "bg/heroScroll/grid/threeStarNum")
|
|
this.twoGrid=Util.GetGameObject(self.transform, "bg/heroScroll/grid/twoGrid")
|
|
this.twoStarNum=Util.GetGameObject(self.transform, "bg/heroScroll/grid/twoStarNum")
|
|
this.oneGrid=Util.GetGameObject(self.transform, "bg/heroScroll/grid/oneGrid")
|
|
this.oneStarNum=Util.GetGameObject(self.transform, "bg/heroScroll/grid/oneStarNum")
|
|
|
|
this.darkGrid=Util.GetGameObject(self.transform, "bg/elementScroll/grid/DarkGrid")
|
|
this.fireGrid=Util.GetGameObject(self.transform, "bg/elementScroll/grid/FireGrid")
|
|
this.waterGrid=Util.GetGameObject(self.transform, "bg/elementScroll/grid/WaterGrid")
|
|
this.windyGrid=Util.GetGameObject(self.transform, "bg/elementScroll/grid/WindyGrid")
|
|
this.groundGrid=Util.GetGameObject(self.transform, "bg/elementScroll/grid/GroundGrid")
|
|
this.grid=Util.GetGameObject(self.transform, "bg/scroll/ScrollCycleView/grid")
|
|
|
|
this.heroGrid=Util.GetGameObject(self.transform, "bg/heroScroll/grid")
|
|
this.elementGrid=Util.GetGameObject(self.transform, "bg/elementScroll/grid")
|
|
this.viewCache = {}
|
|
|
|
--其他
|
|
this.other = Util.GetGameObject(self.gameObject, "bg/otherRoot")
|
|
this.other:SetActive(false)
|
|
|
|
--tabbox
|
|
this.tabBox = Util.GetGameObject(self.gameObject, "bg/TabBox")
|
|
this.List1={}
|
|
this.List2={}
|
|
this.List3={}
|
|
this.List4={}
|
|
this.List5={}
|
|
this.List6={}
|
|
this.List7={}
|
|
end
|
|
|
|
function HeroPreviewNewPanel:BindEvent()
|
|
Util.AddClick(this.BtnBack, function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
self:ClosePanel()
|
|
end)
|
|
end
|
|
|
|
function HeroPreviewNewPanel:AddListener()
|
|
end
|
|
|
|
function HeroPreviewNewPanel:RemoveListener()
|
|
end
|
|
|
|
function HeroPreviewNewPanel:OnSortingOrderChange()
|
|
this.sortingOrder = self.sortingOrder
|
|
end
|
|
|
|
--第一个参数是否是英雄或元素
|
|
--第二个参数是否显示tab 如果没有,则显示,如果有,则根据第二个参数
|
|
function HeroPreviewNewPanel:OnOpen(...)
|
|
this.heroGrid.transform.anchoredPosition = Vector2.New(0,0)
|
|
this.elementGrid.transform.anchoredPosition = Vector2.New(0,0)
|
|
local temp={...}
|
|
if temp and temp[1] ~= nil then
|
|
this.heroScroll:SetActive(temp[1])
|
|
this.elementScroll:SetActive(not temp[1])
|
|
this.tabBox:SetActive(temp[1])
|
|
end
|
|
|
|
if temp[1] then --英雄招募
|
|
if #temp==1 or temp[2] then
|
|
this.TabCtrl = TabBox.New()
|
|
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
|
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
|
|
this.TabCtrl:Init(this.tabBox, _TabData,temp[3] or 1)
|
|
else
|
|
this.tabBox:SetActive(temp[2])
|
|
this.SwitchView(4)
|
|
end
|
|
else
|
|
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) .."%"
|
|
end
|
|
end
|
|
this.elementScroll:SetActive(true)
|
|
this.tabBox:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
function HeroPreviewNewPanel:OnShow()
|
|
|
|
end
|
|
function HeroPreviewNewPanel:OnClose()
|
|
|
|
end
|
|
|
|
function HeroPreviewNewPanel:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
this.List1={}
|
|
this.List2={}
|
|
this.List3={}
|
|
this.List4={}
|
|
this.List5={}
|
|
this.List6={}
|
|
this.List7={}
|
|
itemList={}
|
|
RecruitManager.isFirstEnterElementScroll=true
|
|
RecruitManager.isFirstEnterHeroScroll=true
|
|
end
|
|
|
|
|
|
-- tab节点显示自定义
|
|
function this.TabAdapter(tab, index, status)
|
|
local tabLab = Util.GetGameObject(tab, "Text")
|
|
Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
|
|
Util.GetGameObject(tab,"Image"):GetComponent("Image"):SetNativeSize()
|
|
tabLab:GetComponent("Text").text = _TabData[index].name
|
|
tabLab:GetComponent("Text").color = _TabFontColor[status]
|
|
end
|
|
|
|
--切换视图
|
|
function this.SwitchView(index)
|
|
local oldSelect
|
|
oldSelect, curIndex = curIndex, index
|
|
this.heroScrollGrid.transform:DOAnchorPosY(0,0)
|
|
local oneData = {}
|
|
local twoData = {}
|
|
local threeData = {}
|
|
local fourData = {}
|
|
local fiveData={}
|
|
local sixData={}
|
|
local sevenData={}
|
|
for index, v in ipairs(RecruitManager.GetRewardPreviewData(dataType[curIndex])) do
|
|
-- if curIndex==2 then
|
|
-- LogError("v.v.Reward[1].quan=="..v.Quality)
|
|
-- if v.Quality==1 then
|
|
-- table.insert(oneData,v)
|
|
-- elseif v.Quality==2 then
|
|
-- table.insert(twoData,v)
|
|
-- elseif v.Quality==3 then
|
|
-- table.insert(threeData,v)
|
|
-- elseif v.Quality==4 then
|
|
-- table.insert(fourData,v)
|
|
-- elseif v.Quality==5 then
|
|
-- table.insert(fiveData,v)
|
|
-- elseif v.Quality==6 then
|
|
-- table.insert(sixData,v)
|
|
-- elseif v.Quality==7 then
|
|
-- table.insert(sevenData,v)
|
|
-- end
|
|
-- else
|
|
if itemConfig[v.Reward[1]].HeroQuantity==1 then
|
|
table.insert(oneData,v)
|
|
elseif itemConfig[v.Reward[1]].HeroQuantity==2 then
|
|
table.insert(twoData,v)
|
|
elseif itemConfig[v.Reward[1]].HeroQuantity==3 then
|
|
table.insert(threeData,v)
|
|
elseif itemConfig[v.Reward[1]].HeroQuantity==4 then
|
|
table.insert(fourData,v)
|
|
elseif itemConfig[v.Reward[1]].HeroQuantity==5 then
|
|
table.insert(fiveData,v)
|
|
elseif itemConfig[v.Reward[1]].HeroQuantity==6 then
|
|
table.insert(sixData,v)
|
|
elseif itemConfig[v.Reward[1]].HeroQuantity==7 then
|
|
table.insert(sevenData,v)
|
|
end
|
|
--end
|
|
|
|
end
|
|
if index == 3 then
|
|
for i = 1, #oneData do
|
|
if not this.List1[i] then
|
|
this.List1[i] = SubUIManager.Open(SubUIConfig.ItemView,this.oneGrid.transform)
|
|
end
|
|
this.List1[i]:OnOpen(false, {oneData[i].Reward[1], oneData[i].Reward[2]}, 1.1, true)
|
|
this.List1[i].name:GetComponent("Text").text=""..string.format("%.2f", (oneData[i].WeightShow/100000)*100) .."%"
|
|
this.List1[i].gameObject:SetActive(true)
|
|
|
|
end
|
|
end
|
|
if #oneData==0 then
|
|
this.oneStarNum:SetActive(false)
|
|
this.oneGrid:SetActive(false)
|
|
else
|
|
this.oneStarNum:SetActive(true)
|
|
this.oneGrid:SetActive(true)
|
|
end
|
|
if index == 2 or index ==3 then
|
|
for i = 1, #twoData do
|
|
if not this.List2[i] then
|
|
this.List2[i] = SubUIManager.Open(SubUIConfig.ItemView,this.twoGrid.transform)
|
|
end
|
|
this.List2[i]:OnOpen(false, {twoData[i].Reward[1], twoData[i].Reward[2]}, 1.1, true)
|
|
this.List2[i].name:GetComponent("Text").text=""..string.format("%.2f", (twoData[i].WeightShow/100000)*100) .."%"
|
|
this.List2[i].gameObject:SetActive(true)
|
|
|
|
end
|
|
end
|
|
if #twoData==0 then
|
|
this.twoStarNum:SetActive(false)
|
|
this.twoGrid:SetActive(false)
|
|
else
|
|
this.twoStarNum:SetActive(true)
|
|
this.twoGrid:SetActive(true)
|
|
end
|
|
for i = 1, #this.List3 do
|
|
if this.List3[i] then
|
|
this.List3[i].gameObject:SetActive(false)
|
|
|
|
end
|
|
end
|
|
for i = 1, #threeData do
|
|
if not this.List3[i] then
|
|
this.List3[i] = SubUIManager.Open(SubUIConfig.ItemView,this.threeGrid.transform)
|
|
this.List3[i].gameObject:SetActive(true)
|
|
end
|
|
this.List3[i]:OnOpen(false, {threeData[i].Reward[1], threeData[i].Reward[2]}, 1.1, true)
|
|
this.List3[i].name:GetComponent("Text").text=""..string.format("%.2f", (threeData[i].WeightShow/100000)*100) .."%"
|
|
this.List3[i].gameObject:SetActive(true)
|
|
|
|
end
|
|
if #threeData==0 then
|
|
this.threeStarNum:SetActive(false)
|
|
this.threeGrid:SetActive(false)
|
|
else
|
|
this.threeStarNum:SetActive(true)
|
|
this.threeGrid:SetActive(true)
|
|
end
|
|
for i = 1, #this.List4 do
|
|
if this.List4[i] then
|
|
this.List4[i].gameObject:SetActive(false)
|
|
|
|
end
|
|
end
|
|
for i = 1, #fourData do
|
|
if not this.List4[i] then
|
|
this.List4[i] = SubUIManager.Open(SubUIConfig.ItemView,this.fourGrid.transform)
|
|
this.List4[i].gameObject:SetActive(true)
|
|
end
|
|
this.List4[i]:OnOpen(false, {fourData[i].Reward[1], fourData[i].Reward[2]}, 1.1, true)
|
|
this.List4[i].name:GetComponent("Text").text=""..string.format("%.2f", (fourData[i].WeightShow/100000)*100) .."%"
|
|
this.List4[i].gameObject:SetActive(true)
|
|
|
|
end
|
|
if #fourData==0 then
|
|
this.fourStarNum:SetActive(false)
|
|
this.fourGrid:SetActive(false)
|
|
else
|
|
this.fourStarNum:SetActive(true)
|
|
this.fourGrid:SetActive(true)
|
|
end
|
|
for i = 1, #this.List5 do
|
|
if this.List5[i] then
|
|
this.List5[i].gameObject:SetActive(false)
|
|
this.List5[i].gameObject.transform.parent.gameObject:SetActive(false)
|
|
end
|
|
end
|
|
for i = 1, #fiveData do
|
|
if not this.List5[i] then
|
|
this.List5[i] = SubUIManager.Open(SubUIConfig.ItemView,this.fiveGrid.transform)
|
|
this.List5[i].gameObject:SetActive(true)
|
|
end
|
|
this.List5[i]:OnOpen(false, {fiveData[i].Reward[1], fiveData[i].Reward[2]}, 1.1, true)
|
|
this.List5[i].name:GetComponent("Text").text=""..string.format("%.2f", (fiveData[i].WeightShow/100000)*100) .."%"
|
|
this.List5[i].gameObject:SetActive(true)
|
|
this.List5[i].gameObject.transform.parent.gameObject:SetActive(true)
|
|
end
|
|
if #fiveData==0 then
|
|
this.fiveStarNum:SetActive(false)
|
|
this.fiveGrid:SetActive(false)
|
|
else
|
|
this.fiveStarNum:SetActive(true)
|
|
this.fiveGrid:SetActive(true)
|
|
end
|
|
for i = 1, #this.List6 do
|
|
if this.List6[i] then
|
|
this.List6[i].gameObject:SetActive(false)
|
|
this.List6[i].gameObject.transform.parent.gameObject:SetActive(false)
|
|
end
|
|
end
|
|
for i = 1, #sixData do
|
|
if not this.List6[i] then
|
|
this.List6[i] = SubUIManager.Open(SubUIConfig.ItemView,this.sixGrid.transform)
|
|
this.List6[i].gameObject:SetActive(true)
|
|
end
|
|
this.List6[i]:OnOpen(false, {sixData[i].Reward[1], sixData[i].Reward[2]}, 1.1, true)
|
|
this.List6[i].name:GetComponent("Text").text=""..string.format("%.2f", (sixData[i].WeightShow/100000)*100) .."%"
|
|
this.List6[i].gameObject:SetActive(true)
|
|
this.List6[i].gameObject.transform.parent.gameObject:SetActive(true)
|
|
end
|
|
if #sixData==0 then
|
|
this.sixStarNum:SetActive(false)
|
|
this.sixGrid:SetActive(false)
|
|
else
|
|
this.sixStarNum:SetActive(true)
|
|
this.sixGrid:SetActive(true)
|
|
end
|
|
-- for i = 1, #sixData do
|
|
-- if not this.List6[i] then
|
|
-- this.List6[i] = SubUIManager.Open(SubUIConfig.ItemView,this.sixGrid.transform)
|
|
-- this.List6[i].gameObject:SetActive(true)
|
|
-- end
|
|
-- this.List6[i]:OnOpen(false, {sixData[i].Reward[1], sixData[i].Reward[2]}, 1.1, true)
|
|
-- this.List6[i].name:GetComponent("Text").text=""..string.format("%.2f", (sixData[i].WeightShow/100000)*100) .."%"
|
|
-- this.List6[i].gameObject:SetActive(true)
|
|
-- end
|
|
for i = 1, #this.List7 do
|
|
if this.List7[i] then
|
|
this.List7[i].gameObject:SetActive(false)
|
|
end
|
|
end
|
|
for i = 1, #sevenData do
|
|
if not this.List7[i] then
|
|
this.List7[i] = SubUIManager.Open(SubUIConfig.ItemView,this.sevenGrid.transform)
|
|
this.List7[i].gameObject:SetActive(true)
|
|
end
|
|
this.List7[i]:OnOpen(false, {sevenData[i].Reward[1], sevenData[i].Reward[2]}, 1.1, true)
|
|
this.List7[i].name:GetComponent("Text").text=""..string.format("%.2f", (sevenData[i].WeightShow/100000)*100) .."%"
|
|
this.List7[i].gameObject:SetActive(true)
|
|
end
|
|
if #sevenData==0 then
|
|
this.sevenStarNum:SetActive(false)
|
|
this.sevenGrid:SetActive(false)
|
|
else
|
|
this.sevenStarNum:SetActive(true)
|
|
this.sevenGrid:SetActive(true)
|
|
end
|
|
this.starGridSwitch(index)
|
|
end
|
|
|
|
function this.starGridSwitch(index)
|
|
if index ==1 or index==4 then
|
|
this.oneStarNum:SetActive(false)
|
|
this.oneGrid:SetActive(false)
|
|
this.twoStarNum:SetActive(false)
|
|
this.twoGrid:SetActive(false)
|
|
elseif index == 2 then
|
|
this.oneStarNum:SetActive(false)
|
|
this.oneGrid:SetActive(false)
|
|
this.twoStarNum:SetActive(false)
|
|
this.twoGrid:SetActive(false)
|
|
else
|
|
this.oneStarNum:SetActive(true)
|
|
this.oneGrid:SetActive(true)
|
|
this.twoStarNum:SetActive(true)
|
|
this.twoGrid:SetActive(true)
|
|
end
|
|
end
|
|
|
|
return HeroPreviewNewPanel |