142 lines
4.3 KiB
Lua
142 lines
4.3 KiB
Lua
require("Base/BasePanel")
|
|
local FifteenDayGift = Inherit(BasePanel)
|
|
local this = FifteenDayGift
|
|
local sortingOrder = 0
|
|
local Data
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local itemList = {}
|
|
local canGetList = {}
|
|
|
|
local angle = {
|
|
[1] = Quaternion.Euler(Vector3.New(0, 0, 0)),
|
|
[2] = Quaternion.Euler(Vector3.New(0, 90, 0)),
|
|
}
|
|
|
|
--初始化组件(用于子类重写)
|
|
function FifteenDayGift:InitComponent()
|
|
self.backBtn1 = Util.GetGameObject(self.gameObject,"Content/btnBack1")
|
|
self.backBtn2 = Util.GetGameObject(self.gameObject,"Content/btnBack2")
|
|
self.backBtn3 = Util.GetGameObject(self.gameObject,"Content/btnBack3")
|
|
self.btnGet = Util.GetGameObject(self.gameObject,"Content/btnGet")
|
|
self.rewardGrid = Util.GetGameObject(self.gameObject,"Content/RewardGrid")
|
|
for i = 1, self.rewardGrid.transform.childCount do
|
|
table.insert(itemList, self.rewardGrid.transform:GetChild(i - 1))
|
|
end
|
|
end
|
|
--绑定事件(用于子类重写)
|
|
function FifteenDayGift:BindEvent()
|
|
Util.AddClick(self.backBtn1,function ()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(self.backBtn2,function ()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(self.backBtn3,function ()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(self.btnGet,function ()
|
|
LogPink("领取")
|
|
-- NetManager.GetActivityRewardRequest(-1,data.activityId,function (drop)
|
|
-- UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1,function()
|
|
-- FuXingGaoZhao:Refresh()
|
|
-- end)
|
|
-- end)
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function FifteenDayGift:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function FifteenDayGift:RemoveListener()
|
|
end
|
|
|
|
function FifteenDayGift:OnSortingOrderChange()
|
|
-- Util.AddParticleSortLayer(self.effect, self.sortingOrder - sortingOrder)
|
|
sortingOrder = self.sortingOrder
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function FifteenDayGift:OnOpen()
|
|
end
|
|
|
|
-- 打开,重新打开时回调
|
|
function FifteenDayGift:OnShow()
|
|
FifteenDayGift:Refresh()
|
|
end
|
|
|
|
function FifteenDayGift:Refresh()
|
|
Data = FifteenDayGiftManager.GetData()
|
|
FifteenDayGift:SetReward()
|
|
end
|
|
|
|
function FifteenDayGift:SetReward()
|
|
if Data and #Data.rewards > 0 then
|
|
for i = 1, #itemList do
|
|
FifteenDayGift:SetSingleReward(Data.rewards[i],itemList[i],i)
|
|
end
|
|
end
|
|
end
|
|
|
|
function FifteenDayGift:SetSingleReward(sData,go,index)
|
|
local front = Util.GetGameObject(go,"front")
|
|
local name = Util.GetGameObject(go,"name"):GetComponent("Text")
|
|
local icon = Util.GetGameObject(go,"icon"):GetComponent("Image")
|
|
local num = Util.GetGameObject(go,"num"):GetComponent("Text")
|
|
local back = Util.GetGameObject(go,"back")
|
|
local curTime = GetTimeStamp()
|
|
--设置图片初始角度
|
|
go:GetComponent("RectTransform").rotation = sData.State == 0 and angle[1] or angle[2]
|
|
--判断哪些可领取,插入表
|
|
if sData.Progress <= curTime then
|
|
table.insert(canGetList,go)
|
|
end
|
|
--如果已领取、可领取、不可领取显示第几天;下一领取显示时间
|
|
if sData.Progress > curTime and sData.Progress - 86400 <= curTime then
|
|
local time = sData.Progress
|
|
name.text = TimeToFelaxible(time)
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
self.timer = Timer.New(function()
|
|
time = time - 1
|
|
if time <= 0 then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
FifteenDayGift:Refresh()
|
|
end
|
|
name.text = TimeToFelaxible(time)
|
|
end, 1, -1, true)
|
|
self.timer:Start()
|
|
else
|
|
name.text = itemConfig[sData.Reward[1]].Name
|
|
end
|
|
--设置icon 和数量
|
|
icon.sprite = SetIcon(sData.Reward[1])
|
|
num.text = string.format("X %s",sData.Reward[2])
|
|
|
|
Util.AddOnceClick(icon.gameObject,function ()
|
|
-- body
|
|
end)
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function FifteenDayGift:OnClose()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function FifteenDayGift:OnDestroy()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
itemList = {}
|
|
end
|
|
|
|
return FifteenDayGift |