【牛气冲天】页签根据数据判断显隐

dev_chengFeng
gaoxin 2021-12-08 15:56:08 +08:00
parent 49500da08e
commit d64715ce01
2 changed files with 68 additions and 51 deletions

View File

@ -8,7 +8,7 @@ local itemId = 0
function this.Initialize()
this.InitAllRewardData()
Game.GlobalEvent:AddEvent(GameEvent.Mission.NiuQiChongTianTask,this.UpdateStatus)
this.IsNewActivity = false
-- this.IsNewActivity = false
end
--服务器发来的活动进度条数据
@ -92,52 +92,52 @@ end
--需要显示的任务数据
function this.GetNeedRewardData(sort)
local needData = {}
if not this.IsNewActivity then--老的牛气冲天
for i = 1, 2 do
local tempdata = {}
for k, v in pairs(this.rewardData) do
if v.Sort == sort and v.Type == i and (v.state == 1 or v.state == 0) then
if #tempdata < 1 then
table.insert(tempdata,v)
else
table.insert(tempdata,v)
break
end
end
end
if #tempdata < 2 then
for k = #this.rewardData, 1 , -1 do
local v = this.rewardData[k]
local data = nil
if #tempdata == 0 then
if v.Sort == sort and v.Type == i then
data = v
end
else
for j = 1, #tempdata do
if tempdata[j].id ~= v.id and v.Sort == sort and v.Type == i then
data = v
break
end
end
end
if data then
table.insert(tempdata,data)
if #tempdata >= 2 then
break
end
end
end
end
-- if not this.IsNewActivity then--老的牛气冲天
-- for i = 1, 2 do
-- local tempdata = {}
-- for k, v in pairs(this.rewardData) do
-- if v.Sort == sort and v.Type == i and (v.state == 1 or v.state == 0) then
-- if #tempdata < 1 then
-- table.insert(tempdata,v)
-- else
-- table.insert(tempdata,v)
-- break
-- end
-- end
-- end
-- if #tempdata < 2 then
-- for k = #this.rewardData, 1 , -1 do
-- local v = this.rewardData[k]
-- local data = nil
-- if #tempdata == 0 then
-- if v.Sort == sort and v.Type == i then
-- data = v
-- end
-- else
-- for j = 1, #tempdata do
-- if tempdata[j].id ~= v.id and v.Sort == sort and v.Type == i then
-- data = v
-- break
-- end
-- end
-- end
-- if data then
-- table.insert(tempdata,data)
-- if #tempdata >= 2 then
-- break
-- end
-- end
-- end
-- end
for j = 1,#tempdata do
table.insert(needData,tempdata[j])
end
end
table.sort(needData,function (a,b)
return a.id < b.id
end)
else--新的牛气冲天
-- for j = 1,#tempdata do
-- table.insert(needData,tempdata[j])
-- end
-- end
-- table.sort(needData,function (a,b)
-- return a.id < b.id
-- end)
-- else--新的牛气冲天
for k, v in pairs(this.rewardData) do
if v.Sort == sort then
table.insert(needData,v)
@ -155,7 +155,7 @@ function this.GetNeedRewardData(sort)
return STATE[a.state] > STATE[b.state]
end
end)
end
-- end
return needData
end
@ -209,9 +209,9 @@ end
function this.CheckIsNewActivity()
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.NiuQi)
local data = ConfigManager.GetConfigData(ConfigName.GlobalActivity,id)
if data.ShowArt == 2 then
this.IsNewActivity = true
end
-- if data.ShowArt == 2 then
-- this.IsNewActivity = true
-- end
end
return this

View File

@ -104,6 +104,11 @@ function NiuQiChongTianPanel:OnShow(_sortingOrder)
end
local NiuQiChongTianPanelTabAdapter = function(tab, index, status)
if status == "lock" then
tab:SetActive(false)
return
end
tab:SetActive(true)
local tabLab = Util.GetGameObject(tab, "Text")
local redPoint = Util.GetGameObject(tab, "Redpot")
if _TabData[index].rpType > 0 then
@ -114,7 +119,7 @@ function NiuQiChongTianPanel:OnShow(_sortingOrder)
self.redPointList[_TabData[index].rpType] = redPoint
end
Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = self.spLoader:LoadSprite(_TabData[index][status])
tabLab:GetComponent("Text").text = NiuQiChongTianManager.IsNewActivity and _TabData[index].nameNew or _TabData[index].name
tabLab:GetComponent("Text").text = _TabData[index].nameNew
tabLab:GetComponent("Text").color = _TabFontColor[status]
end
@ -127,8 +132,20 @@ function NiuQiChongTianPanel:OnShow(_sortingOrder)
self:SetReward(bool)
end
-- 没有数据则不显示页签
local IsTabLock = function(index)
-- if index == 1 then
-- return true
-- end
local rewardData = NiuQiChongTianManager.GetNeedRewardData(index)
if not rewardData or #rewardData <= 0 then
return true
end
end
self.TabCtrl = TabBox.New()
self.TabCtrl:SetTabAdapter(NiuQiChongTianPanelTabAdapter)
self.TabCtrl:SetTabIsLockCheck(IsTabLock)
self.TabCtrl:SetChangeTabCallBack(NiuQiChongTianPanelSwitchView)
self.curPage = DynamicActivityManager.NiuQiIndex or 1
self.TabCtrl:Init(self.tabBox, _TabData, self.curPage)