Merge branch '0活动开发聚集地/惊喜礼盒' into china/dev-inner

dev_chengFeng
jiaoyangna 2021-06-17 17:56:51 +08:00
commit 4c1cd67e6e
3 changed files with 1258 additions and 508 deletions

View File

@ -141,6 +141,11 @@ local TypeUpdateFunc = {
end
end
end
for i = #curData.rewards, 1,-1 do
if curData.rewards[i].progress == 5 then
table.remove(curData.rewards,i)
end
end
end,
}

View File

@ -1,5 +1,7 @@
require("Base/BasePanel")
local SurpriseBox = Inherit(BasePanel)
local rechargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
function SurpriseBox:InitComponent()
self.spLoader = SpriteLoader.New()
@ -7,9 +9,10 @@ function SurpriseBox:InitComponent()
self.mask = Util.GetGameObject(self.gameObject, "mask")
self.scrollItem = Util.GetGameObject(self.gameObject, "panel/kuang/scroll")
self.itemPre = Util.GetGameObject(self.gameObject, "ItemPre")
self.viewText = Util.GetGameObject(self.gameObject, "panel/view/Text")
self.viewList = {}
for i = 1, 4 do
self.viewList[i] = Util.GetGameObject(self.gameObject, "panel/view/Grid/Item"..i.."")
self.viewList[i] = Util.GetGameObject(self.gameObject, "panel/view/Grid/Item ("..i..")")
end
local rootHight = self.scrollItem.transform.rect.height
@ -21,6 +24,8 @@ function SurpriseBox:InitComponent()
self.itemList = {}
self.lightList = {}
self.jiantouList = {}
self.itemViewList = {}
end
--绑定事件(用于子类重写)
@ -54,7 +59,7 @@ function SurpriseBox:Refresh()
PlayerPrefs.SetInt(PlayerManager.uid.."SurpriseBoxPatFaceDay"..self.actData.value,1)
SurpriseBox:CheckCurBox()
SurpriseBox:SetItemList()
-- self.scrollView:SetIndex(self.curBoxIndex)
self.scrollView:SetIndex(self.curBoxIndex-1 > 0 and self.curBoxIndex-1 or 1)
SurpriseBox:SetViewList()
end
@ -63,6 +68,7 @@ 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
self.PackData = self.actData.rewards[i]
return
end
end
@ -77,7 +83,6 @@ 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")
@ -89,34 +94,39 @@ function SurpriseBox:ShowSingleData(item,data,index)
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")
local jiantou = Util.GetGameObject(item,"jiantou")
local finished = Util.GetGameObject(item,"finished")
img:SetActive(false)
img:SetActive(data.otherData.Warning ~= nil)
box.sprite = self.spLoader:LoadSprite("q_qiankun_xiangzi_01")--有色宝箱
tip:SetActive(false)
tipText.text = string.format("第%s天开启",NumToSimplenessFont[data.otherData.BuyDay])
tipText.text = string.format("%s天后可购买", data.otherData.BuyDay - self.actData.value)
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)
jiantou:SetActive(self.curBoxIndex == data.otherData.BuyDay)
self.lightList[item] = light
self.jiantouList[item] = jiantou
finished:SetActive(false)
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)
lock:SetActive(true)
elseif data.progress == 7 then--可见了,未解锁,不可预览
box.sprite = self.spLoader:LoadSprite("j_jingxilihe_baoxiang2")--灰色宝箱
tip:SetActive(true)
lock:SetActive(false)
lock:SetActive(true)
elseif data.progress == 8 then--买完了
box.sprite = self.spLoader:LoadSprite("j_jingxilihe_baoxiang2")--灰色宝箱
finished:SetActive(true)
end
Util.AddOnceClick(getBtn,function ()
@ -145,13 +155,43 @@ function SurpriseBox:ShowSingleData(item,data,index)
for key, value in pairs(self.lightList) do
value:SetActive(false)
end
for key, value in pairs(self.jiantouList) do
value:SetActive(false)
end
light:SetActive(true)
jiantou:SetActive(true)
self.curBoxIndex = data.otherData.BuyDay
self.PackData = data
SurpriseBox:SetViewList()
end)
end
function SurpriseBox:SetViewList()
-- body
for i = 1, 4 do
self.viewList[i]:SetActive(false)
end
if self.PackData.progress ~= 7 then
self.viewText:SetActive(false)
local reward = self.PackData.otherData.Reward
for i = 1, #reward do
self.viewList[i]:SetActive(true)
local icon = Util.GetGameObject(self.viewList[i],"icon"):GetComponent("Image")
local name = Util.GetGameObject(self.viewList[i],"Text"):GetComponent("Text")
if not self.itemViewList[i] then
self.itemViewList[i] = SubUIManager.Open(SubUIConfig.ItemView,self.viewList[i].transform)
end
self.itemViewList[i]:OnOpen(false, reward[i], 0,false,false,false,self.sortingOrder)
icon.sprite = SetIcon(self.spLoader,reward[i][1])
name.text = string.format("%s×%s",itemConfig[reward[i][1]].Name,reward[i][2])
Util.AddOnceClick(icon.gameObject,function ()
self.itemViewList[i]:OnBtnCkickEvent(reward[i][1])
end)
end
else
self.viewText:SetActive(true)
self.viewText:GetComponent("Text").text = string.format("%s天后开启敬请期待···",self.PackData.otherData.BuyDay - self.actData.value)
end
end
function SurpriseBox:OnClose()
@ -163,6 +203,8 @@ function SurpriseBox:OnDestroy()
self.viewList = {}
self.itemList = {}
self.lightList = {}
self.jiantouList = {}
self.itemViewList = {}
end
return SurpriseBox