2024-07-03 18:38:10 +08:00
|
|
|
local PrivilegeCardThreePanel = Inherit(BasePanel)
|
|
|
|
|
local this = PrivilegeCardThreePanel
|
|
|
|
|
local kMaxReward = 8
|
|
|
|
|
local cursortingOrder
|
|
|
|
|
local curIndex = 3
|
|
|
|
|
local selfRechargeID
|
|
|
|
|
local privilegeCardInfo ={}
|
|
|
|
|
local img = {
|
|
|
|
|
"X1_jinrishouchong_chongzhi",
|
|
|
|
|
"X1_baridenglu_lingqu"
|
|
|
|
|
}
|
|
|
|
|
local contentWidth =
|
|
|
|
|
{
|
|
|
|
|
[1] = 1031,
|
|
|
|
|
[2] = 1300,
|
|
|
|
|
[3] = 1700,
|
|
|
|
|
[4] = 210, --高
|
|
|
|
|
}
|
|
|
|
|
local buyBtnState = false
|
|
|
|
|
function PrivilegeCardThreePanel:InitComponent()
|
|
|
|
|
|
|
|
|
|
cursortingOrder = 0
|
|
|
|
|
self.backBtn = Util.GetGameObject(self.transform, "btnBack")
|
|
|
|
|
--激活领取
|
|
|
|
|
self.rewardContent2 = {}
|
|
|
|
|
self.rewardContentEffect2 = {}
|
|
|
|
|
self.rewardList2 = {}
|
|
|
|
|
for i = 1, kMaxReward do
|
|
|
|
|
self.rewardContent2[i] = Util.GetGameObject(self.transform, "frame/bg/rewardView1/rewardContent1/itemPos_" .. i)
|
|
|
|
|
self.rewardContentEffect2[i] = Util.GetGameObject(self.rewardContent2[i], "Kuang")
|
|
|
|
|
effectAdapte(self.rewardContentEffect2[i])
|
|
|
|
|
self.rewardList2[i] = SubUIManager.Open(SubUIConfig.ItemView, self.rewardContent2[i].transform)
|
|
|
|
|
Util.GetGameObject(self.rewardList2[i].gameObject,"item/num"):GetComponent("Text").color = Color.New(255/255,255/255,255/255,127/255)
|
|
|
|
|
end
|
|
|
|
|
--每日领取
|
|
|
|
|
self.rewardContent = {}
|
|
|
|
|
self.rewardContentEffect = {}
|
|
|
|
|
self.rewardList = {}
|
|
|
|
|
for i = 1, kMaxReward do
|
|
|
|
|
self.rewardContent[i] = Util.GetGameObject(self.transform, "frame/bg/rewardView2/rewardContent2/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)
|
|
|
|
|
Util.GetGameObject(self.rewardList[i].gameObject,"item/num"):GetComponent("Text").color = Color.New(255/255,255/255,255/255,127/255)
|
|
|
|
|
end
|
|
|
|
|
self.tipList={}
|
|
|
|
|
-- for i = 1, 8 do
|
|
|
|
|
-- self.tipList[i] = Util.GetGameObject(self.transform, "frame/bg/Tips/Text_" .. i):GetComponent("Text")
|
|
|
|
|
-- self.tipList[i].gameObject:SetActive(false)
|
|
|
|
|
-- end
|
|
|
|
|
self.itemPrefab = Util.GetGameObject(self.transform, "frame/bg/Tips/TipsContent/ItemPrefab")
|
|
|
|
|
self.itemPrefab:SetActive(false)
|
|
|
|
|
self.tipsContent = Util.GetGameObject(self.transform, "frame/bg/Tips/TipsContent")
|
|
|
|
|
|
|
|
|
|
self.dealBtn = Util.GetGameObject(self.transform, "frame/bg/dealBtn")
|
|
|
|
|
self.dealBtnText = Util.GetGameObject(self.transform, "frame/bg/dealBtn/Text"):GetComponent("Text")--购买价格
|
|
|
|
|
self.getBtn = Util.GetGameObject(self.transform, "frame/bg/getBtn") --领取
|
|
|
|
|
self.receivedBtn = Util.GetGameObject(self.transform, "frame/bg/receivedBtn") --已领取
|
|
|
|
|
--self.UI_effect_DailyRechargePanel_particle = Util.GetGameObject(self.transform, "frame/UI_effect_DailyRechargePanel_particle")
|
|
|
|
|
self.content = Util.GetGameObject(self.transform, "frame/bg/rewardView1")
|
|
|
|
|
self.content2 = Util.GetGameObject(self.transform, "frame/bg/rewardView2")
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PrivilegeCardThreePanel:BindEvent()
|
|
|
|
|
Util.AddClick(self.backBtn, function()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.dealBtn, function()
|
|
|
|
|
local actRewardConfig = ConfigManager.GetConfigData(ConfigName.TequanCardConfig, curIndex)
|
|
|
|
|
local buy = true
|
|
|
|
|
local nameData ={}
|
|
|
|
|
for index, value in ipairs(actRewardConfig.BuyRule) do
|
|
|
|
|
if value == 0 then
|
|
|
|
|
buy = true
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
local data = ConfigManager.GetConfigData(ConfigName.TequanCardConfig, value)
|
|
|
|
|
if PrivilegeManager.GetPrivilegeOpenStatusById(data.PrivilegeID) == false then
|
|
|
|
|
table.insert(nameData,data.Name)
|
|
|
|
|
buy = false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if buy then
|
|
|
|
|
--判断是否可购买
|
|
|
|
|
PayManager.Pay({Id = selfRechargeID}, function ()
|
|
|
|
|
-- FirstRechargeManager.RefreshAccumRechargeValue(data.Id)
|
|
|
|
|
this:OnShow()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
local str=""
|
|
|
|
|
for i = 1, #nameData do
|
|
|
|
|
str = str..GetLanguageStrById(nameData[i])
|
|
|
|
|
end
|
|
|
|
|
str = string.format(GetLanguageStrById(50405),str)
|
|
|
|
|
PopupTipPanel.ShowTip(str)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.getBtn, function()
|
|
|
|
|
NetManager.ReceivePrivilegeCardDailyRewardRequest(curIndex, function(msg)
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
|
|
|
|
privilegeCardInfo = msg.privilegeCardInfo
|
|
|
|
|
PrivilegeManager.privilegeCardInfo = msg.privilegeCardInfo
|
|
|
|
|
self:RefreshPanel(curIndex)
|
|
|
|
|
--self:WarPowerRewardShow()
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PrivilegeCardThreePanel:OnOpen()
|
2025-02-17 17:23:30 +08:00
|
|
|
|
2024-07-03 18:38:10 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PrivilegeCardThreePanel:OnShow()
|
|
|
|
|
NetManager.GetPrivilegeCardInfoResponse(function (msg)
|
|
|
|
|
privilegeCardInfo = msg.privilegeCardInfo
|
|
|
|
|
PrivilegeManager.privilegeCardInfo = msg.privilegeCardInfo
|
|
|
|
|
self:RefreshPanel(curIndex)
|
|
|
|
|
end)
|
|
|
|
|
--PrivilegeCardThreePanel:RefreshPanel(curIndex)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PrivilegeCardThreePanel:OnClose()
|
|
|
|
|
-- Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityOpenOrClose, self.RefreshPanel, self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PrivilegeCardThreePanel:SetContentWidth(index)
|
|
|
|
|
local content = Util.GetGameObject(self.content, "rewardContent1"):GetComponent("RectTransform")
|
|
|
|
|
local content2 = Util.GetGameObject(self.content2, "rewardContent2"):GetComponent("RectTransform")
|
|
|
|
|
|
|
|
|
|
if index == 1 then
|
|
|
|
|
content.sizeDelta = Vector2.New(contentWidth[index], contentWidth[4])
|
|
|
|
|
content2.sizeDelta = Vector2.New(contentWidth[index], contentWidth[4])
|
|
|
|
|
elseif index == 2 then
|
|
|
|
|
content.sizeDelta = Vector2.New(contentWidth[index], contentWidth[4])
|
|
|
|
|
content2.sizeDelta = Vector2.New(contentWidth[index], contentWidth[4])
|
|
|
|
|
elseif index == 3 then
|
|
|
|
|
content.sizeDelta = Vector2.New(contentWidth[index], contentWidth[4])
|
|
|
|
|
content2.sizeDelta = Vector2.New(contentWidth[index], contentWidth[4])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function PrivilegeCardThreePanel:AddListener()
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.PrivilegeCardPanel.Refresh, this.NewDay)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function PrivilegeCardThreePanel:RemoveListener()
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.PrivilegeCardPanel.Refresh, this.NewDay)
|
|
|
|
|
end
|
|
|
|
|
function PrivilegeCardThreePanel.NewDay()
|
|
|
|
|
PrivilegeCardThreePanel:OnShow()
|
|
|
|
|
end
|
|
|
|
|
function PrivilegeCardThreePanel:RefreshPanel(index)
|
|
|
|
|
curIndex = index
|
|
|
|
|
CheckRedPointStatus(RedPointType.PrivilegeCardThreePage)
|
|
|
|
|
-- CheckRedPointStatus(RedPointType.DailyRecharge)
|
|
|
|
|
-- PrivilegeCardThreePanel:SetContentWidth(curIndex)
|
|
|
|
|
self.content:SetActive(true)
|
|
|
|
|
self.content2:SetActive(true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--每日奖励表
|
|
|
|
|
local actRewardConfig = ConfigManager.GetConfigData(ConfigName.TequanCardConfig, curIndex)
|
|
|
|
|
local configData = ConfigManager.GetConfigData(ConfigName.TequanCardConfig, curIndex)
|
|
|
|
|
local RewardConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, configData.RechargeID)
|
|
|
|
|
selfRechargeID = actRewardConfig.RechargeID
|
|
|
|
|
for index, value in ipairs(privilegeCardInfo) do
|
|
|
|
|
if value.cardId == selfRechargeID then
|
|
|
|
|
buyBtnState = value.takeDailyReward
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
table.walk(self.rewardContent, function(rewardPosItem)
|
|
|
|
|
rewardPosItem:SetActive(false)
|
|
|
|
|
end)
|
|
|
|
|
for i = 1, #self.rewardContent do
|
|
|
|
|
if #actRewardConfig.DailyReward < i then
|
|
|
|
|
self.rewardContent[i]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
for i, rewardInfo in ipairs(actRewardConfig.DailyReward) do
|
|
|
|
|
self.rewardList[i]:OnOpen(false, rewardInfo, 0.68)
|
|
|
|
|
|
|
|
|
|
self.rewardContent[i]:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for i = 1, #self.rewardContent2 do
|
|
|
|
|
if #RewardConfig.RewardShow < i then
|
|
|
|
|
self.rewardContent2[i]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
table.walk(self.rewardContent2, function(rewardPosItem2)
|
|
|
|
|
rewardPosItem2:SetActive(false)
|
|
|
|
|
end)
|
|
|
|
|
local buyPrivilegeState = PrivilegeManager.GetPrivilegeOpenStatusById(actRewardConfig.PrivilegeID)
|
|
|
|
|
for i, rewardInfo in ipairs(actRewardConfig.DailyReward) do
|
|
|
|
|
self.rewardList[i]:OnOpen(false, rewardInfo, 0.68)
|
|
|
|
|
self.rewardContent[i]:SetActive(true)
|
|
|
|
|
if buyPrivilegeState then
|
|
|
|
|
local Data ={}
|
|
|
|
|
for index, value in ipairs(privilegeCardInfo) do
|
|
|
|
|
if value.cardId == curIndex then
|
|
|
|
|
Data = value
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if Data.takeDailyReward then
|
|
|
|
|
self.rewardList[i]:SetDuiImageShow(true)
|
|
|
|
|
else
|
|
|
|
|
self.rewardList[i]:SetDuiImageShow(false)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self.rewardList[i]:SetDuiImageShow(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
for i, rewardInfo in ipairs(RewardConfig.RewardShow) do
|
|
|
|
|
if i<=kMaxReward then
|
|
|
|
|
self.rewardList2[i]:OnOpen(false, rewardInfo, 0.68)
|
|
|
|
|
if buyPrivilegeState then
|
|
|
|
|
self.rewardList2[i]:SetDuiImageShow(true)
|
|
|
|
|
self.rewardList2[i]. duiImage:GetComponent("Image").sprite =Util.LoadSprite("bt_tequan_bg_04")
|
|
|
|
|
else
|
|
|
|
|
self.rewardList2[i]:SetDuiImageShow(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.rewardContent2[i]:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for i, rewardInfo in ipairs(RewardConfig.RewardShow) do
|
|
|
|
|
if i<=kMaxReward then
|
|
|
|
|
self.rewardList2[i]:OnOpen(false, rewardInfo, 0.68)
|
|
|
|
|
self.rewardList2[i]:ShowNum(true)
|
|
|
|
|
self.rewardList2[i]:ShowStar(false)
|
|
|
|
|
self.rewardList2[i]:SetKuangSprite("bt_tequan_bg_04")
|
|
|
|
|
self.rewardContent2[i]:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
PrivilegeCardThreePanel:SetDesc(curIndex)
|
|
|
|
|
PrivilegeCardThreePanel:SetBtnState(curIndex)
|
|
|
|
|
end
|
|
|
|
|
function PrivilegeCardThreePanel:SetDesc(cIndex)
|
|
|
|
|
local desData = PrivilegeTurnManager.GetPrivilegeCardDes(cIndex)
|
|
|
|
|
for i = 1, #desData do
|
|
|
|
|
if self.tipList[i] == nil then
|
|
|
|
|
local go = newObjToParent(self.itemPrefab,self.tipsContent.transform)
|
|
|
|
|
--go.transform:SetParent(self.tipsContent.transform)
|
|
|
|
|
go:GetComponent("Text").text = desData[i].des
|
|
|
|
|
go:SetActive(true)
|
|
|
|
|
self.tipList[i] = go
|
|
|
|
|
else
|
|
|
|
|
self.tipList[i]:GetComponent("Text").text = desData[i].des
|
|
|
|
|
self.tipList[i]:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
function PrivilegeCardThreePanel:SetBtnState(cindex)
|
|
|
|
|
self.dealBtn:SetActive(false)
|
|
|
|
|
self.getBtn:SetActive(false)
|
|
|
|
|
self.receivedBtn:SetActive(false)
|
|
|
|
|
local actRewardConfig = ConfigManager.GetConfigData(ConfigName.TequanCardConfig, cindex)
|
|
|
|
|
local itemPrice = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, actRewardConfig.RechargeID).Price
|
|
|
|
|
local buyPrivilegeState = PrivilegeManager.GetPrivilegeOpenStatusById(actRewardConfig.PrivilegeID)
|
|
|
|
|
if buyPrivilegeState then
|
|
|
|
|
local Data ={}
|
|
|
|
|
for index, value in ipairs(privilegeCardInfo) do
|
|
|
|
|
if value.cardId == cindex then
|
|
|
|
|
Data = value
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if Data.takeDailyReward then
|
|
|
|
|
self.receivedBtn:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
self.getBtn:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self.dealBtn:SetActive(true)
|
|
|
|
|
self.dealBtnText.text = GetLanguageStrById(50202)..MoneyUtil.GetMoney(itemPrice)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return PrivilegeCardThreePanel
|