sk-client/Assets/ManagedResources/~Lua/Modules/PrivilegeCard/PrivilegeTurnTable.lua

948 lines
44 KiB
Lua
Raw Permalink Normal View History

2024-07-03 18:38:10 +08:00
require("Base/BasePanel")
local PrivilegeTurnTable = Inherit(BasePanel)
local this = PrivilegeTurnTable
local BtnBg = {
[3] = GetPictureFont("bt_zhuanpan_bt_tx_02"),
[4] = GetPictureFont("bt_zhuanpan_bt_wm_02"),
[5] = GetPictureFont("bt_zhuanpan_bt_zz_02"),
}
local turnBg = {
[3] = "bt_zhuanpan_bg_tx_03",
[4] = "bt_zhuanpan_bg_wm_03",
[5] = "bt_zhuanpan_bg_zz_03",
}
local BottomBg = {
[3] = "bt_zhuanpan_bg_tx_01",
[4] = "bt_zhuanpan_bg_wm_01",
[5] = "bt_zhuanpan_bg_zz_01",
}
local btnPos = {
[1] = {
x = -341,
y = 0,
},
[2] = {
x = 0,
y = 0,
},
[3] = {
x = -194,
y = 0,
},
[4] = {
x = 197,
y = 0,
},
}
---转盘旋转类型
local TableTurnType = {
Normal = 1,--默认旋转
Expedite = 2,--加快旋转
}
local curTurnPos = 1 --当前位置
this.thread = nil --协程
this.upView = nil
---初始化组件(用于子类重写)
function PrivilegeTurnTable:InitComponent(gameObject)
PrivilegeTurnManager.InitTableData()
this.luckyTurnPanel = Util.GetGameObject(self.gameObject,"Panel")
this.PlayerHeadFrameView = SubUIManager.Open(SubUIConfig.PlayerHeadFrameView, self.gameObject.transform)
this.upView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
this.maskBG = Util.GetGameObject(this.luckyTurnPanel,"Mask")
this.helpBtn = Util.GetGameObject(this.luckyTurnPanel,"HelpBtn")
this.helpPosition = this.helpBtn:GetComponent("RectTransform").localPosition
this.backBtn = Util.GetGameObject(this.luckyTurnPanel,"BackBtn")
--this.activityCountDownText = Util.GetGameObject(this.luckyTurnPanel, "CountDownTimeText"):GetComponent("Text")--活动倒计时
this.luckyTreasureBtn = Util.GetGameObject(this.luckyTurnPanel, "Content/Top/LuckyTreasureBtn")--幸运探宝按钮
this.luckyTreasureBtn:GetComponent("Image").sprite = Util.LoadSprite(GetPictureFont("bt_zhuanpan_bt_tx_01"))
this.luckyTreasureTitle = Util.GetGameObject(this.luckyTreasureBtn,"title"):GetComponent("Image")
this.advancedTreasureBtn = Util.GetGameObject(this.luckyTurnPanel, "Content/Top/AdvancedTreasureBtn")--高级探宝按钮
this.advancedTreasureBtn:GetComponent("Image").sprite = Util.LoadSprite(GetPictureFont("bt_zhuanpan_bt_wm_01"))
this.zhiZunBtn = Util.GetGameObject(this.luckyTurnPanel, "Content/Top/ZhiZunTurn")--高级探宝按钮
this.zhiZunBtn:GetComponent("Image").sprite = Util.LoadSprite(GetPictureFont("bt_zhuanpan_bt_zz_01"))
this.advancedTreasureText = Util.GetGameObject(this.advancedTreasureBtn,"Text"):GetComponent("Text")
this.advancedTreasureTitle = Util.GetGameObject(this.advancedTreasureBtn,"title"):GetComponent("Image")
this.bg2 = Util.GetGameObject(this.luckyTurnPanel, "Content/TurnTableImage/BG/BG2")
this.countDesc = Util.GetGameObject(this.luckyTurnPanel, "Bottom/DescText"):GetComponent("Text")
this.turnBg = Util.GetGameObject(this.bg2, "bg"):GetComponent("Image")
this.bottomBgImg = Util.GetGameObject(this.luckyTurnPanel, "bottomBg"):GetComponent("Image")
this.oneRed = Util.GetGameObject(this.luckyTreasureBtn,"redPoint")
this.twoRed = Util.GetGameObject(this.advancedTreasureBtn,"redPoint")
this.threeRed = Util.GetGameObject(this.zhiZunBtn,"redPoint")
this.maskRed = Util.GetGameObject(this.luckyTurnPanel,"Content/Top/mask/redPoint")
---跑马灯位置(物品位置)
this.itemList = {}
for i = 1,8 do
this.itemList[i] = Util.GetGameObject(this.luckyTurnPanel, "Content/TurnTableImage/ItemList/Item"..i)
end
this.itemEffectIcon = {}--跑马灯亮灯
this.itemViewList = {}--跑马灯itemviewList
this.itemViewCurPos = {}
local tab = {{14,0},{3,0},{12001,0},{5,0},{4,0},{21,0},{60068,0},{60071,0}}---防白片临时数据
for i = 1, 8 do
this.itemEffectIcon[i] = Util.GetGameObject(this.itemList[i], "Image")
local parent = Util.GetGameObject(this.itemList[i].transform,"box").transform
this.itemViewList[i] = SubUIManager.Open(SubUIConfig.ItemView,parent)
this.itemViewList[i]:OnOpen(false, {tab[1][1],tab[1][2]},0.75)
local rect = this.itemViewList[i].transform
rect.anchoredPosition = Vector2.New(0,0)
rect.anchorMin = Vector2.New(0.5, 0.5)
rect.anchorMax = Vector2.New(0.5, 0.5)
rect.pivot = Vector2.New(0.5, 0.5)
this.itemViewCurPos[i] = this.itemList[i].transform.position
end
--拥有道具数量
this.bottom = Util.GetGameObject(this.luckyTurnPanel,"Bottom")
this.treasureOnceBtn = Util.GetGameObject(this.bottom,"TreasureOnceBtn")
this.treasureOnceText = Util.GetGameObject(this.treasureOnceBtn,"Text"):GetComponent("Text")--探宝次数
this.treasureOnceIcon = Util.GetGameObject(this.treasureOnceBtn,"Icon"):GetComponent("Image")--消耗道具图标
this.treasureOnceNum = Util.GetGameObject(this.treasureOnceBtn,"Num"):GetComponent("Text")--消耗道具数量
this.treasureMultipleBtn = Util.GetGameObject(this.bottom,"TreasureMultipleBtn")
this.treasureMultipleText = Util.GetGameObject(this.treasureMultipleBtn,"Text"):GetComponent("Text")
this.treasureMultipleIcon = Util.GetGameObject(this.treasureMultipleBtn,"Icon"):GetComponent("Image")
this.treasureMultipleNum = Util.GetGameObject(this.treasureMultipleBtn,"Num"):GetComponent("Text")
this.slider = Util.GetGameObject(this.luckyTurnPanel,"Slider")
this.luckyValueNum = Util.GetGameObject(this.slider, "LuckyValue/LuckyValueNum"):GetComponent("Text")--幸运值
this.luckySlider = Util.GetGameObject(this.slider, "LuckySlider"):GetComponent("Slider")
this.rewardBoxList = {}--奖励盒
this.rewardBox = Util.GetGameObject(this.slider,"RewardBox")
for i = 1,3 do
this.rewardBoxList[i] = Util.GetGameObject(this.rewardBox,"Item"..i)
end
this.rewardPanel = Util.GetGameObject(this.slider,"RewardPanel")--幸运值奖励预览面板
this.itemViewParent = Util.GetGameObject(this.rewardPanel,"ItemViewParent")--item父物体
this.rewardPanelMaskBtn = Util.GetGameObject(this.rewardPanel,"Mask")--幸运值奖励预览遮罩按钮
this.rewardItemView = SubUIManager.Open(SubUIConfig.ItemView,this.itemViewParent.transform)
-- 奖励预览
this.btnPreview = Util.GetGameObject(self.gameObject, "Panel/Content/Top/btnPreview")
this.mask = Util.GetGameObject(self.gameObject, "Panel/Content/Top/mask")
this.maskText = Util.GetGameObject(this.mask,"Text"):GetComponent("Text")
this.maskTitle = Util.GetGameObject(self.gameObject, "Panel/Content/Top/mask"):GetComponent("Image")
this.material = Util.GetGameObject(this.rewardBox,"material"):GetComponent("Image").material
this.shopBtn = Util.GetGameObject(self.gameObject, "Panel/Content/shopBtn")
this.allMask = Util.GetGameObject(self.gameObject, "mask")
end
---绑定事件(用于子类重写)
function PrivilegeTurnTable:BindEvent()
--帮助按钮
Util.AddClick(this.helpBtn,function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.LuckyTurn,this.helpPosition.x,this.helpPosition.y)
end)
--返回按钮
Util.AddClick(this.backBtn,function()
self:ClosePanel()
end)
--幸运探宝按钮
Util.AddClick(this.luckyTreasureBtn, function()
this.SwitchTreasureType(TreasureType.PrivilegeOne)
-- this.luckyTreasureBtn:SetActive(false)
-- this.advancedTreasureBtn:SetActive(true)
this.mask.transform.position = this.luckyTreasureBtn.transform.position
this.maskTitle.sprite = Util.LoadSprite(BtnBg[TreasureType.PrivilegeOne])
this.turnBg.sprite = Util.LoadSprite(turnBg[TreasureType.PrivilegeOne])
this.bottomBgImg.sprite = Util.LoadSprite(BottomBg[TreasureType.PrivilegeOne])
end)
Util.AddClick(this.zhiZunBtn, function()
this.SwitchTreasureType(TreasureType.PrivilegeThree)
-- this.luckyTreasureBtn:SetActive(false)
-- this.advancedTreasureBtn:SetActive(false)
this.mask.transform.position = this.zhiZunBtn.transform.position
this.maskTitle.sprite = Util.LoadSprite(BtnBg[TreasureType.PrivilegeThree])
this.turnBg.sprite = Util.LoadSprite(turnBg[TreasureType.PrivilegeThree])
this.bottomBgImg.sprite = Util.LoadSprite(BottomBg[TreasureType.PrivilegeThree])
end)
--高级探宝按钮
Util.AddClick(this.advancedTreasureBtn, function()
this.SwitchTreasureType(TreasureType.PrivilegeTwo)
-- this.luckyTreasureBtn:SetActive(true)
-- this.advancedTreasureBtn:SetActive(false)
this.mask.transform.position = this.advancedTreasureBtn.transform.position
this.maskTitle.sprite = Util.LoadSprite(BtnBg[TreasureType.PrivilegeTwo])
this.turnBg.sprite = Util.LoadSprite(turnBg[TreasureType.PrivilegeTwo])
this.bottomBgImg.sprite = Util.LoadSprite(BottomBg[TreasureType.PrivilegeTwo])
end)
--幸运值奖励预览遮罩按钮
Util.AddClick(this.rewardPanelMaskBtn, function()
this.rewardPanelMaskBtn.gameObject:SetActive(false)
this.rewardPanel.gameObject:SetActive(false)
end)
Util.AddClick(this.btnPreview, function()
local index = 6
if PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeTwo then
index = 7
elseif PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeThree then
index = 8
end
UIManager.OpenPanel(UIName.HeroPreviewPanel, index, false)
end)
Util.AddClick(this.shopBtn, function()
UIManager.OpenPanel(UIName.MainShopPanel, 61)
end)
end
---添加事件监听(用于子类重写)
function PrivilegeTurnTable:RefreshTitleRedpot(PriviType)
end
---添加事件监听(用于子类重写)
function PrivilegeTurnTable:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Privilege.RefreshPrivilegeTurn, this.NewDay)
end
---移除事件监听(用于子类重写)
function PrivilegeTurnTable:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Privilege.RefreshPrivilegeTurn, this.NewDay)
end
---界面打开时调用(用于子类重写)
function PrivilegeTurnTable:OnOpen(_TreasureType)
PrivilegeTurnManager.curTreasureType = _TreasureType and _TreasureType or TreasureType.PrivilegeOne
end
function PrivilegeTurnTable:SetBtnState()
local isShow = PrivilegeTurnManager.GetPrivilrgeTurnIsShow(TreasureType.PrivilegeThree)
if isShow then
this.zhiZunBtn:SetActive(true)
this.luckyTreasureBtn:GetComponent("RectTransform").localPosition = Vector2.New(btnPos[1].x, btnPos[1].y)
this.advancedTreasureBtn:GetComponent("RectTransform").localPosition = Vector2.New(btnPos[2].x, btnPos[2].y)
else
this.zhiZunBtn:SetActive(false)
this.luckyTreasureBtn:GetComponent("RectTransform").localPosition = Vector2.New(btnPos[3].x, btnPos[3].y)
this.advancedTreasureBtn:GetComponent("RectTransform").localPosition = Vector2.New(btnPos[4].x, btnPos[4].y)
end
end
function PrivilegeTurnTable:GetState(index)
local actRewardConfig = ConfigManager.GetConfigData(ConfigName.TequanCardConfig, index)
local buyPrivilegeState = PrivilegeManager.GetPrivilegeOpenStatusById(actRewardConfig.PrivilegeID)
if buyPrivilegeState then
return true
else
return false
end
end
function PrivilegeTurnTable.NewDay()
PrivilegeTurnTable:OnShow()
end
---界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function PrivilegeTurnTable:OnShow()
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
PrivilegeTurnTable:SetBtnState()
this.maskBG.gameObject:SetActive(false)
--Log("PrivilegeTurnManager.curTreasureType "..PrivilegeTurnManager.curTreasureType)
if PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeOne then--防止当前为高级探宝时 按下探宝后跳转到幸运探宝
this.LuckyTurnOnShow(TreasureType.PrivilegeOne)
this.mask.transform.position = this.luckyTreasureBtn.transform.position
this.maskTitle.sprite = Util.LoadSprite(BtnBg[TreasureType.PrivilegeOne])
this.turnBg.sprite =Util.LoadSprite(turnBg[TreasureType.PrivilegeOne])
this.bottomBgImg.sprite =Util.LoadSprite(BottomBg[TreasureType.PrivilegeOne])
elseif PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeTwo then
this.LuckyTurnOnShow(TreasureType.PrivilegeTwo)
this.mask.transform.position = this.advancedTreasureBtn.transform.position
this.maskTitle.sprite = Util.LoadSprite(BtnBg[TreasureType.PrivilegeTwo])
this.turnBg.sprite =Util.LoadSprite(turnBg[TreasureType.PrivilegeTwo])
this.bottomBgImg.sprite =Util.LoadSprite(BottomBg[TreasureType.PrivilegeTwo])
elseif PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeThree then
this.LuckyTurnOnShow(TreasureType.PrivilegeThree)
this.mask.transform.position = this.zhiZunBtn.transform.position
this.maskTitle.sprite = Util.LoadSprite(BtnBg[TreasureType.PrivilegeThree])
this.turnBg.sprite =Util.LoadSprite(turnBg[TreasureType.PrivilegeThree])
this.bottomBgImg.sprite =Util.LoadSprite(BottomBg[TreasureType.PrivilegeThree])
end
this.PlayerHeadFrameView:OnShow()
this.upView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
end)
end
local sortingOrder = 0
---重设层级
function PrivilegeTurnTable:OnSortingOrderChange()
sortingOrder = self.sortingOrder
for i, v in pairs(this.itemViewList) do
v:SetEffectLayer(sortingOrder)
end
end
---界面关闭时调用(用于子类重写)
function PrivilegeTurnTable:OnClose()
this.rewardPanel.gameObject:SetActive(false)
if this.thread then
coroutine.stop(this.thread)
this.thread = nil
end
if this.turnEffect then
this.turnEffect:Stop()
this.turnEffect = nil
end
if this.outsideLightTurnEffect then
this.outsideLightTurnEffect:Stop()
this.outsideLightTurnEffect = nil
end
end
---界面销毁时调用(用于子类重写)
function PrivilegeTurnTable:OnDestroy()
this.itemViewList = nil
this.rewardItemView = nil
SubUIManager.Close(this.upView)
end
---打开面板
function this.LuckyTurnOnShow(treasureType)
if not this.turnEffect then
this.turnEffect = Timer.New(nil,1,-1,true)
end
if not this.outsideLightTurnEffect then
this.outsideLightTurnEffect = Timer.New(nil,1,-1,true)
end
--初始化幸运探宝
this.SwitchTreasureType(treasureType)
this.SetTableTurnEffect(TableTurnType.Normal)
end
---切换探宝类型
function this.SwitchTreasureType(treasureType)
PrivilegeTurnManager.curTreasureType = treasureType
this.ClearDefault()
if treasureType == TreasureType.PrivilegeOne then
PrivilegeTurnTable.curTreasureType = treasureType
local countNum = PrivilegeTurnManager.GetTurnNums(treasureType)+PrivilegeTurnManager.GetPrivilegeAddTurnNums(treasureType)
this.upView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
this.bg2:SetActive(true)
--设置顶部按钮
local turnData = PrivilegeTurnManager.GetPrivilrgeTurnItems(treasureType)
this.SetItemViewShow(turnData)
-- --请求跑马灯物品数据
-- LuckyTurnTableManager.GetLuckyTurnRequest(function(msg)
-- this.SetItemViewShow(msg.posInfos,function()
-- this.SetItemViewGray(LuckyTurnTableManager.luckyData)
-- end)
-- end)
-- --立即刷新一次转盘记录
-- if LuckyTurnTableManager.isCanGetWorldMessage then
-- LuckyTurnTableManager.TimeUpdate()
-- end
-- --启动定时刷新转盘记录
-- LuckyTurnTableManager.StartLuckyTurnRecordDataUpdate()
--探宝按钮显示
local oneData,moreData,icon = PrivilegeTurnManager.GetTreasureBtnInfo(treasureType)
this.SetTreasureBtnShow(oneData,moreData,icon)
-- --探宝泉预览
-- Util.AddOnceClick(this.propBtn,function()
-- UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,60)
-- end)
--探宝1次按钮
Util.AddOnceClick(this.treasureOnceBtn, function()
if PrivilegeTurnManager.GetTreasureTicketNum(treasureType) - oneData[2] >= 0 then --抽奖判断
if PrivilegeTurnManager.GetPrivilrgeTurnCount(treasureType) - 1 >= 0 then
this.DelayMaskWithBool(true)
--判断次数
NetManager.PrivilegeWheelDrawRequest(PrivilegeTurnManager.curTreasureType, 1, function(msg)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
this.SetTableTurnEffect(TableTurnType.Expedite, msg.drop, msg.pos)
-- Log("pos "..msg.pos)
this.RrFreshInfo()
end)
end)
else
if this.GetOpenPrivilege(TreasureType.PrivilegeOne) then
PopupTipPanel.ShowTip(GetLanguageStrById(50407))
else
this.JumpPrivilegeCard(function()
UIManager.OpenPanel(UIName.PrivilegeCardPanel)
PrivilegeTurnTable:ClosePanel()
end)
end
end
else
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,16,nil)
end
end)
--探宝10次按钮
Util.AddOnceClick(this.treasureMultipleBtn, function()
if PrivilegeTurnManager.GetTreasureTicketNum(treasureType) - moreData[2] >= 0 then
if PrivilegeTurnManager.GetPrivilrgeTurnCount(treasureType) - 10 >= 0 then
--判断次数
this.DelayMaskWithBool(true)
NetManager.PrivilegeWheelDrawRequest(PrivilegeTurnManager.curTreasureType,2,function(msg)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
this.SetTableTurnEffect(TableTurnType.Expedite, msg.drop, msg.pos)
this.RrFreshInfo()
end)
end)
else
if this.GetOpenPrivilege(TreasureType.PrivilegeOne) then
PopupTipPanel.ShowTip(GetLanguageStrById(50407))
else
this.JumpPrivilegeCard(function()
UIManager.OpenPanel(UIName.PrivilegeCardPanel)
PrivilegeTurnTable:ClosePanel()
end)
end
end
else
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, 16, nil)
end
end)
this.RrFreshInfo()
elseif treasureType == TreasureType.PrivilegeTwo then
PrivilegeTurnTable.curTreasureType = treasureType
this.upView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
this.bg2:SetActive(true) --设置材质
--设置顶部按钮
local turnData = PrivilegeTurnManager.GetPrivilrgeTurnItems(treasureType)
this.SetItemViewShow(turnData)
-- --请求跑马灯物品数据
-- LuckyTurnTableManager.GetLuckyTurnRequest(function(msg)
-- this.SetItemViewShow(msg.posInfosAdvance,function()
-- this.SetItemViewGray(LuckyTurnTableManager.advancedData)
-- end)
-- end)
-- --立即刷新一次转盘记录
-- if LuckyTurnTableManager.isCanGetWorldMessage then
-- LuckyTurnTableManager.TimeUpdate()
-- end
-- --启动定时刷新转盘记录
-- LuckyTurnTableManager.StartLuckyTurnRecordDataUpdate(treasureType)
--探宝按钮显示
local oneData,moreData,icon = PrivilegeTurnManager.GetTreasureBtnInfo(treasureType)
this.SetTreasureBtnShow(oneData,moreData,icon)
-- --探宝泉预览
-- Util.AddOnceClick(this.propBtn,function()
-- UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,61)
-- end)
--探宝1次按钮
Util.AddOnceClick(this.treasureOnceBtn, function()
if PrivilegeTurnManager.GetTreasureTicketNum(treasureType) - oneData[2] >= 0 then
if PrivilegeTurnManager.GetPrivilrgeTurnCount(treasureType) - 1 >= 0 then
--判断次数
this.DelayMaskWithBool(true)
NetManager.PrivilegeWheelDrawRequest(PrivilegeTurnManager.curTreasureType,1,function(msg)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
this.SetTableTurnEffect(TableTurnType.Expedite,msg.drop,msg.pos)
this.RrFreshInfo()
end)
end)
else
if this.GetOpenPrivilege(TreasureType.PrivilegeTwo) then
PopupTipPanel.ShowTip(GetLanguageStrById(50407))
else
this.JumpPrivilegeCard(function()
UIManager.OpenPanel(UIName.PrivilegeCardPanel)
PrivilegeTurnTable:ClosePanel()
end)
end
end
else
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,16,nil)
end
end)
--探宝10次按钮
Util.AddOnceClick(this.treasureMultipleBtn, function()
if PrivilegeTurnManager.GetTreasureTicketNum(treasureType) - moreData[2] >= 0 then
if PrivilegeTurnManager.GetPrivilrgeTurnCount(treasureType) - 10 >= 0 then
this.DelayMaskWithBool(true)
NetManager.PrivilegeWheelDrawRequest(PrivilegeTurnManager.curTreasureType,2,function(msg)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
this.SetTableTurnEffect(TableTurnType.Expedite,msg.drop,msg.pos)
this.RrFreshInfo()
end)
end)
else
if this.GetOpenPrivilege(TreasureType.PrivilegeTwo) then
PopupTipPanel.ShowTip(GetLanguageStrById(50407))
else
this.JumpPrivilegeCard(function()
UIManager.OpenPanel(UIName.PrivilegeCardPanel)
PrivilegeTurnTable:ClosePanel()
end)
end
end
else
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,16,nil)
end
end)
this.RrFreshInfo()
elseif treasureType == TreasureType.PrivilegeThree then
PrivilegeTurnTable.curTreasureType = treasureType
this.upView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
this.bg2:SetActive(true) --设置材质
--设置顶部按钮
local turnData = PrivilegeTurnManager.GetPrivilrgeTurnItems(treasureType)
this.SetItemViewShow(turnData)
-- --请求跑马灯物品数据
-- LuckyTurnTableManager.GetLuckyTurnRequest(function(msg)
-- this.SetItemViewShow(msg.posInfosAdvance,function()
-- this.SetItemViewGray(LuckyTurnTableManager.advancedData)
-- end)
-- end)
-- --立即刷新一次转盘记录
-- if LuckyTurnTableManager.isCanGetWorldMessage then
-- LuckyTurnTableManager.TimeUpdate()
-- end
-- --启动定时刷新转盘记录
-- LuckyTurnTableManager.StartLuckyTurnRecordDataUpdate(treasureType)
--探宝按钮显示
local oneData,moreData,icon = PrivilegeTurnManager.GetTreasureBtnInfo(treasureType)
this.SetTreasureBtnShow(oneData,moreData,icon)
-- --探宝泉预览
-- Util.AddOnceClick(this.propBtn,function()
-- UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,61)
-- end)
--探宝1次按钮
Util.AddOnceClick(this.treasureOnceBtn, function()
if PrivilegeTurnManager.GetTreasureTicketNum(treasureType) - oneData[2] >= 0 then
if PrivilegeTurnManager.GetPrivilrgeTurnCount(treasureType) - 1 >= 0 then
--判断次数
this.DelayMaskWithBool(true)
NetManager.PrivilegeWheelDrawRequest(PrivilegeTurnManager.curTreasureType, 1, function(msg)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
this.SetTableTurnEffect(TableTurnType.Expedite, msg.drop, msg.pos)
this.RrFreshInfo()
end)
end)
else
if this.GetOpenPrivilege(TreasureType.PrivilegeThree) then
PopupTipPanel.ShowTip(GetLanguageStrById(50407))
else
this.JumpPrivilegeCard(function()
UIManager.OpenPanel(UIName.PrivilegeCardPanel)
PrivilegeTurnTable:ClosePanel()
end)
end
end
else
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,16,nil)
end
end)
--探宝10次按钮
Util.AddOnceClick(this.treasureMultipleBtn, function()
if PrivilegeTurnManager.GetTreasureTicketNum(treasureType) - moreData[2] >= 0 then
if PrivilegeTurnManager.GetPrivilrgeTurnCount(treasureType) - 10 >= 0 then
--判断次数
this.DelayMaskWithBool(true)
NetManager.PrivilegeWheelDrawRequest(PrivilegeTurnManager.curTreasureType,2,function(msg)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
this.SetTableTurnEffect(TableTurnType.Expedite,msg.drop,msg.pos)
this.RrFreshInfo()
end)
end)
else
if this.GetOpenPrivilege(TreasureType.PrivilegeThree) then
PopupTipPanel.ShowTip(GetLanguageStrById(50407))
else
this.JumpPrivilegeCard(function()
UIManager.OpenPanel(UIName.PrivilegeCardPanel)
PrivilegeTurnTable:ClosePanel()
end)
end
end
else
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,16,nil)
end
end)
this.RrFreshInfo()
end
this.mask.transform:SetAsLastSibling()
end
function this.GetOpenPrivilege(turnType)
--local data = this.dialRewardSettingConfig[turnType].OpenRules --
local isopen = true
local data = ConfigManager.GetConfigData(ConfigName.DialRewardSetting, turnType)
if data.OpenRules == nil then
return true
end
for i = 1, #data.OpenRules do
local PrivilegeData = ConfigManager.GetConfigDataByKey(ConfigName.TequanCardConfig,"PrivilegeID", data.OpenRules[i])
if PrivilegeManager.GetPrivilegeOpenStatusById(PrivilegeData.PrivilegeID) == false then
isopen = false
end
end
return isopen
end
--重置默认
function this.ClearDefault()
--清除红点
Util.GetGameObject(this.luckyTreasureBtn,"redPoint"):SetActive(false)
Util.GetGameObject(this.advancedTreasureBtn,"redPoint"):SetActive(false)
for i = 1, 3 do
Util.GetGameObject(this.rewardBoxList[i],"redPoint"):SetActive(false)
end
-- for i = 1, 6 do
-- this.recordTextList[i].text = ""
-- end
end
function this.JumpPrivilegeCard(func)
MsgPanel.ShowTwo("是否前往激活特权", nil, function()
if func then
func()
end
end)
end
--设置转盘滚动 1旋转类型 2探宝类型 3服务器给的探宝后位置
function this.SetTableTurnEffect(turnType,Drop,pos)
if turnType == TableTurnType.Normal then --默认旋转
this.TurnEffectReset(0.5)
this.turnEffect:Start()
elseif turnType == TableTurnType.Expedite then --抽奖旋转 至指定位置
this.DelayMaskWithBool(true)
-- LuckyTurnTableManager.isCanGetWorldMessage = false
this.TurnEffectReset(0.05)
this.turnEffect:Start()
this.thread = coroutine.start(function()
-- coroutine.wait(0.1)
-- this.TurnEffectReset(0.)
coroutine.wait(0.1)
this.TurnEffectReset(0.1,true,pos,function()--当效果播放完毕后 从管理器取得数据
local timer = Timer.New(function()
this.DelayMaskWithBool(false)
UIManager.OpenPanel(UIName.RewardItemPopup,Drop,1,function()
this.SetTableTurnEffect(TableTurnType.Normal)--恢复转盘旋转
-- LuckyTurnTableManager.isCanGetWorldMessage = true
end)--打开奖励弹窗
-- this.SetItemViewGray(LuckyTurnTableManager.luckyData)--刷新物品是否置灰
-- if treasureType == TreasureType.PrivilegeOne then
-- elseif treasureType == TreasureType.PrivilegeTwo then
-- UIManager.OpenPanel(UIName.RewardItemPopup,LuckyTurnTableManager.advancedTempData.drop,1,function()
-- this.SetTableTurnEffect(TableTurnType.Normal)--恢复转盘旋转
-- -- LuckyTurnTableManager.isCanGetWorldMessage = true
-- end)
-- this.SetItemViewGray(LuckyTurnTableManager.advancedData)
-- end
end,0.5,1,true)
timer:Start()
end)
end)
end
end
--转盘滚动特效重设 1移动速度,值越小越快 2是否停止 3停止位置
function this.TurnEffectReset(turnSpeed,isStop,pos,func)
this.turnEffect:Reset(function()
if curTurnPos == 1 then
this.itemEffectIcon[8]:SetActive(false)
else
this.itemEffectIcon[curTurnPos-1]:SetActive(false)
end
if curTurnPos >= 9 then
curTurnPos = 1
end
if isStop then
if pos == curTurnPos then--如果停到对应位置
this.turnEffect:Stop()--暂停跑马灯
if func then--回调
func()
end
end
end
this.itemEffectIcon[curTurnPos]:SetActive(true)
curTurnPos = curTurnPos + 1
end,turnSpeed,-1,true)
end
--设置跑马灯物品显示 func确保先生成itemview 再置灰
function this.SetItemViewShow(data)
for i = 1, #this.itemViewList do
local tab = {PrivilegeTurnManager.dialRewardConfig[data[i].luckId].Reward[1],PrivilegeTurnManager.dialRewardConfig[data[i].luckId].Reward[2]}
this.itemViewList[i]:OnOpen(false, {tab[1],tab[2]},1, false, false, false, sortingOrder)
end
end
--设置跑马灯物品置灰
-- function this.SetItemViewGray(data)
-- for i = 1, #data do
-- if LuckyTurnTableManager.dialRewardConfig[data[i].luckId].LimitNum ~= 0 then
-- Util.SetGray(this.itemViewList[i].gameObject,data[i].luckTimes >= LuckyTurnTableManager.dialRewardConfig[data[i].luckId].LimitNum)
-- end
-- if LuckyTurnTableManager.dialRewardConfig[data[i].luckId].LimitNum == 0 then
-- Util.SetGray(this.itemViewList[i].gameObject,false)
-- end
-- end
-- end
--探宝按钮显示
function this.SetTreasureBtnShow(oneData,moreData,icon)
this.treasureOnceText.text = GetLanguageStrById(11143)..oneData[1]..GetLanguageStrById(10054)
this.treasureOnceNum.text = oneData[2]
this.treasureOnceIcon.sprite = icon
this.treasureMultipleText.text = GetLanguageStrById(11143)..moreData[1]..GetLanguageStrById(10054)
this.treasureMultipleNum.text = moreData[2]
this.treasureMultipleIcon.sprite = icon
end
---本地检查红点 幸运高级按钮
function this.CheckRedPoint()
this.oneRed:SetActive(false)
this.twoRed:SetActive(false)
this.threeRed:SetActive(false)
this.maskRed:SetActive(false)
local index = PrivilegeTurnManager.curTreasureType
local data = PrivilegeTurnManager.GetAllData()
if data then
for key, value in pairs(data) do
if value.wheelId and value.leftTimes then
if index == value.wheelId then
if value.leftTimes > 0 then
this.maskRed:SetActive(true)
end
end
if value.wheelId == TreasureType.PrivilegeOne and PrivilegeTurnManager.curTreasureType ~= TreasureType.PrivilegeOne then
if value.leftTimes > 0 then
this.oneRed:SetActive(true)
end
elseif value.wheelId == TreasureType.PrivilegeTwo and PrivilegeTurnManager.curTreasureType ~= TreasureType.PrivilegeTwo then
if value.leftTimes > 0 then
this.twoRed:SetActive(true)
end
elseif value.wheelId == TreasureType.PrivilegeThree and PrivilegeTurnManager.curTreasureType ~= TreasureType.PrivilegeThree then
if value.leftTimes > 0 then
this.threeRed:SetActive(true)
end
end
end
end
end
end
---设置奖盒
function this.SetRewardBox()
local privilegeScore = PrivilegeTurnManager.GetPrivilrgeTurnScore(PrivilegeTurnManager.curTreasureType)
if PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeOne then
for i = 1, 3 do
local BG1 = Util.GetGameObject(this.rewardBoxList[i],"BG1"):GetComponent("Image")
local BG2 = Util.GetGameObject(this.rewardBoxList[i],"BG1/BG2"):GetComponent("Image")
local baoxiang = Util.GetGameObject(this.rewardBoxList[i],"BG1/UI_baoxiang")
Util.GetGameObject(this.rewardBoxList[i],"Value"):GetComponent("Text").text = PrivilegeTurnManager.boxReward_One[i].score
BG2.sprite = SetIcon(PrivilegeTurnManager.boxReward_One[i].itemId)
BG1.sprite = SetFrame(PrivilegeTurnManager.boxReward_One[i].itemId)
Util.GetGameObject(this.rewardBoxList[i],"yilingqu"):SetActive(false)
--显示奖盒红点
--BG1:灰色合箱子 BG2:灰色开箱子 BG3:彩色合箱子
if privilegeScore >= PrivilegeTurnManager.boxReward_One[i].score then --设置幸运值
if PrivilegeTurnManager.GetPrivilrgeItemRewardState(PrivilegeTurnManager.curTreasureType,i-1) then
Util.GetGameObject(this.rewardBoxList[i],"redPoint"):SetActive(true)
BG1.material = nil
BG2.material = nil
baoxiang:SetActive(true)
else--奖励已领取
BG1.material = this.material
BG2.material = this.material
baoxiang:SetActive(false)
Util.GetGameObject(this.rewardBoxList[i],"yilingqu"):SetActive(true)
end
else--幸运值未超过该箱子
BG1.material = this.material
BG2.material = this.material
baoxiang:SetActive(false)
end
Util.AddOnceClick(this.rewardBoxList[i], function()
-- RedpotManager.CheckRedPointStatus(RedPointType.LuckyTurn)
--如果幸运值达到奖励要求值
if privilegeScore >= PrivilegeTurnManager.boxReward_One[i].score then
--奖励未领取 先请求领取
if PrivilegeTurnManager.GetPrivilrgeItemRewardState(PrivilegeTurnManager.curTreasureType, i-1) then
NetManager.PrivilegeWheelAwardRequet(PrivilegeTurnManager.curTreasureType, i-1, function(msg)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop)
Util.GetGameObject(this.rewardBoxList[i],"redPoint"):SetActive(false)--隐藏红点
this.RrFreshInfo()
end)
end)
return
end
end
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, PrivilegeTurnManager.boxReward_One[i].itemId)
end)
end
elseif PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeTwo then
for i = 1, 3 do
local BG1 = Util.GetGameObject(this.rewardBoxList[i],"BG1"):GetComponent("Image")
local BG2 = Util.GetGameObject(this.rewardBoxList[i],"BG1/BG2"):GetComponent("Image")
local baoxiang = Util.GetGameObject(this.rewardBoxList[i],"BG1/UI_baoxiang")
Util.GetGameObject(this.rewardBoxList[i],"Value"):GetComponent("Text").text = PrivilegeTurnManager.boxReward_Two[i].score
BG2.sprite = SetIcon(PrivilegeTurnManager.boxReward_Two[i].itemId)
BG1.sprite = SetFrame(PrivilegeTurnManager.boxReward_Two[i].itemId)
Util.GetGameObject(this.rewardBoxList[i],"yilingqu"):SetActive(false)
--显示红点
if privilegeScore >= PrivilegeTurnManager.boxReward_Two[i].score then
if PrivilegeTurnManager.GetPrivilrgeItemRewardState(PrivilegeTurnManager.curTreasureType,i-1) then
Util.GetGameObject(this.rewardBoxList[i],"redPoint"):SetActive(true)
BG1.material = nil
BG2.material = nil
baoxiang:SetActive(true)
else
BG1.material = this.material
BG2.material = this.material
baoxiang:SetActive(false)
Util.GetGameObject(this.rewardBoxList[i],"yilingqu"):SetActive(true)
end
else
BG1.material = this.material
BG2.material = this.material
baoxiang:SetActive(false)
end
Util.AddOnceClick(this.rewardBoxList[i], function()
RedpotManager.CheckRedPointStatus(RedPointType.LuckyTurn)
if privilegeScore >= PrivilegeTurnManager.boxReward_One[i].score then
if PrivilegeTurnManager.GetPrivilrgeItemRewardState(PrivilegeTurnManager.curTreasureType, i-1) then
NetManager.PrivilegeWheelAwardRequet(PrivilegeTurnManager.curTreasureType, i-1,function(drop)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
UIManager.OpenPanel(UIName.RewardItemPopup,drop)
Util.GetGameObject(this.rewardBoxList[i],"redPoint"):SetActive(false)--隐藏红点
this.RrFreshInfo()
end)
end)
return
end
end
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, PrivilegeTurnManager.boxReward_Two[i].itemId)
end)
end
elseif PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeThree then
for i = 1, 3 do
local BG1 = Util.GetGameObject(this.rewardBoxList[i], "BG1"):GetComponent("Image")
local BG2 = Util.GetGameObject(this.rewardBoxList[i], "BG1/BG2"):GetComponent("Image")
local baoxiang = Util.GetGameObject(this.rewardBoxList[i], "BG1/UI_baoxiang")
Util.GetGameObject(this.rewardBoxList[i], "Value"):GetComponent("Text").text = PrivilegeTurnManager.boxReward_Three[i].score
BG2.sprite = SetIcon(PrivilegeTurnManager.boxReward_Three[i].itemId)
BG1.sprite = SetFrame(PrivilegeTurnManager.boxReward_Three[i].itemId)
Util.GetGameObject(this.rewardBoxList[i],"yilingqu"):SetActive(false)
--显示红点
if privilegeScore >= PrivilegeTurnManager.boxReward_Three[i].score then
if PrivilegeTurnManager.GetPrivilrgeItemRewardState(PrivilegeTurnManager.curTreasureType,i-1) then
Util.GetGameObject(this.rewardBoxList[i], "redPoint"):SetActive(true)
BG1.material = nil
BG2.material = nil
baoxiang:SetActive(true)
else
BG1.material = this.material
BG2.material = this.material
baoxiang:SetActive(false)
Util.GetGameObject(this.rewardBoxList[i], "yilingqu"):SetActive(true)
end
else
BG1.material = this.material
BG2.material = this.material
baoxiang:SetActive(false)
end
Util.AddOnceClick(this.rewardBoxList[i], function()
RedpotManager.CheckRedPointStatus(RedPointType.LuckyTurn)
if privilegeScore >= PrivilegeTurnManager.boxReward_One[i].score then
if PrivilegeTurnManager.GetPrivilrgeItemRewardState(PrivilegeTurnManager.curTreasureType, i-1) then
NetManager.PrivilegeWheelAwardRequet(PrivilegeTurnManager.curTreasureType, i-1, function(drop)
PrivilegeTurnManager.SetPrivilrgeTurnData(function()
UIManager.OpenPanel(UIName.RewardItemPopup,drop)
Util.GetGameObject(this.rewardBoxList[i],"redPoint"):SetActive(false)--隐藏红点
this.RrFreshInfo()
end)
end)
return
end
end
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, PrivilegeTurnManager.boxReward_Three[i].itemId)
end)
end
end
end
---刷新幸运值
function this.RefreshLuckyValue()
local data = {}
if PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeOne then
data = PrivilegeTurnManager.boxReward_One
elseif PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeTwo then
data = PrivilegeTurnManager.boxReward_Two
elseif PrivilegeTurnManager.curTreasureType == TreasureType.PrivilegeThree then
data = PrivilegeTurnManager.boxReward_Three
end
this.luckySlider.maxValue = data[#data].score
local sign = Util.GetGameObject(this.luckySlider.gameObject, "Fill/Image")
for i = 1, 3 do
this.luckySlider.value = data[i].score
local pos = sign.transform.position
this.rewardBoxList[i].transform.position = pos
local rPos = this.rewardBoxList[i].transform.localPosition
this.rewardBoxList[i].transform.localPosition = Vector3.New(rPos.x-50, rPos.y+70, 0)
end
local data = PrivilegeTurnManager.GetPrivilrgeTurnScore(PrivilegeTurnManager.curTreasureType)
this.luckySlider.minValue = 0
this.luckyValueNum.text = data
this.luckySlider.value = data
local countNum = PrivilegeTurnManager.GetTurnNums(PrivilegeTurnManager.curTreasureType)+PrivilegeTurnManager.GetPrivilegeAddTurnNums(PrivilegeTurnManager.curTreasureType)
this.countDesc.text = string.format(GetLanguageStrById(50406), PrivilegeTurnManager.GetPrivilrgeTurnCount(PrivilegeTurnManager.curTreasureType), countNum)
end
---刷新信息
function this.RrFreshInfo()
this.RefreshLuckyValue()
this.CheckRedPoint()
this.SetRewardBox()
-- RedpotManager.CheckRedPointStatus(RedPointType.LuckyTurn)
end
---延时遮罩 1按时间
function this.DelayMaskWithTime(delayTime)
this.maskBG.gameObject:SetActive(true)
this.allMask:SetActive(true)
local closeMask = Timer.New(function()
this.maskBG.gameObject:SetActive(false)
this.allMask:SetActive(false)
end,delayTime,1,true)
closeMask:Start()
end
---延时遮罩 1按bool
function this.DelayMaskWithBool(b)
if b then
this.maskBG.gameObject:SetActive(true)
this.allMask:SetActive(true)
else
this.maskBG.gameObject:SetActive(false)
this.allMask:SetActive(false)
end
end
return PrivilegeTurnTable