2021-04-01 18:36:34 +08:00
|
|
|
|
require("Base/BasePanel")
|
2021-03-29 09:52:53 +08:00
|
|
|
|
local FuXingGaoZhao = Inherit(BasePanel)
|
|
|
|
|
local this = FuXingGaoZhao
|
|
|
|
|
local sortingOrder = 0
|
2021-03-30 10:27:18 +08:00
|
|
|
|
local rewardList = {}
|
|
|
|
|
local itemPreList={} --item预设容器
|
|
|
|
|
local data
|
2021-03-30 20:20:12 +08:00
|
|
|
|
local func
|
2021-03-29 09:52:53 +08:00
|
|
|
|
|
2021-03-30 16:24:28 +08:00
|
|
|
|
local timeData = string.split(ConfigManager.GetConfigDataByKey(ConfigName.SpecialConfig,"Id",109).Value,"#")
|
2021-03-29 09:52:53 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function FuXingGaoZhao:InitComponent()
|
|
|
|
|
self.backBtn = Util.GetGameObject(self.gameObject,"btnBack")
|
2021-03-30 10:27:18 +08:00
|
|
|
|
self.effect = Util.GetGameObject(self.gameObject,"UI_effect_LuckyCatPanel_normal")
|
|
|
|
|
self.time = Util.GetGameObject(self.gameObject,"Time"):GetComponent("Text")
|
|
|
|
|
self.getBtn = Util.GetGameObject(self.gameObject,"getBtn")
|
2021-03-29 09:52:53 +08:00
|
|
|
|
FuXingGaoZhaoManager.InitRewardData()
|
2021-03-30 10:27:18 +08:00
|
|
|
|
self.mid = Util.GetGameObject(self.gameObject,"mid")
|
|
|
|
|
if #rewardList == 0 then
|
|
|
|
|
for i = 1, self.mid.transform.childCount do
|
|
|
|
|
table.insert(rewardList,self.mid.transform:GetChild(i-1))
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-03-30 16:55:45 +08:00
|
|
|
|
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft})
|
2021-03-29 09:52:53 +08:00
|
|
|
|
end
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function FuXingGaoZhao:BindEvent()
|
|
|
|
|
Util.AddClick(self.backBtn,function ()
|
2021-03-30 17:53:01 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.FuXingGaoZhao)
|
2021-03-29 09:52:53 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
2021-03-30 10:27:18 +08:00
|
|
|
|
|
|
|
|
|
Util.AddClick(self.getBtn,function ()
|
|
|
|
|
if data.ActState == 0 then
|
2021-03-30 18:50:15 +08:00
|
|
|
|
local configData = ConfigManager.GetConfigDataByKey(ConfigName.SpecialConfig,"Id",110).Value
|
2021-03-30 20:20:12 +08:00
|
|
|
|
local strings = string.split(configData,"#")
|
|
|
|
|
local costId, costNum = tonumber(strings[1]),tonumber(strings[2])
|
2021-03-30 10:27:18 +08:00
|
|
|
|
if costNum > BagManager.GetTotalItemNum(costId) then
|
|
|
|
|
JumpManager.GoJump(36003)
|
|
|
|
|
else
|
|
|
|
|
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
|
2021-04-01 18:36:34 +08:00
|
|
|
|
MsgPanel.ShowTwo(string.format(Language[12243],costNum,itemName), nil, function()
|
2021-03-30 18:50:15 +08:00
|
|
|
|
NetManager.FuXingStoreBuyRequest(data.activityId,function ()
|
2021-04-01 18:36:34 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[12244])
|
2021-03-30 10:27:18 +08:00
|
|
|
|
FuXingGaoZhao:Refresh()
|
2021-03-30 18:50:15 +08:00
|
|
|
|
end)
|
2021-03-30 10:27:18 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
elseif data.ActState == 1 then
|
2021-03-30 16:24:28 +08:00
|
|
|
|
NetManager.GetActivityRewardRequest(-1,data.activityId,function (drop)
|
2021-03-30 10:27:18 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1,function()
|
|
|
|
|
FuXingGaoZhao:Refresh()
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
2021-03-29 09:52:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function FuXingGaoZhao:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function FuXingGaoZhao:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FuXingGaoZhao:OnSortingOrderChange()
|
2021-03-30 10:27:18 +08:00
|
|
|
|
Util.AddParticleSortLayer(self.effect, self.sortingOrder - sortingOrder)
|
2021-03-29 09:52:53 +08:00
|
|
|
|
sortingOrder = self.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
2021-03-30 20:20:12 +08:00
|
|
|
|
function FuXingGaoZhao:OnOpen(_func)
|
|
|
|
|
func = _func
|
2021-03-30 16:55:45 +08:00
|
|
|
|
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main})
|
2021-03-29 09:52:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 打开,重新打开时回调
|
|
|
|
|
function FuXingGaoZhao:OnShow()
|
2021-03-30 10:27:18 +08:00
|
|
|
|
FuXingGaoZhao:Refresh()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FuXingGaoZhao:Refresh()
|
|
|
|
|
data = FuXingGaoZhaoManager.GetData()
|
|
|
|
|
FuXingGaoZhao:SetBtn()
|
2021-03-30 16:24:28 +08:00
|
|
|
|
if data.ActState == 0 then
|
|
|
|
|
FuXingGaoZhao:SetTime()
|
|
|
|
|
self.time.gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
self.time.gameObject:SetActive(false)
|
|
|
|
|
end
|
2021-03-30 10:27:18 +08:00
|
|
|
|
for i = 1, #rewardList do
|
|
|
|
|
FuXingGaoZhao:SetSingleReward(rewardList[i],data.rewards[i],i)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FuXingGaoZhao:SetBtn()
|
|
|
|
|
local text = Util.GetGameObject(self.getBtn,"Text"):GetComponent("Text")
|
|
|
|
|
local redPoint = Util.GetGameObject(self.getBtn,"redPoint")
|
|
|
|
|
if data.ActState == 0 then
|
2021-04-01 18:36:34 +08:00
|
|
|
|
text.text = Language[12245]
|
2021-03-30 10:27:18 +08:00
|
|
|
|
self.getBtn:SetActive(true)
|
|
|
|
|
redPoint:SetActive(false)
|
|
|
|
|
elseif data.ActState == 1 then
|
2021-03-30 16:24:28 +08:00
|
|
|
|
text.text = Language[11948]
|
2021-03-30 10:27:18 +08:00
|
|
|
|
local bool = FuXingGaoZhaoManager.CheckRedPoint()
|
|
|
|
|
self.getBtn:SetActive(bool)
|
|
|
|
|
redPoint:SetActive(bool)
|
2021-03-30 16:24:28 +08:00
|
|
|
|
elseif data.ActState == 2 then
|
|
|
|
|
self.getBtn:SetActive(false)
|
2021-03-30 10:27:18 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-03-29 09:52:53 +08:00
|
|
|
|
|
2021-03-30 16:24:28 +08:00
|
|
|
|
function FuXingGaoZhao:SetTime()
|
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
|
|
|
|
local time = data.startTime + tonumber(timeData[1])*86400 - GetTimeStamp()
|
2021-04-01 18:36:34 +08:00
|
|
|
|
self.time.text = string.format(Language[12246],TimeToFelaxible(time))
|
2021-03-30 16:24:28 +08:00
|
|
|
|
self.timer = Timer.New(function()
|
|
|
|
|
time = time - 1
|
|
|
|
|
if time < 1 then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end
|
2021-04-01 18:36:34 +08:00
|
|
|
|
self.time.text = string.format(Language[12246],TimeToFelaxible(time))
|
2021-03-30 16:24:28 +08:00
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.timer:Start()
|
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 17:53:01 +08:00
|
|
|
|
function FuXingGaoZhao:SetSingleReward(go,sdata,index)
|
2021-03-30 10:27:18 +08:00
|
|
|
|
local reward = Util.GetGameObject(go,"GameObject")
|
2021-03-30 16:24:28 +08:00
|
|
|
|
local mask = Util.GetGameObject(go,"mask")
|
|
|
|
|
-- LogBlue("index:"..index.." go:"..tostring(go.name).." 天数:"..tostring(NumToSimplenessFont[index]))
|
2021-04-01 18:36:34 +08:00
|
|
|
|
Util.GetGameObject(go,"Text"):GetComponent("Text").text = string.format(Language[10528],NumToSimplenessFont[index])
|
2021-03-30 10:27:18 +08:00
|
|
|
|
if not itemPreList[index] then
|
|
|
|
|
itemPreList[index] = SubUIManager.Open(SubUIConfig.ItemView,reward.transform)
|
|
|
|
|
end
|
2021-03-30 17:53:01 +08:00
|
|
|
|
itemPreList[index]:OnOpen(false, sdata.Reward, 0.85,false, false, false, sortingOrder)
|
|
|
|
|
mask:SetActive(sdata.State == 1)
|
|
|
|
|
local effect = Util.GetGameObject(itemPreList[index].gameObject,"effects/UI_Effect_jinkuang_Fang")
|
|
|
|
|
itemPreList[index]:SetEffectLayer(self.sortingOrder)
|
|
|
|
|
effect:SetActive((data.ActState == 1) and (sdata.State == 0) and (sdata.Progress <= GetTimeStamp()))
|
2021-03-29 09:52:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function FuXingGaoZhao:OnClose()
|
2021-03-30 16:24:28 +08:00
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
2021-03-30 20:20:12 +08:00
|
|
|
|
end
|
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
func = nil
|
|
|
|
|
end
|
2021-03-29 09:52:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function FuXingGaoZhao:OnDestroy()
|
2021-03-30 16:24:28 +08:00
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
2021-03-30 10:27:18 +08:00
|
|
|
|
itemPreList={}
|
2021-03-30 17:53:01 +08:00
|
|
|
|
rewardList={}
|
2021-03-30 16:55:45 +08:00
|
|
|
|
SubUIManager.Close(self.UpView)
|
2021-03-29 09:52:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return FuXingGaoZhao
|