2021-06-16 11:59:52 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
local SurpriseBox = Inherit(BasePanel)
|
|
|
|
|
|
|
|
|
|
function SurpriseBox:InitComponent()
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
2021-06-16 19:56:10 +08:00
|
|
|
|
self.btnBack = Util.GetGameObject(self.gameObject, "panel/btnBack")
|
|
|
|
|
self.mask = Util.GetGameObject(self.gameObject, "mask")
|
2021-06-17 15:26:10 +08:00
|
|
|
|
self.scrollItem = Util.GetGameObject(self.gameObject, "panel/kuang/scroll")
|
|
|
|
|
self.itemPre = Util.GetGameObject(self.gameObject, "ItemPre")
|
|
|
|
|
self.viewList = {}
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
self.viewList[i] = Util.GetGameObject(self.gameObject, "panel/view/Grid/Item("..i..")")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local rootHight = self.scrollItem.transform.rect.height
|
|
|
|
|
local width = self.scrollItem.transform.rect.width
|
|
|
|
|
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollItem.transform,
|
|
|
|
|
self.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 0))
|
|
|
|
|
self.scrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
self.scrollView.moveTween.Strength = 2
|
|
|
|
|
|
|
|
|
|
self.itemList = {}
|
|
|
|
|
self.lightList = {}
|
2021-06-16 11:59:52 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function SurpriseBox:BindEvent()
|
2021-06-16 19:56:10 +08:00
|
|
|
|
Util.AddClick(self.mask, function()
|
|
|
|
|
self:ClosePanel()
|
2021-06-16 11:59:52 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.btnBack, function()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function SurpriseBox:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function SurpriseBox:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function SurpriseBox:OnOpen()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function SurpriseBox:OnShow()
|
2021-06-16 19:56:10 +08:00
|
|
|
|
SurpriseBox:Refresh()
|
2021-06-16 11:59:52 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SurpriseBox:Refresh()
|
2021-06-16 19:56:10 +08:00
|
|
|
|
self.actData = CommonActPageManager.GetData(ActivityTypeDef.SurpriseBox)
|
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."SurpriseBoxPatFaceDay"..self.actData.value,1)
|
2021-06-17 15:26:10 +08:00
|
|
|
|
SurpriseBox:CheckCurBox()
|
|
|
|
|
SurpriseBox:SetItemList()
|
|
|
|
|
-- self.scrollView:SetIndex(self.curBoxIndex)
|
|
|
|
|
SurpriseBox:SetViewList()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--判断当前第几个箱子亮起
|
|
|
|
|
function SurpriseBox:CheckCurBox()
|
|
|
|
|
for i = 1, #self.actData.rewards do
|
|
|
|
|
if self.actData.rewards[i].progress ~= 8 then
|
|
|
|
|
self.curBoxIndex = self.actData.rewards[i].otherData.BuyDay
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-06-16 11:59:52 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-06-17 15:26:10 +08:00
|
|
|
|
--Set左侧礼盒列表
|
|
|
|
|
function SurpriseBox:SetItemList()
|
|
|
|
|
self.scrollView:SetData(self.actData.rewards, function (index, item)
|
|
|
|
|
SurpriseBox:ShowSingleData(item, self.actData.rewards[index],index)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SurpriseBox:ShowSingleData(item,data,index)
|
|
|
|
|
LogGreen("PackId:"..tostring(data.otherData.PackId).." State:"..tostring(data.progress))
|
|
|
|
|
if data.progress == 5 then return end
|
|
|
|
|
local box = Util.GetGameObject(item,"box"):GetComponent("Image")
|
|
|
|
|
local lock = Util.GetGameObject(item,"lock")
|
|
|
|
|
local getBtn = Util.GetGameObject(item,"getBtn")
|
|
|
|
|
local img = Util.GetGameObject(item,"Img")
|
|
|
|
|
local light1 = Util.GetGameObject(item,"light1")
|
|
|
|
|
local light2 = Util.GetGameObject(item,"light2")
|
|
|
|
|
local light = data.otherData.BuyDay == 1 and light1 or light2
|
|
|
|
|
local tip = Util.GetGameObject(item,"Tip")
|
|
|
|
|
local tipText = Util.GetGameObject(item,"Tip/Text"):GetComponent("Text")
|
|
|
|
|
local price = Util.GetGameObject(item,"getBtn/Price")
|
|
|
|
|
local priceText = Util.GetGameObject(item,"getBtn/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
img:SetActive(false)
|
|
|
|
|
box.sprite = self.spLoader:LoadSprite("q_qiankun_xiangzi_01")--有色宝箱
|
|
|
|
|
tip:SetActive(false)
|
|
|
|
|
tipText.text = string.format("第%s天开启",NumToSimplenessFont[data.otherData.BuyDay])
|
|
|
|
|
price:SetActive(true)
|
|
|
|
|
priceText.text = string.format("%s元",data.otherData.Price)
|
|
|
|
|
lock:SetActive(false)
|
|
|
|
|
light1:SetActive(false)
|
|
|
|
|
light2:SetActive(false)
|
|
|
|
|
light:SetActive(self.curBoxIndex == data.otherData.BuyDay)
|
|
|
|
|
self.lightList[item] = light
|
|
|
|
|
|
|
|
|
|
if data.progress == 1 then--完成所有条件,可购买
|
|
|
|
|
elseif data.progress == 2 then--可见了,解锁了,未到购买时间
|
|
|
|
|
elseif data.progress == 3 then--可见了,解锁了,到达购买时间,前置礼包未购买
|
|
|
|
|
elseif data.progress == 4 then--可见了,解锁了,到达购买时间,前置礼包购买了,未激活月卡特权
|
|
|
|
|
img:SetActive(true)
|
|
|
|
|
elseif data.progress == 6 then--可见了,未解锁,可预览
|
|
|
|
|
box.sprite = self.spLoader:LoadSprite("j_jingxilihe_baoxiang2")--灰色宝箱
|
|
|
|
|
tip:SetActive(true)
|
|
|
|
|
lock:SetActive(false)
|
|
|
|
|
elseif data.progress == 7 then--可见了,未解锁,不可预览
|
|
|
|
|
box.sprite = self.spLoader:LoadSprite("j_jingxilihe_baoxiang2")--灰色宝箱
|
|
|
|
|
tip:SetActive(true)
|
|
|
|
|
lock:SetActive(false)
|
|
|
|
|
elseif data.progress == 8 then--买完了
|
|
|
|
|
box.sprite = self.spLoader:LoadSprite("j_jingxilihe_baoxiang2")--灰色宝箱
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(getBtn,function ()
|
|
|
|
|
if data.progress == 1 then--完成所有条件,可购买
|
|
|
|
|
PayManager.Pay(data.otherData.PackId, function(id)
|
|
|
|
|
FirstRechargeManager.RefreshAccumRechargeValue(data.otherData.PackId)
|
|
|
|
|
OperatingManager.SetHadBuyGoodsId({data.otherData.PackId})
|
|
|
|
|
OperatingManager.RemoveItemInfoByType(GoodsTypeDef.DirectPurchaseGift, data.otherData.PackId)
|
|
|
|
|
self:Refresh()
|
|
|
|
|
end)
|
|
|
|
|
elseif data.progress == 2 then--可见了,解锁了,未到购买时间
|
|
|
|
|
PopupTipPanel.ShowTip("礼盒尚未开启,请耐心等待")
|
|
|
|
|
elseif data.progress == 3 then--可见了,解锁了,到达购买时间,前置礼包未购买
|
|
|
|
|
PopupTipPanel.ShowTip("请先购买上一个礼盒")
|
|
|
|
|
elseif data.progress == 4 then--可见了,解锁了,到达购买时间,前置礼包购买了,未激活月卡特权
|
|
|
|
|
PopupTipPanel.ShowTip(data.otherData.Warning)
|
|
|
|
|
elseif data.progress == 6 then--可见了,未解锁,可预览
|
|
|
|
|
PopupTipPanel.ShowTip("礼盒尚未开启,请耐心等待")
|
|
|
|
|
elseif data.progress == 7 then--可见了,未解锁,不可预览
|
|
|
|
|
PopupTipPanel.ShowTip("礼盒尚未开启,请耐心等待")
|
|
|
|
|
elseif data.progress == 8 then--买完了
|
|
|
|
|
PopupTipPanel.ShowTip("已购买该礼盒")
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(box.gameObject,function ()
|
|
|
|
|
for key, value in pairs(self.lightList) do
|
|
|
|
|
value:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
light:SetActive(true)
|
|
|
|
|
self.curBoxIndex = data.otherData.BuyDay
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SurpriseBox:SetViewList()
|
|
|
|
|
-- body
|
|
|
|
|
end
|
2021-06-16 11:59:52 +08:00
|
|
|
|
|
|
|
|
|
function SurpriseBox:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function SurpriseBox:OnDestroy()
|
2021-06-17 15:26:10 +08:00
|
|
|
|
self.viewList = {}
|
|
|
|
|
self.itemList = {}
|
|
|
|
|
self.lightList = {}
|
2021-06-16 11:59:52 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return SurpriseBox
|