588 lines
24 KiB
Lua
588 lines
24 KiB
Lua
--[[
|
|
* @ClassName OperatingPanel
|
|
* @Description 等级特权面板
|
|
* @Date 2019/5/27 11:14
|
|
* @Author MagicianJoker, fengliudianshao@outlook.com
|
|
* @Copyright Copyright (c) 2019, MagicianJoker
|
|
--]]
|
|
local VipTaskListItem = require("Modules/Vip/VipTaskListItem")
|
|
|
|
---@class VipPanelV2
|
|
local VipPanelV2 = quick_class("VipPanelV2", BasePanel)
|
|
local this = VipPanelV2
|
|
local kMaxGiftCount, kMaxTaskCount = 4, 5
|
|
local ReceiveTypeIconDef = {
|
|
"t_tequan_tequandengjilibao", --特权等级礼包
|
|
"t_tequan_meirijiangli", --每日礼包
|
|
}
|
|
local orginLayer
|
|
|
|
function VipPanelV2:InitComponent()
|
|
orginLayer = 0
|
|
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, "helpBtn")
|
|
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
|
|
--topPart
|
|
self.topPart = Util.GetGameObject(self.transform, "frame/topPart")
|
|
self.BtnLeft = Util.GetGameObject(self.transform, "leftBtn")
|
|
self.BtnRight = Util.GetGameObject(self.transform, "rightBtn")
|
|
self.BtnTip = Util.GetGameObject(self.transform, "btnTip")
|
|
self.curLevel = Util.GetGameObject(self.transform, "btnTip/bg/vip"):GetComponent("Image")
|
|
|
|
self.StateRoot = Util.GetGameObject(self.topPart, "stateRoot")
|
|
|
|
self.curStatePart = Util.GetGameObject(self.StateRoot, "curState")
|
|
-- self.currentLv = Util.GetGameObject(self.curStatePart, "level/Text"):GetComponent("Text")
|
|
self.currentLvNum=Util.GetGameObject(self.curStatePart,"title/num"):GetComponent("Text")
|
|
-- self.vipLevelIcon=Util.GetGameObject(self.curStatePart,"title"):GetComponent("Image")
|
|
self.progressBar = Util.GetGameObject(self.curStatePart, "progressBar"):GetComponent("Slider")
|
|
self.progressText = Util.GetGameObject(self.curStatePart, "progressBar/Text"):GetComponent("Text")
|
|
|
|
-- self.lvUpPart = Util.GetGameObject(self.StateRoot, "lvUp")
|
|
-- self.lvUpCurNum=Util.GetGameObject( self.lvUpPart,"curTitle/num"):GetComponent("Text")
|
|
-- self.lvUpNexNum=Util.GetGameObject( self.lvUpPart,"nextTitle/num"):GetComponent("Text")
|
|
-- self.btnLvUp = Util.GetGameObject(self.lvUpPart, "btnLvUp")
|
|
-- self.lvUpRedPoint = Util.GetGameObject(self.btnLvUp, "redPoint")
|
|
|
|
-- self.previewPart = Util.GetGameObject(self.StateRoot, "preview")
|
|
-- self.previewLevel = Util.GetGameObject(self.previewPart, "image/Text"):GetComponent("Text")
|
|
-- self.previewNum=Util.GetGameObject(self.previewPart,"nextTitle/num"):GetComponent("Text")
|
|
|
|
self.giftRoot = Util.GetGameObject(self.topPart, "giftRoot")
|
|
self.giftTypeIcon = Util.GetGameObject(self.giftRoot, "title"):GetComponent("Image")
|
|
self.giftItemContent = Util.GetGameObject(self.giftRoot, "grid")
|
|
self.giftItemList = {}
|
|
for i = 1, kMaxGiftCount do
|
|
self.giftItemList[i] = Util.GetGameObject(self.giftRoot, "grid/prop_"..i)--SubUIManager.Open(SubUIConfig.ItemView, self.giftItemContent.transform)
|
|
end
|
|
|
|
self.effect = Util.GetGameObject(self.giftRoot, "UI_Effect_VipPanel")
|
|
effectAdapte(self.effect)
|
|
|
|
self.BtnReceive = Util.GetGameObject(self.topPart, "btnGet")
|
|
self.BtnReceiveText = Util.GetGameObject(self.BtnReceive, "Text"):GetComponent("Text")
|
|
self.receiveRedPoint = Util.GetGameObject(self.BtnReceive,"redPoint")
|
|
|
|
--midPart
|
|
self.privilegeTitle = Util.GetGameObject(self.transform, "frame/midPart/privilegeRoot/title"):GetComponent("Text")
|
|
self.privilegeContent = Util.GetGameObject(self.transform, "frame/midPart/privilegeRoot/privilegeList/viewPort/content")
|
|
self.privilegeItem = Util.GetGameObject(self.privilegeContent, "itemPro")
|
|
self.privilegeItem.gameObject:SetActive(false)
|
|
self.privilegeList = {}
|
|
--bottomPart
|
|
self.maxLv = Util.GetGameObject(self.transform, "bottomPart/maxLv")
|
|
self.btnLvUp = Util.GetGameObject(self.transform, "bottomPart/btnLvUp")
|
|
self.taskList = Util.GetGameObject(self.transform, "bottomPart/taskList")
|
|
self.taskContent = Util.GetGameObject(self.transform, "bottomPart/taskList/viewPort/content")
|
|
self.taskItemPro = Util.GetGameObject(self.taskContent, "itemPro")
|
|
self.taskItemPro.gameObject:SetActive(false)
|
|
self.taskItemList = {}
|
|
for i = 1, kMaxTaskCount do
|
|
self.taskItemList[i] = VipTaskListItem.create(self.taskItemPro, self.taskContent)
|
|
self.taskItemList[i].cloneObj.name = "itemPro" .. i
|
|
end
|
|
|
|
end
|
|
|
|
function VipPanelV2:BindEvent()
|
|
-- Util.AddClick(self.BtnTip, function()
|
|
-- UIManager.OpenPanel(UIName.VipTipPopup)
|
|
-- end)
|
|
--帮助按钮
|
|
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)
|
|
|
|
Util.AddClick(self.BtnLeft, function()
|
|
self:OnTurnLeftBtnClicked()
|
|
end)
|
|
Util.AddClick(self.BtnRight, function()
|
|
self:OnTurnRightBtnClicked()
|
|
end)
|
|
|
|
Util.AddClick(self.BtnReceive, function()
|
|
self:OnReceiveBtnClicked()
|
|
end)
|
|
|
|
Util.AddClick(self.btnLvUp, function()
|
|
self:OnBtnLvUpClicked()
|
|
end)
|
|
|
|
end
|
|
|
|
function VipPanelV2:OnVipTaskStatusChanged(taskId)
|
|
self:OnTaskStatusChanged(taskId)
|
|
end
|
|
|
|
function VipPanelV2:OnVipDailyRewardStatusChanged(taskId)
|
|
self:OnShow()
|
|
end
|
|
|
|
function VipPanelV2:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Vip.OnVipTaskStatusChanged, self.OnVipTaskStatusChanged, self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Vip.OnVipDailyRewardStatusChanged, self.OnVipDailyRewardStatusChanged, self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.CloseUI.OnClose,self.OnVipDailyRewardStatusChanged, self)
|
|
end
|
|
|
|
function VipPanelV2:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Vip.OnVipTaskStatusChanged, self.OnVipTaskStatusChanged, self)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Vip.OnVipDailyRewardStatusChanged, self.OnVipDailyRewardStatusChanged, self)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.CloseUI.OnClose,self.OnVipDailyRewardStatusChanged, self)
|
|
end
|
|
|
|
--待功能扩展(试图打开某个状态)
|
|
function VipPanelV2:OnOpen()
|
|
|
|
end
|
|
|
|
function VipPanelV2:OnSortingOrderChange()
|
|
Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
|
|
orginLayer = self.sortingOrder
|
|
end
|
|
|
|
function VipPanelV2:OnShow()
|
|
self:InitVipContext()
|
|
self:SetPanelStatus()
|
|
end
|
|
|
|
function VipPanelV2: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
|
|
end
|
|
|
|
function VipPanelV2:OnDestroy()
|
|
end
|
|
|
|
function VipPanelV2:InitVipContext()
|
|
self.context = {}
|
|
self.context.UserMissionInfo = TaskManager.GetTypeTaskList(TaskTypeDef.VipTask)
|
|
self.context.vipLevel = VipManager.GetVipLevel()
|
|
-- self.context.hadTakeLevelBox = VipManager.GetTakeLevelBoxStatus()
|
|
-- self.context.hadTakeDailyBox = VipManager.GetTakeDailyBoxStatus()
|
|
end
|
|
|
|
function VipPanelV2:SetPanelStatus()
|
|
-- self:SwitchState(self:GetCurrentStatus(self.context.UserMissionInfo))
|
|
local maxLv = VipManager.GetMaxVipLevel()
|
|
self.curLevel.sprite = Util.LoadSprite("r_zjm_tequanpaizi_0" .. self.context.vipLevel)
|
|
-- 显示的
|
|
self.curShowLevel = math.min(self.context.vipLevel + 1, maxLv)
|
|
self:RefreshPanelStatus(self.curShowLevel)
|
|
self:CheckTaskShow()
|
|
self.BtnLeft:SetActive(self.curShowLevel > 1)
|
|
self.BtnRight:SetActive(self.curShowLevel ~= maxLv)
|
|
end
|
|
|
|
-- 检测任务显示
|
|
function VipPanelV2:CheckTaskShow()
|
|
if self.context.vipLevel == VipManager.GetMaxVipLevel() then
|
|
self.taskList:SetActive(false)
|
|
self.btnLvUp:SetActive(false)
|
|
self.maxLv:SetActive(true)
|
|
else
|
|
self.maxLv:SetActive(false)
|
|
local isfinish = true
|
|
local taskListInfo = self.context.UserMissionInfo
|
|
for i = 1, #taskListInfo do
|
|
if taskListInfo[i].state ~= VipTaskStatusDef.Received then
|
|
isfinish = false
|
|
end
|
|
end
|
|
self.taskList:SetActive(not isfinish)
|
|
self.btnLvUp:SetActive(isfinish)
|
|
if not isfinish then
|
|
self:SetVipTaskList(self.context.vipLevel)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- function VipPanelV2:GetCurrentStatus(taskListInfo)
|
|
-- local taskFinishNum = 0
|
|
-- for i = 1, #taskListInfo do
|
|
-- if taskListInfo[i].state == VipTaskStatusDef.Received then
|
|
-- taskFinishNum = taskFinishNum + 1
|
|
-- end
|
|
-- end
|
|
-- local maxLv = VipManager.GetMaxVipLevel()
|
|
-- self.progressBar.gameObject:SetActive(self.context.vipLevel ~= maxLv)
|
|
-- if self.context.vipLevel == maxLv then
|
|
-- return VipShowStatusDef.Current
|
|
-- else
|
|
-- self.progressBar.value = taskFinishNum / #taskListInfo
|
|
-- return taskFinishNum >= #taskListInfo and VipShowStatusDef.LevelUp or VipShowStatusDef.Current
|
|
-- end
|
|
-- end
|
|
|
|
function VipPanelV2:SetProgressShow(level)
|
|
local taskLevel = level - 1
|
|
if taskLevel < self.context.vipLevel then
|
|
self.progressBar.value = 1
|
|
self.progressText.text = "4/4"
|
|
elseif taskLevel > self.context.vipLevel then
|
|
self.progressBar.value = 0
|
|
self.progressText.text = "0/4"
|
|
else
|
|
local taskFinishNum = 0
|
|
local taskListInfo = self.context.UserMissionInfo
|
|
for i = 1, #taskListInfo do
|
|
if taskListInfo[i].state == VipTaskStatusDef.Received then
|
|
taskFinishNum = taskFinishNum + 1
|
|
end
|
|
end
|
|
self.progressBar.value = taskFinishNum / #taskListInfo
|
|
self.progressText.text = string.format("%d/%d", taskFinishNum, #taskListInfo)
|
|
end
|
|
end
|
|
|
|
--特权界面
|
|
-- function VipPanelV2:SwitchState(type, isAnimation)
|
|
-- self.currentStatus = type
|
|
-- self.curStatePart:SetActive(type == VipShowStatusDef.Current)
|
|
-- -- self.lvUpPart:SetActive(type == VipShowStatusDef.LevelUp)
|
|
-- -- self.lvUpRedPoint:SetActive(type == VipShowStatusDef.LevelUp)
|
|
-- -- self.previewPart:SetActive(type == VipShowStatusDef.Preview)
|
|
-- if isAnimation then
|
|
-- -- if type == VipShowStatusDef.LevelUp then
|
|
-- -- PlayUIAnim(self.lvUpPart)
|
|
-- -- end
|
|
-- else
|
|
-- if type == VipShowStatusDef.Current then
|
|
-- PlayUIAnim(self.curStatePart)
|
|
-- -- elseif type == VipShowStatusDef.LevelUp then
|
|
-- -- PlayUIAnim(self.lvUpPart)
|
|
-- -- elseif type == VipShowStatusDef.Preview then
|
|
-- -- PlayUIAnim(self.previewPart)
|
|
-- end
|
|
-- end
|
|
-- self.BtnLeft:SetActive(type == VipShowStatusDef.Preview)
|
|
-- local maxLv = VipManager.GetMaxVipLevel()
|
|
-- if self.context.vipLevel < maxLv then
|
|
-- self.BtnLeft:SetActive(type == VipShowStatusDef.Preview)
|
|
-- self.BtnRight:SetActive(type == VipShowStatusDef.Current or type == VipShowStatusDef.LevelUp)
|
|
-- else
|
|
-- self.BtnRight:SetActive(false)
|
|
-- self.BtnLeft:SetActive(false)
|
|
-- end
|
|
-- self.BtnReceive:SetActive(type ~= VipShowStatusDef.Preview)
|
|
-- self:SetVipTitle(type)
|
|
-- end
|
|
-- function VipPanelV2:SetVipTitle(type)
|
|
-- if type == VipShowStatusDef.Current then
|
|
-- self.currentLv.text = self.context.vipLevel
|
|
-- this.CheckVipLvPos(self.currentLvNum,self.context.vipLevel)
|
|
-- self.currentLvNum.text= self.context.vipLevel
|
|
-- elseif type == VipShowStatusDef.LevelUp then
|
|
-- this.CheckVipLvPos(self.lvUpCurNum,self.context.vipLevel)
|
|
-- this.CheckVipLvPos(self.lvUpNexNum,self.context.vipLevel)
|
|
-- self.lvUpCurNum.text=self.context.vipLevel
|
|
-- self.lvUpNexNum.text=self.context.vipLevel + 1
|
|
-- else
|
|
-- self.previewLevel.text = self.context.vipLevel + 1
|
|
-- this.CheckVipLvPos(self.previewNum,self.context.vipLevel)
|
|
-- self.previewNum.text=self.context.vipLevel + 1
|
|
-- end
|
|
-- end
|
|
|
|
--特权相关礼包
|
|
function VipPanelV2:SetVipRewardStatus(configData)
|
|
-- self.BtnReceive:GetComponent("Button").enabled = true
|
|
-- Util.SetGray(self.BtnReceive, false)
|
|
-- self.receiveRedPoint:SetActive(false)
|
|
-- if self.currentStatus == VipShowStatusDef.Preview then
|
|
-- local VipLvConfig = ConfigManager.GetConfigData(ConfigName.VipLevelConfig, self.context.vipLevel + 1)
|
|
-- self.giftTypeIcon.sprite = Util.LoadSprite(ReceiveTypeIconDef[1])
|
|
-- self:SetRewardList(VipLvConfig.VipBoxReward)
|
|
-- self.BtnReceiveText.text = "领 取"
|
|
-- else
|
|
-- if self.context.hadTakeLevelBox == GiftReceivedStatus.NotReceive then
|
|
-- self.giftTypeIcon.sprite = Util.LoadSprite(ReceiveTypeIconDef[1])
|
|
-- self:SetRewardList(configData.VipBoxReward)
|
|
-- self.BtnReceiveText.text = "领 取"
|
|
-- self.receiveRedPoint:SetActive(true)
|
|
-- else
|
|
-- self.giftTypeIcon.sprite = Util.LoadSprite(ReceiveTypeIconDef[2])
|
|
-- self:SetRewardList(configData.VipBoxDailyReward)
|
|
-- if self.context.hadTakeDailyBox == -1 then
|
|
-- self.BtnReceiveText.text = "领 取"
|
|
-- self.receiveRedPoint:SetActive(true)
|
|
-- else
|
|
-- self.BtnReceiveText.text = "已领取"
|
|
-- Util.SetGray(self.BtnReceive, true)
|
|
-- self.BtnReceive:GetComponent("Button").enabled = false
|
|
-- end
|
|
-- end
|
|
-- end
|
|
-- self.giftTypeIcon:SetNativeSize()
|
|
end
|
|
function VipPanelV2:SetRewardList(level)
|
|
local VipLvConfig = ConfigManager.GetConfigData(ConfigName.VipLevelConfig, level)
|
|
local configData = VipLvConfig.Property
|
|
table.walk(self.giftItemList, function(giftItem)
|
|
giftItem:SetActive(false)
|
|
end)
|
|
for idx, dataInfo in ipairs(configData) do
|
|
local id = dataInfo[1]
|
|
local num = dataInfo[2]
|
|
if num ~= 0 then
|
|
self.giftItemList[idx]:SetActive(true)
|
|
local propInfo = ConfigManager.GetConfigData(ConfigName.PropertyConfig, id)
|
|
if propInfo.Style == 1 then
|
|
self.giftItemList[idx]:GetComponent("Text").text = string.format(Language[12023], propInfo.Info)
|
|
Util.GetGameObject(self.giftItemList[idx], "value"):GetComponent("Text").text = "+"..num
|
|
elseif propInfo.Style == 2 then
|
|
self.giftItemList[idx]:GetComponent("Text").text = propInfo.Info
|
|
Util.GetGameObject(self.giftItemList[idx], "value"):GetComponent("Text").text = string.format("+%d%%", num/100)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- function VipPanelV2:OnReceiveBtnClicked()
|
|
-- if self.context.hadTakeLevelBox == GiftReceivedStatus.NotReceive then
|
|
-- NetManager.RequestReceiveVipRights(GiftReceivedType.LevelGift, function(respond)
|
|
-- UIManager.OpenPanel(UIName.RewardItemPopup, respond.drop, 1)
|
|
-- VipManager.SetTakeLevelBoxStatus(GiftReceivedStatus.Received)
|
|
-- self.context.hadTakeLevelBox = GiftReceivedStatus.Received
|
|
-- -- self:ChangeReceivedStatus()
|
|
-- TaskManager.ChangeVipRedPointState()
|
|
-- end)
|
|
-- else
|
|
-- NetManager.RequestReceiveVipRights(GiftReceivedType.DailyGift, function(respond)
|
|
-- UIManager.OpenPanel(UIName.RewardItemPopup, respond.drop, 1)
|
|
-- VipManager.SetTakeDailyBoxStatus(self.context.vipLevel)
|
|
-- self.context.hadTakeDailyBox = self.context.vipLevel
|
|
-- -- self:ChangeReceivedStatus()
|
|
-- TaskManager.ChangeVipRedPointState()
|
|
-- end)
|
|
-- end
|
|
-- end
|
|
--改变领取状态
|
|
-- function VipPanelV2:ChangeReceivedStatus()
|
|
-- local VipLvConfig = ConfigManager.GetConfigData(ConfigName.VipLevelConfig, self.context.vipLevel)
|
|
-- assert(VipLvConfig, string.format("ConfigName.VipLevelConfig not find VipLevel:%s", self.context.vipLevel))
|
|
-- self:SetVipRewardStatus(VipLvConfig)
|
|
-- end
|
|
|
|
--特权增益描述
|
|
function VipPanelV2: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.IfFloat == 1 and privilegeInfo.value > 0)
|
|
or (privilegeInfo.IfFloat == 2 and privilegeInfo.value > 1)
|
|
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.IfFloat == 2 then --特权关卡挂机加成百分比
|
|
Util.GetGameObject(item, "title"):GetComponent("Text").text = string.format(privilegeInfo.content, "<color=#7AB159><size=50>"..(privilegeInfo.value*100-100).."%</size></color>")
|
|
else
|
|
Util.GetGameObject(item, "title"):GetComponent("Text").text = string.format(privilegeInfo.content, "<color=#7AB159><size=50>" .. privilegeInfo.value .. "</size></color>")
|
|
end
|
|
PlayUIAnim(Util.GetGameObject(item, "content"))
|
|
coroutine.wait(0.03)
|
|
--加成为0就别丢人现眼了
|
|
if privilegeInfo.value == 0 then
|
|
-- if privilegeInfo.id==1 and (privilegeInfo.value*100-100)==0 then
|
|
item:SetActive(false)
|
|
else
|
|
item:SetActive(true)
|
|
end
|
|
end
|
|
|
|
end
|
|
end)
|
|
end
|
|
function VipPanelV2:SetExtraPrivilege(index, configData)
|
|
local item = self:GetPrivilegeItem(index)
|
|
item.gameObject:SetActive(true)
|
|
local str = Language[10106]
|
|
for _, rewardInfo in ipairs(configData.VipBoxDailyReward) do
|
|
local itemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig, rewardInfo[1])
|
|
assert(itemConfig, string.format("ConfigName.ItemConfig not find Id:%s", rewardInfo[1]))
|
|
str = str .. string.format("%s<size=45><color=#7bb15bFF>%s</color></size>", itemConfig.Name, rewardInfo[2])
|
|
end
|
|
Util.GetGameObject(item, "title"):GetComponent("Text").text = str
|
|
end
|
|
function VipPanelV2: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 VipPanelV2:SetVipTaskList(level)
|
|
local configData = ConfigManager.GetConfigData(ConfigName.VipLevelConfig, level)
|
|
table.walk(self.taskItemList, function(taskItem)
|
|
taskItem:SetVisible(false)
|
|
end)
|
|
|
|
if level < self.context.vipLevel then
|
|
for i, taskId in ipairs(configData.OpenRules) do
|
|
self.taskItemList[i]:Init(taskId)
|
|
local taskConfigInfo = ConfigManager.GetConfigData(ConfigName.TaskConfig, taskId)
|
|
self.taskItemList[i]:SetValue({state = VipTaskStatusDef.Received, progress = taskConfigInfo.TaskValue[2][1]})
|
|
end
|
|
self:SetTaskAnimation(#configData.OpenRules)
|
|
elseif level > self.context.vipLevel then
|
|
for i, taskId in ipairs(configData.OpenRules) do
|
|
self.taskItemList[i]:Init(taskId)
|
|
self.taskItemList[i]:SetValue({state = VipTaskStatusDef.NotFinished, progress = 0})
|
|
end
|
|
self:SetTaskAnimation(#configData.OpenRules)
|
|
elseif level == self.context.vipLevel then
|
|
if #self.context.UserMissionInfo == 0 then
|
|
return
|
|
end
|
|
for i, taskInfo in ipairs(self.context.UserMissionInfo) do
|
|
self.taskItemList[i]:Init(taskInfo.missionId)
|
|
self.taskItemList[i]:SetValue(taskInfo)
|
|
end
|
|
self:SetTaskAnimation(#self.context.UserMissionInfo)
|
|
end
|
|
end
|
|
function VipPanelV2:SetTaskAnimation(length)
|
|
if self.taskThread then
|
|
coroutine.stop(self.taskThread)
|
|
self.taskThread = nil
|
|
end
|
|
self.taskThread = coroutine.start(function()
|
|
for i = 1, length do
|
|
self.taskItemList[i].cloneObj:SetActive(false)
|
|
PlayUIAnim(Util.GetGameObject(self.taskItemList[i].cloneObj, "content"))
|
|
coroutine.wait(0.05)
|
|
self.taskItemList[i].cloneObj:SetActive(true)
|
|
-- coroutine.wait(0.05)
|
|
end
|
|
end)
|
|
end
|
|
|
|
|
|
function VipPanelV2:OnTurnLeftBtnClicked()
|
|
-- self:SwitchState(self:GetCurrentStatus(self.context.UserMissionInfo))
|
|
if self.curShowLevel <= 1 then
|
|
return
|
|
end
|
|
self.curShowLevel = self.curShowLevel - 1
|
|
self:RefreshPanelStatus(self.curShowLevel)
|
|
|
|
self.BtnLeft:SetActive(self.curShowLevel > 1)
|
|
self.BtnRight:SetActive(self.curShowLevel ~= VipManager.GetMaxVipLevel())
|
|
end
|
|
|
|
function VipPanelV2:OnTurnRightBtnClicked()
|
|
-- self:SwitchState(VipShowStatusDef.Preview)
|
|
if self.curShowLevel >= VipManager.GetMaxVipLevel() then
|
|
return
|
|
end
|
|
self.curShowLevel = self.curShowLevel + 1
|
|
self:RefreshPanelStatus(self.curShowLevel)
|
|
|
|
self.BtnLeft:SetActive(self.curShowLevel > 1)
|
|
self.BtnRight:SetActive(self.curShowLevel ~= VipManager.GetMaxVipLevel())
|
|
end
|
|
|
|
function VipPanelV2:OnBtnLvUpClicked()
|
|
-- if self.context.hadTakeLevelBox == GiftReceivedStatus.NotReceive then
|
|
-- PopupTipPanel.ShowTip("请先领取特权等级礼包")
|
|
-- elseif self.context.hadTakeDailyBox == -1 then
|
|
-- PopupTipPanel.ShowTip("请先领取每日奖励")
|
|
-- else
|
|
NetManager.RequestVipLevelUp(function(respond)
|
|
self:OnShow()
|
|
SoundManager.PlaySound(SoundConfig.Sound_VipUpLevel)
|
|
end)
|
|
-- end
|
|
end
|
|
|
|
--刷新界面
|
|
function VipPanelV2:RefreshPanelStatus(level)
|
|
-- self.privilegeTitle.text = string.format("特权%s增益描述", level)
|
|
-- local VipLvConfig = ConfigManager.GetConfigData(ConfigName.VipLevelConfig, level)
|
|
-- assert(VipLvConfig, string.format("ConfigName.VipLevelConfig not find VipLevel:%s", level))
|
|
-- self:SetVipRewardStatus(VipLvConfig)
|
|
self:SetProgressShow(level)
|
|
self.currentLvNum.text = level
|
|
self:SetVipPrivileges(level)
|
|
-- self:SetVipTaskList(level)
|
|
self:SetRewardList(level)
|
|
end
|
|
|
|
--特权任务发生变化
|
|
function VipPanelV2:OnTaskStatusChanged(taskId)
|
|
for i = 1, #self.context.UserMissionInfo do
|
|
local taskInfo = self.context.UserMissionInfo[i]
|
|
if taskInfo.missionId == taskId then
|
|
taskInfo.state = VipTaskStatusDef.Received
|
|
self.taskItemList[i]:SetValue(taskInfo)
|
|
break
|
|
end
|
|
end
|
|
|
|
if self.curShowLevel - 1 == self.context.vipLevel then
|
|
self:SetProgressShow(self.curShowLevel)
|
|
end
|
|
|
|
--local VipLvConfig = ConfigManager.GetConfigData(ConfigName.VipLevelConfig, self.context.vipLevel)
|
|
--self:SetVipTaskList(VipLvConfig)
|
|
-- self:SwitchState(self:GetCurrentStatus(self.context.UserMissionInfo), true)
|
|
local isfinish = true
|
|
local taskListInfo = self.context.UserMissionInfo
|
|
for i = 1, #taskListInfo do
|
|
if taskListInfo[i].state ~= VipTaskStatusDef.Received then
|
|
isfinish = false
|
|
end
|
|
end
|
|
if isfinish then
|
|
self:CheckTaskShow()
|
|
end
|
|
end
|
|
|
|
--跳转显示新手提示圈
|
|
function this.ShowGuideGo()
|
|
JumpManager.ShowGuide(UIName.VipPanelV2, this.taskItemList[1].dealBtn)
|
|
end
|
|
|
|
--修正因VIP字体导致等级数篡位
|
|
function this.CheckVipLvPos(tarObj,lv)
|
|
if lv>9 then
|
|
tarObj.transform:DOAnchorPosX(10,0)
|
|
else
|
|
tarObj.transform:DOAnchorPosX(0,0)
|
|
end
|
|
end
|
|
|
|
return VipPanelV2 |