miduo_client/Assets/ManagedResources/~Lua/Modules/Explore/ExploreRewardPopup.lua

126 lines
4.3 KiB
Lua
Raw Normal View History

2021-12-23 13:09:34 +08:00
require("Base/BasePanel")
local FightAreaRewardPopup = Inherit(BasePanel)
local this = FightAreaRewardPopup
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local _ProductList = {}
local _ItemList = {}
local _RewardList = {}
local _ExtraRewardList = {}
--初始化组件(用于子类重写)
function FightAreaRewardPopup:InitComponent()
this.spLoader = SpriteLoader.New()
this.btnBack = Util.GetGameObject(this.transform, "mask")
this.rewardPre = Util.GetGameObject(this.transform, "showMopUp/reward")
this.itemRoot = Util.GetGameObject(this.transform, "showMopUp/scroller")
this.itemList = {}
end
--绑定事件(用于子类重写)
function FightAreaRewardPopup:BindEvent()
Util.AddClick(this.btnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
this:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function FightAreaRewardPopup:AddListener()
end
--移除事件监听(用于子类重写)
function FightAreaRewardPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function FightAreaRewardPopup:OnOpen(mapId)
this.mapId = mapId
end
--
local orginLayer = -1
function this:OnSortingOrderChange()
-- Util.AddParticleSortLayer(this.privilegeEffect, this.sortingOrder - orginLayer)
orginLayer = this.sortingOrder
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function FightAreaRewardPopup:OnShow()
this.data = ExploreManager.GetFormationDataByMapId(this.mapId)
for i = 1,math.max(#this.data,#this.itemList) do
if not this.data[i] then
this.itemList[i].go.gameObject:SetActive(false)
else
if not this.itemList[i] then
this.itemList[i] = {}
this.itemList[i].reward = {}
this.itemList[i].go = newObjToParent(this.rewardPre,this.itemRoot)
this.itemList[i].name = Util.GetGameObject(this.itemList[i].go, "name"):GetComponent("Text")
this.itemList[i].time = Util.GetGameObject(this.itemList[i].go, "time"):GetComponent("Text")
this.itemList[i].exploring = Util.GetGameObject(this.itemList[i].go, "exploring")
this.itemList[i].grid = Util.GetGameObject(this.itemList[i].go, "grid")
end
this:Refresh(this.itemList[i],this.data[i])
end
end
this:TimeCountDown()
end
function this:Refresh(_item,_data)
if _data.state == 0 then
_item.go.gameObject:SetActive(false)
else
_item.go.gameObject:SetActive(true)
end
_item.data = _data
_item.name.text = string.format("队伍%s",_data.index)
for i = 1,math.max(#this.itemList[i].reward,#_data.dropReward) do
if not _data.dropReward[i] then
this.itemList[i].reward[i].gameObject:SetActive(false)
else
if not this.itemList[i].reward[i] then
this.itemList[i].reward[i] = SubUIManager.Open(SubUIConfig.ItemView,this.itemList[i].grid.transform)
end
this.itemList[i].reward[i].gameObject:SetActive(true)
--this.itemList[i].reward[i]:OnOpen(false, {data1,data2},0.7,false,false,false,orginLayer)
end
end
Util.AddOnceClick(_item.exploring,function()
end)
end
function this:TimeCountDown()
if this.timer then
this.timer:Stop()
this.timer = nil
end
this.timer = Timer.New(function()
for i = 1,#this.itemList do
if this.itemList[i].data and this.itemList[i].data.state > 0 then
local time = this.itemList[i].data.exploreTime - GetTimeStamp()
if time < 0 then
this.itemList[i].data.state = 0
this.itemList[i].data.exploreTime = 0
this:Refresh(this.itemList[i],this.itemList[i].data)
else
this.itemList[i].time.text = string.format("%后结束",TimeStampToDateStr3new(time))
end
end
end
end,1,-1,true)
this.timer:Start()
end
--界面关闭时调用(用于子类重写)
function FightAreaRewardPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function FightAreaRewardPopup:OnDestroy()
this.spLoader:Destroy()
this.itemList = {}
end
return FightAreaRewardPopup