2020-08-25 15:46:38 +08:00
|
|
|
|
--[[
|
2020-05-09 13:31:21 +08:00
|
|
|
|
* @ClassName OperatingPanel
|
|
|
|
|
* @Description 等级特权面板
|
|
|
|
|
* @Date 2019/5/27 11:14
|
|
|
|
|
* @Author MagicianJoker, fengliudianshao@outlook.com
|
|
|
|
|
* @Copyright Copyright (c) 2019, MagicianJoker
|
|
|
|
|
--]]
|
|
|
|
|
|
|
|
|
|
---@class VipPanel
|
|
|
|
|
local VipPanel = quick_class("VipPanel", BasePanel)
|
|
|
|
|
local this = VipPanel
|
|
|
|
|
local orginLayer
|
|
|
|
|
local maxVipLevel = 15
|
|
|
|
|
local curChooseLevel = 0
|
|
|
|
|
-- 当前选中的礼包内容
|
|
|
|
|
local giftData = {}
|
|
|
|
|
-- 避免多次点击按钮
|
|
|
|
|
local btnBg = {
|
|
|
|
|
[1] = "r_hero_button_001", -- 未激活, 已领取
|
|
|
|
|
[2] = "t_tequan_lingqu", -- 领取
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- 按钮选中的颜色
|
|
|
|
|
local btnColor = {
|
|
|
|
|
[1] = {nameColor = "#dca074FF", descColor = "#b6815bFF", img = "r_tequan_te_anniu01"}, -- 未选中
|
|
|
|
|
[2] = {nameColor = "#930f0fFF", descColor = "#60271bFF", img = "r_tequan_te_anniu02"}, -- 选中
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 上一个选择的按钮
|
|
|
|
|
local lastChoose = 0
|
|
|
|
|
|
|
|
|
|
local vipLevelConfig = ConfigManager.GetConfig(ConfigName.VipLevelConfig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function VipPanel:InitComponent()
|
|
|
|
|
orginLayer = 0
|
|
|
|
|
maxVipLevel = VipManager.GetMaxVipLevel()
|
|
|
|
|
--self.bg = Util.GetGameObject(self.transform, "bg")
|
|
|
|
|
--if Screen.width / Screen.height < 1080 / 1920 then
|
|
|
|
|
-- screenAdapte(self.bg)
|
|
|
|
|
--end
|
|
|
|
|
|
|
|
|
|
self.BtnBack = Util.GetGameObject(self.transform, "btnBack")
|
|
|
|
|
this.helpBtn = Util.GetGameObject(self.gameObject, "frame/helpBtn")
|
|
|
|
|
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
|
--topPart
|
|
|
|
|
self.topPart = Util.GetGameObject(self.transform, "frame/topPart")
|
|
|
|
|
self.effect = Util.GetGameObject(self.topPart, "UI_Effect_VipPanel")
|
|
|
|
|
|
|
|
|
|
effectAdapte(self.effect)
|
|
|
|
|
|
|
|
|
|
-- 充值信息
|
|
|
|
|
self.chargeTip = Util.GetGameObject(self.topPart, "VipInfoPart/textGrid")
|
|
|
|
|
self.moneyNeed = Util.GetGameObject(self.topPart, "VipInfoPart/textGrid/num"):GetComponent("Text")
|
|
|
|
|
self.vipNextLevel = Util.GetGameObject(self.topPart, "VipInfoPart/textGrid/end"):GetComponent("Text")
|
|
|
|
|
self.moneyIcon = Util.GetGameObject(self.topPart, "VipInfoPart/textGrid/icon/Image"):GetComponent("Image")
|
|
|
|
|
self.rewardInfo = Util.GetGameObject(self.topPart, "VipInfoPart/reward/Text"):GetComponent("Image")
|
|
|
|
|
self.vipCurLevel = Util.GetGameObject(self.topPart, "VipInfoPart/vipIcon/num"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
-- 充值进度信息
|
|
|
|
|
self.progressValue = Util.GetGameObject(self.topPart, "VipInfoPart/Slider/fill"):GetComponent("Image")
|
|
|
|
|
self.progressText = Util.GetGameObject(self.topPart, "VipInfoPart/Slider/value"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
-- 购买月卡
|
|
|
|
|
self.monthRewardList = {}
|
|
|
|
|
self.monthRewardGrid = Util.GetGameObject(self.topPart, "dailyGift/grid")
|
|
|
|
|
self.dailyReward = {}
|
|
|
|
|
for i = 1, 2 do
|
|
|
|
|
self.dailyReward[i] = SubUIManager.Open(SubUIConfig.ItemView, self.monthRewardGrid.transform)
|
|
|
|
|
self.dailyReward[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
self.btnGetReward = Util.GetGameObject(self.topPart, "dailyGift/btnGet")
|
|
|
|
|
self.btnText = Util.GetGameObject(self.btnGetReward, "Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
-- 领取按钮红点
|
|
|
|
|
self.redReward = Util.GetGameObject(self.btnGetReward, "redPoint")
|
|
|
|
|
|
|
|
|
|
--midPart
|
|
|
|
|
self.midPart = Util.GetGameObject(self.gameObject, "frame/midPart/privilegeRoot")
|
|
|
|
|
self.moneyNeedTotal = Util.GetGameObject(self.midPart, "chargeTip/num"):GetComponent("Text")
|
|
|
|
|
self.moneyIconTotal = Util.GetGameObject(self.midPart, "chargeTip/icon/Image"):GetComponent("Image")
|
|
|
|
|
self.btnMidPart = Util.GetGameObject(self.gameObject, "frame/midPart")
|
|
|
|
|
|
|
|
|
|
-- 增益描述
|
|
|
|
|
self.privilegeTitle = Util.GetGameObject(self.midPart, "imgTitle/title"):GetComponent("Text")
|
|
|
|
|
self.privilegeContent = Util.GetGameObject(self.midPart, "privilegeList/viewPort/content")
|
|
|
|
|
self.privilegeItem = Util.GetGameObject(self.privilegeContent, "itemPro")
|
|
|
|
|
self.privilegeItem.gameObject:SetActive(false)
|
|
|
|
|
self.privilegeList = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 当前等级的特权礼包
|
|
|
|
|
self.giftGrid = Util.GetGameObject(self.midPart, "gfitContent/Scroll/grid")
|
|
|
|
|
self.vipGfitList = {}
|
|
|
|
|
-- 缓存6项
|
|
|
|
|
for i = 1, 6 do
|
|
|
|
|
self.vipGfitList[i] = SubUIManager.Open(SubUIConfig.ItemView, self.giftGrid.transform)
|
|
|
|
|
self.vipGfitList[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.giftText = Util.GetGameObject(self.midPart, "gfitContent/orginPrice/price"):GetComponent("Text")
|
|
|
|
|
self.giftIcon = Util.GetGameObject(self.midPart, "gfitContent/orginPrice/icon"):GetComponent("Image")
|
|
|
|
|
self.discountLine = Util.GetGameObject(self.midPart, "gfitContent/orginPrice/line")
|
|
|
|
|
self.btnGiftBuy = Util.GetGameObject(self.midPart, "gfitContent/btnBuy")
|
|
|
|
|
self.buyIcon = Util.GetGameObject(self.midPart, "gfitContent/icon"):GetComponent("Image")
|
|
|
|
|
self.buyText = Util.GetGameObject(self.midPart, "gfitContent/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 那一排的滑动按钮
|
|
|
|
|
self.levelBtnList = {}
|
|
|
|
|
self.btnRedPointList = {}
|
|
|
|
|
self.btnGrid = Util.GetGameObject(self.midPart, "btnScroll/grid")
|
|
|
|
|
self.btnPre = Util.GetGameObject(self.midPart, "btnScroll/btnVipInfo")
|
|
|
|
|
for i = 1, maxVipLevel + 1 do
|
|
|
|
|
self.levelBtnList[i] = newObjToParent(self.btnPre, self.btnGrid)
|
|
|
|
|
self.btnRedPointList[i] = Util.GetGameObject(self.levelBtnList[i], "redPoint")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function VipPanel:BindEvent()
|
|
|
|
|
----帮助按钮
|
|
|
|
|
Util.AddClick(this.helpBtn, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.VIP, this.helpPosition.x,this.helpPosition.y)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.BtnBack, function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
for i = 1, maxVipLevel + 1 do
|
|
|
|
|
Util.AddClick(self.levelBtnList[i], function ()
|
|
|
|
|
self:RefreshPanelStatus(i - 1)
|
|
|
|
|
-- 刷新按钮红点状态
|
|
|
|
|
if VipManager.GetBuyBtnRedState(i - 1) == 0 and self.vipLevel >= i - 1 then
|
|
|
|
|
VipManager.SetBuyBtnRed(i - 1, 1)
|
|
|
|
|
CheckRedPointStatus(RedPointType.VIP_SHOP_DETAIL)
|
|
|
|
|
CheckRedPointStatus(RedPointType.VipPrivilege)
|
|
|
|
|
end
|
|
|
|
|
self:SetBtnRedState(i-1)
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--点击中间部分,设置为目前VIP等级的增益描述
|
|
|
|
|
-- Util.AddClick(self.btnMidPart, function ()
|
|
|
|
|
-- if curChooseLevel ~= self.vipLevel then
|
|
|
|
|
-- self:RefreshPanelStatus(self.vipLevel)
|
|
|
|
|
-- end
|
|
|
|
|
-- end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btnGetReward, function ()
|
|
|
|
|
self:BtnRewardClick()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btnGiftBuy, function ()
|
|
|
|
|
self:BuyVipGift()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--待功能扩展(试图打开某个状态)
|
|
|
|
|
function VipPanel:OnOpen()
|
|
|
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function VipPanel:OnSortingOrderChange()
|
|
|
|
|
Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
|
|
|
|
|
orginLayer = self.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function VipPanel:OnShow()
|
|
|
|
|
---- 临时使用活动的充值数量
|
|
|
|
|
self.chargedNum = VipManager.GetChargedNum()
|
|
|
|
|
|
|
|
|
|
self.vipLevel = VipManager.GetVipLevel()
|
2021-01-09 14:20:06 +08:00
|
|
|
|
Log("当前Vip等级" .. self.vipLevel)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.nextLevel = self.vipLevel + 1
|
|
|
|
|
self.nextLevel = self.nextLevel > maxVipLevel and maxVipLevel or self.nextLevel
|
|
|
|
|
-- 设置充值信息
|
|
|
|
|
self:SetChargeInfo()
|
|
|
|
|
--豪华礼包奖励信息
|
|
|
|
|
self:MonthGift()
|
|
|
|
|
-- 滑动的特权按钮
|
|
|
|
|
self:SetBtnListState()
|
|
|
|
|
self:InitAllRedBtn()
|
|
|
|
|
-- 设置增益描述
|
|
|
|
|
lastChoose = self.vipLevel
|
|
|
|
|
self:RefreshPanelStatus(self.vipLevel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 刷新系统界面
|
|
|
|
|
function VipPanel:RefreshPanelStatus(curLevel)
|
|
|
|
|
if lastChoose ~= curLevel then -- 重置
|
|
|
|
|
local bg = self.levelBtnList[lastChoose + 1]:GetComponent("Image")
|
|
|
|
|
local name = Util.GetGameObject(self.levelBtnList[lastChoose + 1], "level"):GetComponent("Text")
|
|
|
|
|
local desc = Util.GetGameObject(self.levelBtnList[lastChoose + 1], "info"):GetComponent("Text")
|
|
|
|
|
bg.sprite = Util.LoadSprite(btnColor[1].img)
|
2021-04-06 22:33:57 +08:00
|
|
|
|
local nameText = Language[11944] .. lastChoose
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local descTex = VipManager.GetFirstNameByLevel(lastChoose)
|
|
|
|
|
name.text = string.format("<color=%s>%s</color>", btnColor[1].nameColor, nameText)
|
|
|
|
|
desc.text = string.format("<color=%s>%s</color>", btnColor[1].descColor, descTex)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
curChooseLevel = curLevel
|
|
|
|
|
lastChoose = curChooseLevel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local bg1 = self.levelBtnList[curChooseLevel + 1]:GetComponent("Image")
|
2021-04-06 22:33:57 +08:00
|
|
|
|
local nameText1 = Language[11944] .. curChooseLevel
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local descTex1 = VipManager.GetFirstNameByLevel(curChooseLevel)
|
|
|
|
|
local name1 = Util.GetGameObject(self.levelBtnList[curChooseLevel + 1], "level"):GetComponent("Text")
|
|
|
|
|
local desc1 = Util.GetGameObject(self.levelBtnList[curChooseLevel + 1], "info"):GetComponent("Text")
|
|
|
|
|
bg1.sprite = Util.LoadSprite(btnColor[2].img)
|
|
|
|
|
name1.text = string.format("<color=%s>%s</color>", btnColor[2].nameColor, nameText1)
|
|
|
|
|
desc1.text = string.format("<color=%s>%s</color>", btnColor[2].descColor, descTex1)
|
|
|
|
|
|
|
|
|
|
|
2021-04-06 22:33:57 +08:00
|
|
|
|
self.privilegeTitle.text = string.format(Language[11945], curLevel)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.moneyNeedTotal.text = VipManager.CurLevelMoneyNeed(curLevel)
|
|
|
|
|
self.moneyIconTotal.sprite = SetIcon(15)
|
|
|
|
|
|
|
|
|
|
local VipLvConfig = vipLevelConfig[curLevel]
|
|
|
|
|
assert(VipLvConfig, string.format("ConfigName.VipLevelConfig not find VipLevel:%s", curLevel))
|
|
|
|
|
self:SetVipPrivileges(curLevel)
|
|
|
|
|
-- 刷新礼包内容
|
|
|
|
|
self:RefreshVipGift(curLevel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 初始化刷新所有按钮红点状态
|
|
|
|
|
function VipPanel:InitAllRedBtn()
|
|
|
|
|
|
|
|
|
|
for i = 1, maxVipLevel + 1 do
|
|
|
|
|
VipPanel:SetBtnRedState(i - 1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function VipPanel:SetBtnRedState(level)
|
|
|
|
|
local isShow = false
|
|
|
|
|
isShow = VipManager.GetBtnListRed(level)
|
|
|
|
|
self.btnRedPointList[level + 1]:SetActive(isShow)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
----------------------------- 特权信息显示 --------------------------------------
|
|
|
|
|
function VipPanel:SetChargeInfo()
|
|
|
|
|
local maxLevelNeed = VipManager.CurLevelMoneyNeed(maxVipLevel)
|
|
|
|
|
local need, nextLevelNeed = VipManager.GetNextLevelNeed()
|
|
|
|
|
self.moneyNeed.text = need
|
|
|
|
|
--self.chargeTip:SetActive(self.chargedNum < maxLevelNeed)
|
|
|
|
|
self.vipNextLevel.text = self.nextLevel
|
|
|
|
|
self.moneyIcon.sprite = SetIcon(15)
|
|
|
|
|
|
|
|
|
|
self.rewardInfo.sprite = Util.LoadSprite(VIP_LEVEL_REWARD[self.nextLevel])
|
|
|
|
|
self.rewardInfo:SetNativeSize()
|
|
|
|
|
self.vipCurLevel.text = self.vipLevel
|
|
|
|
|
self.progressValue.fillAmount = self.chargedNum / nextLevelNeed
|
|
|
|
|
self.progressText.text = self.chargedNum .. "/" .. nextLevelNeed
|
|
|
|
|
|
|
|
|
|
self:RefreshBtnState()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function VipPanel:AddListener()
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Vip.OnVipDailyRewardStatusChanged, self.OnVipDailyRewardStatusChanged, self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function VipPanel:RemoveListener()
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Vip.OnVipDailyRewardStatusChanged, self.OnVipDailyRewardStatusChanged, self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 点击领取按钮
|
|
|
|
|
function VipPanel:BtnRewardClick()
|
|
|
|
|
-- 豪华月卡的激活状态
|
|
|
|
|
local isActive = OperatingManager.GetMonthCardIsOpen(MONTH_CARD_TYPE.LUXURYMONTHCARD)--VipManager.GetMonthCardOpenState()
|
|
|
|
|
local getState = VipManager.GetRewardState()
|
|
|
|
|
if not isActive then
|
|
|
|
|
JumpManager.GoJump(36004)
|
|
|
|
|
else
|
|
|
|
|
if getState < 1 then
|
|
|
|
|
-- 发送领取请求
|
|
|
|
|
NetManager.GetVipDailyReward(function(respond)
|
|
|
|
|
VipManager.SetRewardVipLevel(self.vipLevel)
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, respond.drop, 1, function ()
|
|
|
|
|
self:RefreshBtnState()
|
|
|
|
|
CheckRedPointStatus(RedPointType.VIP_SHOP_DETAIL)
|
|
|
|
|
CheckRedPointStatus(RedPointType.VipPrivilege)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
-- 设置为不可领取
|
2021-04-06 22:33:57 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11946])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 设置领取按钮显示状态
|
|
|
|
|
function VipPanel:RefreshBtnState()
|
|
|
|
|
local isActive = OperatingManager.GetMonthCardIsOpen(MONTH_CARD_TYPE.LUXURYMONTHCARD)--VipManager.GetMonthCardOpenState()
|
2021-01-09 14:20:06 +08:00
|
|
|
|
Log("豪华月卡是否激活 -- " .. tostring(isActive))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local getState = VipManager.GetRewardState()
|
|
|
|
|
local str = ""
|
|
|
|
|
if not isActive then
|
2021-04-06 22:33:57 +08:00
|
|
|
|
str = Language[11947]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
if getState < 1 then
|
2021-04-06 22:33:57 +08:00
|
|
|
|
str = Language[11948]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2021-04-06 22:33:57 +08:00
|
|
|
|
str = Language[10101]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 设置红点
|
|
|
|
|
self.redReward:SetActive(isActive and getState < 1)
|
|
|
|
|
self.btnText.text = str
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 5点刷新数据
|
|
|
|
|
function VipPanel:OnVipDailyRewardStatusChanged()
|
|
|
|
|
self:RefreshBtnState()
|
|
|
|
|
self:MonthGift()
|
|
|
|
|
self:InitAllRedBtn()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
----------------------------- 豪华月卡每日礼包显示 --------------------------------
|
|
|
|
|
function VipPanel:MonthGift()
|
|
|
|
|
local level = 0
|
|
|
|
|
local getState = VipManager.GetRewardState()
|
|
|
|
|
local isLevelUp = self:IsLevelUped()
|
|
|
|
|
|
|
|
|
|
--Log("升级结果 -- " .. tostring(isLevelUp))
|
|
|
|
|
--Log("getState" .. getState)
|
|
|
|
|
|
|
|
|
|
if isLevelUp and getState > 0 then -- 升级过又领取了奖励
|
|
|
|
|
level = VipManager.GetRewardVipLevel()
|
|
|
|
|
else
|
|
|
|
|
level = VipManager.GetVipLevel()
|
|
|
|
|
end
|
|
|
|
|
|
2021-01-09 14:20:06 +08:00
|
|
|
|
Log("显示等级 " .. level .. "的礼包内容")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
local rewardData = vipLevelConfig[level].VipBoxDailyReward
|
2021-04-06 22:33:57 +08:00
|
|
|
|
if not rewardData then Log(Language[11949]) return end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
for i = 1, 2 do
|
|
|
|
|
this.dailyReward[i].gameObject:SetActive(i <= #rewardData)
|
|
|
|
|
if rewardData[i] then
|
|
|
|
|
this.dailyReward[i]:OnOpen(false, {rewardData[i][1],rewardData[i][2]}, 0.9)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function VipPanel:SetBtnListState()
|
|
|
|
|
for i = 1, maxVipLevel + 1 do
|
|
|
|
|
local btn = self.levelBtnList[i]
|
2021-04-06 22:33:57 +08:00
|
|
|
|
Util.GetGameObject(btn, "level"):GetComponent("Text").text = Language[11944] .. i - 1
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Util.GetGameObject(btn, "info"):GetComponent("Text").text = VipManager.GetFirstNameByLevel(i - 1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------- 特权增益 --------------------------------------
|
|
|
|
|
--特权增益描述
|
|
|
|
|
function VipPanel:SetVipPrivileges(curVipLevel)
|
|
|
|
|
if self.priThread then
|
|
|
|
|
coroutine.stop(self.priThread)
|
|
|
|
|
self.priThread = nil
|
|
|
|
|
end
|
|
|
|
|
table.walk(self.privilegeList, function(privilegeItem)
|
|
|
|
|
privilegeItem:SetActive(false)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
local curVipData = PrivilegeManager.GetTipsByVipLv(curVipLevel)
|
|
|
|
|
local tempNumber = 0
|
|
|
|
|
self.priThread = coroutine.start(function()
|
|
|
|
|
for _, privilegeInfo in ipairs(curVipData) do
|
|
|
|
|
|
|
|
|
|
if privilegeInfo.value == "" or privilegeInfo.value > 0 then
|
|
|
|
|
tempNumber = tempNumber + 1
|
|
|
|
|
local item = self:GetPrivilegeItem(tempNumber)
|
|
|
|
|
item:SetActive(false)
|
|
|
|
|
-- local str = "<size=45><color=#7bb15bFF> </color></size>"
|
|
|
|
|
-- str = string.format("<size=45><color=#7bb15bFF>%s</color></size>", privilegeInfo.value)
|
|
|
|
|
if privilegeInfo.id==1 then --特权关卡挂机加成百分比
|
2021-04-06 22:33:57 +08:00
|
|
|
|
Util.GetGameObject(item, "title"):GetComponent("Text").text = privilegeInfo.content ..Language[11950]..(privilegeInfo.value*100-100).."%"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
Util.GetGameObject(item, "title"):GetComponent("Text").text = privilegeInfo.content .. privilegeInfo.value
|
|
|
|
|
end
|
|
|
|
|
PlayUIAnim(Util.GetGameObject(item, "content"))
|
|
|
|
|
coroutine.wait(0.03)
|
|
|
|
|
--加成为0就别丢人现眼了
|
|
|
|
|
if privilegeInfo.id==1 and (privilegeInfo.value*100-100)==0 then
|
|
|
|
|
item:SetActive(false)
|
|
|
|
|
else
|
|
|
|
|
item:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function VipPanel:GetPrivilegeItem(index)
|
|
|
|
|
if self.privilegeList[index] then
|
|
|
|
|
return self.privilegeList[index]
|
|
|
|
|
else
|
|
|
|
|
local newItem = newObjToParent(self.privilegeItem, self.privilegeContent)
|
|
|
|
|
table.insert(self.privilegeList, newItem)
|
|
|
|
|
return newItem
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
|
--------------------------特权礼包购买 ----------------------------------
|
|
|
|
|
function VipPanel:RefreshVipGift(curLevel)
|
|
|
|
|
local shopData = VipManager.vipShopData[curLevel + 1]
|
|
|
|
|
if not shopData then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
Log("未能找到Vip等级为 " .. curLevel .. "的商店数据")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local curGoodData = shopData.Goods
|
|
|
|
|
|
|
|
|
|
for i = 1, 6 do
|
|
|
|
|
self.vipGfitList[i].gameObject:SetActive(i <= #curGoodData)
|
|
|
|
|
if curGoodData[i] then
|
|
|
|
|
self.vipGfitList[i]:OnOpen(false, {curGoodData[i][1],curGoodData[i][2]}, 0.75)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
giftData = {}
|
|
|
|
|
-- 设置购买按钮状态
|
|
|
|
|
local itemId = shopData.Id
|
|
|
|
|
|
|
|
|
|
local costId, finalCost, orignalCost = ShopManager.calculateBuyCost(SHOP_TYPE.VIP_GIFT, itemId, 1)
|
|
|
|
|
|
|
|
|
|
self.giftText.text = orignalCost
|
|
|
|
|
self.giftIcon.sprite = SetIcon(costId)
|
|
|
|
|
self.buyIcon.sprite = SetIcon(costId)
|
|
|
|
|
giftData.shopType = SHOP_TYPE.VIP_GIFT
|
|
|
|
|
giftData.shopItemId = itemId
|
|
|
|
|
giftData.num = 1
|
|
|
|
|
giftData.costId = costId
|
|
|
|
|
giftData.costNum = finalCost
|
|
|
|
|
|
|
|
|
|
VipPanel:FreshBuyBtnState(giftData.costNum)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--购买礼包处理
|
|
|
|
|
function VipPanel:BuyVipGift()
|
|
|
|
|
-- 你有资格买吗
|
|
|
|
|
if curChooseLevel > self.vipLevel then
|
2021-04-06 22:33:57 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11951] .. curChooseLevel .. Language[11952])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 商品的剩余购买次数
|
|
|
|
|
local leftNum = ShopManager.GetShopItemRemainBuyTimes(giftData.shopType, giftData.shopItemId)
|
|
|
|
|
if leftNum < 1 and leftNum ~= -1 then
|
2021-04-06 22:33:57 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11953])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 钱钱是不是不够,找麻麻要吧
|
|
|
|
|
local haveNum = BagManager.GetItemCountById(giftData.costId)
|
|
|
|
|
if haveNum < giftData.costNum then
|
|
|
|
|
UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.DemonCrystal })
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ShopManager.RequestBuyShopItem(giftData.shopType, giftData.shopItemId, 1, function ()
|
|
|
|
|
VipPanel:FreshBuyBtnState(giftData.costNum)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 刷新购买按钮显示状态
|
|
|
|
|
function VipPanel:FreshBuyBtnState(costNum)
|
|
|
|
|
-- 检测剩余购买次数
|
|
|
|
|
local leftNum = ShopManager.GetShopItemRemainBuyTimes(giftData.shopType, giftData.shopItemId)
|
|
|
|
|
|
|
|
|
|
local canBuy = false
|
|
|
|
|
if leftNum < 1 and leftNum ~= -1 then
|
2021-04-06 22:33:57 +08:00
|
|
|
|
self.buyText.text = Language[11954]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
canBuy = false
|
|
|
|
|
Util.SetGray(self.btnGiftBuy, true)
|
|
|
|
|
else
|
|
|
|
|
self.buyText.text = costNum
|
|
|
|
|
canBuy = true
|
|
|
|
|
Util.SetGray(self.btnGiftBuy, false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 判断出去面板后,是否升过级
|
|
|
|
|
function VipPanel:IsLevelUped()
|
|
|
|
|
local isUp = false
|
|
|
|
|
-- 今日领取奖励时的等级
|
|
|
|
|
local rewardLevel = VipManager.GetRewardVipLevel()
|
|
|
|
|
if rewardLevel > 0 and rewardLevel ~= self.vipLevel then
|
|
|
|
|
isUp = true
|
|
|
|
|
else
|
|
|
|
|
isUp = false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return isUp
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--跳转显示新手提示圈
|
|
|
|
|
function this.ShowGuideGo()
|
|
|
|
|
JumpManager.ShowGuide(UIName.VipPanel, this.taskItemList[1].dealBtn)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function VipPanel:OnClose()
|
|
|
|
|
if self.priThread then
|
|
|
|
|
coroutine.stop(self.priThread)
|
|
|
|
|
self.priThread = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if self.taskThread then
|
|
|
|
|
coroutine.stop(self.taskThread)
|
|
|
|
|
self.taskThread = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 目前的选择
|
|
|
|
|
local bg = self.levelBtnList[curChooseLevel + 1]:GetComponent("Image")
|
|
|
|
|
local name = Util.GetGameObject(self.levelBtnList[curChooseLevel + 1], "level"):GetComponent("Text")
|
|
|
|
|
local desc = Util.GetGameObject(self.levelBtnList[curChooseLevel + 1], "info"):GetComponent("Text")
|
|
|
|
|
bg.sprite = Util.LoadSprite(btnColor[1].img)
|
2021-04-06 22:33:57 +08:00
|
|
|
|
local namaText = Language[11944] .. curChooseLevel + 1
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local descTex = VipManager.GetFirstNameByLevel(curChooseLevel)
|
|
|
|
|
name.text = string.format("<color=%s>%s</color>", btnColor[1].nameColor, namaText)
|
|
|
|
|
desc.text = string.format("<color=%s>%s</color>", btnColor[1].descColor, descTex)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function VipPanel:OnDestroy()
|
|
|
|
|
SubUIManager.Close(this.UpView)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return VipPanel
|