miduo_client/Assets/ManagedResources/~Lua/Modules/Operating/QianKunBox.lua

125 lines
4.8 KiB
Lua

local QianKunBox = quick_class("QianKunBox")
local ActivityDetail = require("Modules/Operating/ActivityDetail")--活动详情
local iconsData = ConfigManager.GetAllConfigsDataByKey(ConfigName.LotteryRewardConfig,"Pool",4401)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local orginLayer = 0
function QianKunBox:ctor(mainPanel, gameObject)
self.mainPanel = mainPanel.transform
self.gameObject = gameObject
self:InitComponent(gameObject)
self:BindEvent()
end
function QianKunBox:InitComponent(gameObject)
self.tabList = Util.GetGameObject(self.mainPanel,"bg/tabList")
self.btnBack = Util.GetGameObject(self.mainPanel,"bg/btnBack")
self.bottomBar = Util.GetGameObject(self.mainPanel,"bg/bottomBar")
--leftUp
self.leftUp = Util.GetGameObject(gameObject,"leftUp")
self.leftUpTime = Util.GetGameObject(self.leftUp,"tips/tips2/time"):GetComponent("Text")
self.btnHelp= Util.GetGameObject(gameObject,"btnHelp")
self.helpPosition=self.btnHelp:GetComponent("RectTransform").localPosition
--rightUp
self.rightUp = Util.GetGameObject(gameObject,"rightUp")
self.btnReward = Util.GetGameObject(self.rightUp,"reward")
self.btnStore = Util.GetGameObject(self.rightUp,"store")
--center
self.center = Util.GetGameObject(gameObject,"center")
self.icons = Util.GetGameObject(self.center,"icons")
--bottom
self.bottom = Util.GetGameObject(gameObject,"bottom")
self.btnOne = Util.GetGameObject(self.bottom,"btnOne")
self.btnTime = Util.GetGameObject(self.bottom,"btnOne/di/time"):GetComponent("Text")
self.btnTen1 = Util.GetGameObject(self.bottom,"btnTen1")
self.btnTen2 = Util.GetGameObject(self.bottom,"btnTen2")
self.btnTimes= Util.GetGameObject(self.bottom,"btnTen2/di/times"):GetComponent("Text")
self.limit = Util.GetGameObject(self.bottom,"limit")
--detail
self.detail = Util.GetGameObject(gameObject,"detail")
--shop
self.shop = Util.GetGameObject(gameObject,"shop")
self.shopBack = Util.GetGameObject(self.shop,"shopBack/btnBack")
self.content = Util.GetGameObject(self.shop,"content")
self.live = Util.GetGameObject(self.shop,"live")
end
function QianKunBox:BindEvent()
Util.AddClick(self.btnHelp,function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.QianKunBox,self.helpPosition.x,self.helpPosition.y)
end)
Util.AddClick(self.btnReward,function()
ActivityDetail.new(self.detail,2)
end)
Util.AddClick(self.btnStore,function()
self.shop:SetActive(true)
self.btnBack:SetActive(false)
self.tabList:SetActive(false)
self.bottomBar:SetActive(false)
end)
Util.AddClick(self.shopBack,function()
self.shop:SetActive(false)
self.btnBack:SetActive(true)
self.tabList:SetActive(true)
self.bottomBar:SetActive(true)
end)
Util.AddClick(self.btnOne,function()
LogPink("单抽")
end)
Util.AddClick(self.btnTen1,function()
LogYellow("钥匙十连")
end)
Util.AddClick(self.btnTen2,function()
LogPurple("妖晶十连")
end)
end
function QianKunBox:OnShow()
self.gameObject:SetActive(true)
self.btnTen2:SetActive(BagManager.GetItemCountById(16)>=2000)
self.btnTen1:SetActive(BagManager.GetItemCountById(16)<2000)
--五个魂印头像
for i = 1, 5 do
local icon = Util.GetGameObject(self.icons,"icon"..i.."/icon"):GetComponent("Image")
local kuang = Util.GetGameObject(self.icons,"icon"..i.."/kuang"):GetComponent("Image")
local name = artConfig[itemConfig[iconsData[i].Reward[1]].ResourceID].Name
icon.sprite = Util.LoadSprite(name)
if itemConfig[iconsData[i].Reward[1]].Quantity == 5 then--金色
kuang.sprite = Util.LoadSprite("r_hunyin_hunyinkuanghuang001")
end
--点击能查看魂印信息
Util.AddOnceClick(kuang.gameObject,function ()
UIManager.OpenPanel(UIName.SoulPrintPopUp,nil,nil,iconsData[i].Reward[1],nil,nil)
end)
end
--商店
if not self.shopView then
self.shopView = SubUIManager.Open(SubUIConfig.ShopView, self.content.transform)
end
self.shopView:ShowShop(SHOP_TYPE.SOULBOX_SHOP,orginLayer)
self.live = poolManager:LoadLive("live2d_ui_h_52_xx_pf1", self.live.transform, Vector3.New(0.25,0.25,0.25), Vector3.New(123,214,0))
end
function QianKunBox:OnSortingOrderChange(_sortingOrder)
orginLayer = _sortingOrder
end
function QianKunBox:OnHide()
self.gameObject:SetActive(false)
self.detail.gameObject:SetActive(false)
end
function QianKunBox:OnDestroy()
if self.shopView then
self.shopView = SubUIManager.Close(self.shopView)
self.shopView = nil
end
poolManager:UnLoadLive("live2d_ui_h_52_xx_pf1", self.live)
end
return QianKunBox