2020-08-25 15:46:38 +08:00
|
|
|
|
--[[
|
2020-05-09 13:31:21 +08:00
|
|
|
|
* @ClassName DailyRechargePanel
|
|
|
|
|
* @Description 每日首充
|
|
|
|
|
* @Date 2019/8/1 19:28
|
|
|
|
|
* @Author MagicianJoker, fengliudianshao@outlook.com
|
|
|
|
|
* @Copyright Copyright (c) 2019, MagicianJoker
|
|
|
|
|
--]]
|
|
|
|
|
---@class DailyRechargePanel
|
|
|
|
|
local DailyRechargePanel = quick_class("DailyRechargePanel", BasePanel)
|
|
|
|
|
|
|
|
|
|
local kMaxReward = 4
|
|
|
|
|
|
|
|
|
|
local rechargeBgDef = {
|
2021-01-26 17:08:39 +08:00
|
|
|
|
[1] = "r_mrcz_zi_1_zh",
|
|
|
|
|
[2] = "r_mrcz_zi_2_zh",
|
|
|
|
|
[3] = "r_mrcz_zi_33_zh",
|
|
|
|
|
[4] = "r_mrcz_zi_4_zh",
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
local cursortingOrder
|
|
|
|
|
local isFirstOpen = false
|
|
|
|
|
function DailyRechargePanel:InitComponent()
|
|
|
|
|
cursortingOrder = 0
|
|
|
|
|
self.backBtn = Util.GetGameObject(self.transform, "frame")
|
|
|
|
|
|
|
|
|
|
self.extraIcon = Util.GetGameObject(self.transform,"frame/bg/descbg/extraIcon"):GetComponent("Image")
|
|
|
|
|
self.desc = Util.GetGameObject(self.transform, "frame/bg/descbg/value"):GetComponent("Text")
|
2020-08-25 17:29:03 +08:00
|
|
|
|
self.dollar = Util.GetGameObject(self.transform,"frame/bg/descbg/dollar")
|
|
|
|
|
self.dollar:SetActive(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.rewardContent = {}
|
|
|
|
|
self.rewardContentEffect = {}
|
|
|
|
|
self.rewardList = {}
|
|
|
|
|
for i = 1, kMaxReward do
|
|
|
|
|
self.rewardContent[i] = Util.GetGameObject(self.transform, "frame/bg/rewardContent/itemPos_" .. i)
|
|
|
|
|
self.rewardContentEffect[i] = Util.GetGameObject(self.rewardContent[i], "Kuang")
|
|
|
|
|
effectAdapte(self.rewardContentEffect[i])
|
|
|
|
|
self.rewardList[i] = SubUIManager.Open(SubUIConfig.ItemView, self.rewardContent[i].transform)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.dealBtn = Util.GetGameObject(self.transform, "frame/bg/dealBtn")
|
|
|
|
|
self.dealText = Util.GetGameObject(self.dealBtn, "Text"):GetComponent("Text")
|
|
|
|
|
self.UI_effect_DailyRechargePanel_particle = Util.GetGameObject(self.transform, "frame/UI_effect_DailyRechargePanel_particle")
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local parent = Util.GetGameObject(self.transform, "frame/bg/Image")
|
|
|
|
|
local titleText = Util.GetGameObject(parent, "Text"):GetComponent("Text")
|
2021-04-06 22:33:57 +08:00
|
|
|
|
titleText.text = Language[12109]
|
2021-01-26 17:08:39 +08:00
|
|
|
|
SetTextVerTial(titleText,Vector3.New(102.07,18.2,0))
|
2021-04-07 21:07:42 +08:00
|
|
|
|
local yuanIma = Util.GetGameObject(self.transform, "frame/bg/descbg/dollar"):GetComponent("Image")
|
|
|
|
|
local yuanText = Util.GetGameObject(self.transform, "frame/bg/descbg/value")
|
|
|
|
|
if MoneyUtil.MT == MoneyType.RMB then
|
|
|
|
|
yuanIma.sprite = Util.LoadSprite("c_czlb_yuan1")
|
|
|
|
|
yuanIma.transform.localPosition = Vector3.New(163,10,0)
|
|
|
|
|
yuanText.transform.localPosition = Vector3.New(78,21,0)
|
|
|
|
|
else
|
|
|
|
|
yuanIma.sprite = Util.LoadSprite("c_czlb_yuan2")
|
|
|
|
|
yuanIma.transform.localPosition = Vector3.New(75.21,25.8,0)
|
|
|
|
|
yuanText.transform.localPosition = Vector3.New(166.34,15.9,0)
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyRechargePanel:BindEvent()
|
|
|
|
|
Util.AddClick(self.backBtn, function()
|
|
|
|
|
if not isFirstOpen then
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.dealBtn, function()
|
|
|
|
|
if not isFirstOpen then
|
|
|
|
|
self:OnDealBtnClicked()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyRechargePanel:OnOpen()
|
|
|
|
|
isFirstOpen = true
|
|
|
|
|
self:RefreshPanel()
|
|
|
|
|
Timer.New(function ()
|
|
|
|
|
isFirstOpen = false
|
|
|
|
|
end, 1.5):Start()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyRechargePanel:OnShow()
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityOpenOrClose, self.RefreshPanel, self)
|
|
|
|
|
end
|
|
|
|
|
function DailyRechargePanel:OnSortingOrderChange()
|
|
|
|
|
Util.AddParticleSortLayer( self.UI_effect_DailyRechargePanel_particle, self.sortingOrder - cursortingOrder)
|
|
|
|
|
for i = 1, #self.rewardContentEffect do
|
|
|
|
|
Util.AddParticleSortLayer( self.rewardContentEffect[i], self.sortingOrder - cursortingOrder)
|
|
|
|
|
end
|
|
|
|
|
cursortingOrder = self.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
function DailyRechargePanel:OnClose()
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityOpenOrClose, self.RefreshPanel, self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyRechargePanel:RefreshPanel()
|
|
|
|
|
local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge)
|
|
|
|
|
self.activityId = dailyActInfo.activityId
|
|
|
|
|
self.missionInfo = dailyActInfo.mission[1]
|
|
|
|
|
local actRewardConfig = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig, self.missionInfo.missionId)
|
|
|
|
|
if self.missionInfo.state == 0 then
|
|
|
|
|
if DailyRechargeManager.GetRechargeValue()==0 then
|
2020-08-25 17:29:03 +08:00
|
|
|
|
self.extraIcon.sprite = Util.LoadSprite(rechargeBgDef[4])
|
|
|
|
|
self.dollar:SetActive(true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.desc.text = actRewardConfig.Values[1][1]
|
2021-04-06 22:33:57 +08:00
|
|
|
|
self.dealText.text = Language[10420]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
if DailyRechargeManager.ReceivedEnabled() then
|
|
|
|
|
self.extraIcon.sprite = Util.LoadSprite(rechargeBgDef[3])
|
2020-08-25 17:29:03 +08:00
|
|
|
|
self.dollar:SetActive(false)
|
2021-04-06 22:33:57 +08:00
|
|
|
|
self.dealText.text = Language[10018]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.desc.text = ""
|
|
|
|
|
else
|
2020-08-25 17:29:03 +08:00
|
|
|
|
self.extraIcon.sprite = Util.LoadSprite(rechargeBgDef[4])
|
|
|
|
|
self.dollar:SetActive(true)
|
2020-08-27 21:34:38 +08:00
|
|
|
|
-- local remainValue = actRewardConfig.Values[1][1] - DailyRechargeManager.GetRechargeValue()
|
|
|
|
|
-- remainValue = remainValue < 0 and 0 or remainValue
|
|
|
|
|
self.desc.text = actRewardConfig.Values[1][1]--remainValue
|
2021-04-06 22:33:57 +08:00
|
|
|
|
self.dealText.text = Language[10420]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
2021-04-06 22:33:57 +08:00
|
|
|
|
self.dealText.text = Language[10101]
|
2020-08-25 17:29:03 +08:00
|
|
|
|
self.extraIcon.sprite = Util.LoadSprite(rechargeBgDef[4])
|
|
|
|
|
self.dollar:SetActive(true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
self.extraIcon:SetNativeSize()
|
|
|
|
|
table.walk(self.rewardContent, function(rewardPosItem)
|
|
|
|
|
rewardPosItem:SetActive(false)
|
|
|
|
|
end)
|
|
|
|
|
for i, rewardInfo in ipairs(actRewardConfig.Reward) do
|
|
|
|
|
self.rewardList[i]:OnOpen(false, rewardInfo, 1.1)
|
|
|
|
|
self.rewardContent[i]:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyRechargePanel:OnDealBtnClicked()
|
|
|
|
|
if self.missionInfo.state == 1 then
|
2021-04-06 22:33:57 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10421])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
if DailyRechargeManager.ReceivedEnabled() then
|
|
|
|
|
NetManager.GetActivityRewardRequest(self.missionInfo.missionId, self.activityId, function(_drop)
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, _drop, 1)
|
|
|
|
|
DailyRechargeManager.SetRechargeState(1)
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Activity.OnActivityOpenOrClose, {
|
|
|
|
|
type = ActivityTypeDef.DailyRecharge,
|
|
|
|
|
status = 0
|
|
|
|
|
})
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
if not ShopManager.IsActive(SHOP_TYPE.SOUL_STONE_SHOP) then
|
2021-04-06 22:33:57 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10422])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2021-03-30 20:17:26 +08:00
|
|
|
|
JumpManager.GoJump(36008)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-28 17:48:49 +08:00
|
|
|
|
return DailyRechargePanel
|