miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/MatchTipPopup.lua

96 lines
2.5 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
MatchTipPopup = Inherit(BasePanel)
local this = MatchTipPopup
2021-03-02 16:53:12 +08:00
local showStr = Language[11488]
2020-05-09 13:31:21 +08:00
local isCounting = false
--初始化组件(用于子类重写)
function MatchTipPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.btnBack = Util.GetGameObject(self.gameObject, "bg/btnBack")
this.context = Util.GetGameObject(self.gameObject, "bg/BgMask/context"):GetComponent("Text")
this.rewardList = {}
this.grid = Util.GetGameObject(self.gameObject, "bg/BgMask/rewardbg/Scroll/grid")
this.btnCanel = Util.GetGameObject(self.gameObject, "bg/BgMask/btnCancel")
this.btnSure = Util.GetGameObject(self.gameObject, "bg/BgMask/btnGo")
this.btnText = Util.GetGameObject(this.btnCanel, "Text"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function MatchTipPopup:BindEvent()
Util.AddClick(this.btnBack, function ()
self:ClosePanel()
end)
Util.AddClick(this.btnSure, function ()
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11489])
2020-05-09 13:31:21 +08:00
end)
Util.AddClick(this.btnCanel, function ()
if isCounting then return end
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function MatchTipPopup:AddListener()
end
--移除事件监听(用于子类重写)
function MatchTipPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function MatchTipPopup:OnOpen()
-- 设置提示文字
ShowText(this.context, showStr, 2)
-- 设置奖励
for i = 1, 6 do
if not this.rewardList[i] then
this.rewardList[i] = SubUIManager.Open(SubUIConfig.ItemView, this.grid.transform)
end
this.rewardList[i]:OnOpen(false, {6022, 0}, 0.9)
end
this.timer = nil
local index = 5
2021-03-02 16:53:12 +08:00
this.btnText.text = Language[10589] .. index .. ")"
2020-05-09 13:31:21 +08:00
this.timer = Timer.New(function ()
index = index - 1
2021-03-02 16:53:12 +08:00
this.btnText.text = Language[10589] .. index .. ")"
2020-05-09 13:31:21 +08:00
isCounting = true
if index == 0 then
2021-03-02 16:53:12 +08:00
this.btnText.text = Language[10731]
2020-05-09 13:31:21 +08:00
isCounting = false
this.timer:Stop()
self:ClosePanel()
end
end, 1, 5, true)
this.timer:Start()
end
--界面关闭时调用(用于子类重写)
function MatchTipPopup:OnClose()
if this.timer then
this.timer:Stop()
this.timer = nil
end
end
--界面销毁时调用(用于子类重写)
function MatchTipPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return MatchTipPopup