161 lines
6.0 KiB
Lua
161 lines
6.0 KiB
Lua
require("Base/BasePanel")
|
|
local NiuZhuanQianKun = Inherit(BasePanel)
|
|
local this = NiuZhuanQianKun
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
|
|
local _sortingOrder = 0
|
|
local activityId
|
|
local canRollTime
|
|
local rewardList = {}
|
|
local textList = {}
|
|
local imgList = {}
|
|
local lightList = {}
|
|
|
|
local iconList = {}
|
|
local redList = {}
|
|
local numList = {}
|
|
|
|
local costList={
|
|
[1] = {iconId=1221,on="n_niuzhuanqiankun_niu_zh",off="n_niuzhuanqiankun_niu02_zh"},
|
|
[2] = {iconId=1222,on="n_niuzhuanqiankun_zhuan_zh",off="n_niuzhuanqiankun_zhuan02_zh"},
|
|
[3] = {iconId=1223,on="n_niuzhuanqiankun_qian_zh",off="n_niuzhuanqiankun_qian02_zh"},
|
|
[4] = {iconId=1224,on="n_niuzhuanqiankun_kun_zh",off="n_niuzhuanqiankun_kun02_zh"},
|
|
}
|
|
|
|
--初始化组件(用于子类重写)
|
|
function NiuZhuanQianKun:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.backBtn = Util.GetGameObject(self.gameObject,"backBtn")
|
|
this.title = Util.GetGameObject(self.gameObject,"bg/title")
|
|
this.rollBtn = Util.GetGameObject(self.gameObject,"rollBtn")
|
|
this.center = Util.GetGameObject(self.gameObject,"center")
|
|
this.tip = Util.GetGameObject(self.gameObject,"tip"):GetComponent("Text")
|
|
this.effect = Util.GetGameObject(self.gameObject,"UI_Effect_MianBan_NiuZhuanQianKun")
|
|
this.bottomtip = Util.GetGameObject(self.gameObject,"kuang/tip"):GetComponent("Image")
|
|
for i = 1, 8 do
|
|
rewardList[i] = Util.GetGameObject(self.gameObject,"center/reward"..i)
|
|
textList[i] = Util.GetGameObject(rewardList[i],"Text")
|
|
imgList[i] = Util.GetGameObject(rewardList[i],"img")
|
|
lightList[i] = Util.GetGameObject(self.gameObject,"center/lights/Image ("..i..")")
|
|
end
|
|
for i = 1, 4 do
|
|
iconList[i] = Util.GetGameObject(self.gameObject,"bottom/Img"..i)
|
|
redList[i] = Util.GetGameObject(iconList[i],"numImg")
|
|
numList[i] = Util.GetGameObject(redList[i],"num")
|
|
end
|
|
end
|
|
--绑定事件(用于子类重写)
|
|
function NiuZhuanQianKun:BindEvent()
|
|
Util.AddClick(this.backBtn,function ()
|
|
this:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.rollBtn,function ()
|
|
if canRollTime <= 0 then
|
|
PopupTipPanel.ShowTip(Language[12177])
|
|
return
|
|
end
|
|
NetManager.GoodLuckRequest(activityId,function (msg)
|
|
local thread=coroutine.start(function()
|
|
NiuZhuanQianKun:SetLight()
|
|
this.rollBtn:GetComponent("Button").interactable = false
|
|
this.backBtn:GetComponent("Button").interactable = false
|
|
this.center.transform:DORotate(Vector3.New(0,0,-3600 + (msg.index-1)*45),3)
|
|
NiuZhuanQianKun:SetBottom()
|
|
coroutine.wait(3)
|
|
lightList[msg.index]:SetActive(true)
|
|
coroutine.wait(0.2)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function ()
|
|
this.rollBtn:GetComponent("Button").interactable = true
|
|
this.backBtn:GetComponent("Button").interactable = true
|
|
end)
|
|
end)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function NiuZhuanQianKun:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function NiuZhuanQianKun:RemoveListener()
|
|
end
|
|
|
|
function NiuZhuanQianKun:OnSortingOrderChange()
|
|
Util.AddParticleSortLayer(this.effect, self.sortingOrder - _sortingOrder)
|
|
_sortingOrder = self.sortingOrder
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function NiuZhuanQianKun:OnOpen()
|
|
this.title:GetComponent("Image").sprite = this.spLoader:LoadSprite("n_niuzhuanqiankun_slogan_zh")
|
|
this.rollBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("n_niuzhuanqiankun_anniu01_zh")
|
|
if GetCurLanguage() ~= 0 then
|
|
local state = this.rollBtn:GetComponent("Button").spriteState
|
|
state.pressedSprite = this.spLoader:LoadSprite("n_niuzhuanqiankun_anniu02_zh")
|
|
this.rollBtn:GetComponent("Button").spriteState = state
|
|
end
|
|
this.bottomtip:GetComponent("Image").sprite = this.spLoader:LoadSprite("n_niuzhuanqiankun_zi_zh")
|
|
end
|
|
|
|
-- 打开,重新打开时回调
|
|
function NiuZhuanQianKun:OnShow()
|
|
activityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.NiuZhuan)
|
|
if not activityId or activityId <= 0 then return end
|
|
NiuZhuanQianKun:RefreshData()
|
|
end
|
|
|
|
function NiuZhuanQianKun:RefreshData()
|
|
this.rollBtn:GetComponent("Button").interactable = true
|
|
NiuZhuanQianKun:SetReward()
|
|
NiuZhuanQianKun:SetLight()
|
|
NiuZhuanQianKun:SetBottom()
|
|
end
|
|
|
|
function NiuZhuanQianKun:SetLight()
|
|
for i = 1, #lightList do
|
|
lightList[i]:SetActive(false)
|
|
end
|
|
end
|
|
|
|
function NiuZhuanQianKun:SetReward()
|
|
local goodLuckConfig = ConfigManager.GetConfigDataByKey(ConfigName.GoodLuck,"ActivityId",activityId)
|
|
for i = 1, #goodLuckConfig.Reward do
|
|
local reward = goodLuckConfig.Reward[i]
|
|
textList[i]:GetComponent("Text").text = GetLanguageStrById(itemConfig[reward[1]].Name) .."*"..reward[2]
|
|
imgList[i]:GetComponent("Image").sprite = this.spLoader:LoadSprite(artResourcesConfig[itemConfig[reward[1]].ResourceID].Name)
|
|
end
|
|
end
|
|
|
|
function NiuZhuanQianKun:SetBottom()
|
|
canRollTime = 9999
|
|
for i = 1, 4 do
|
|
local itemNum = BagManager.GetTotalItemNum(costList[i].iconId)
|
|
local sprite = itemNum > 0 and costList[i].on or costList[i].off
|
|
redList[i]:SetActive(itemNum > 0)
|
|
iconList[i]:GetComponent("Image").sprite = this.spLoader:LoadSprite(sprite)
|
|
numList[i]:GetComponent("Text").text = itemNum
|
|
canRollTime = canRollTime < itemNum and canRollTime or itemNum
|
|
end
|
|
this.tip.text = Language[12178]..canRollTime
|
|
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function NiuZhuanQianKun:OnClose()
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function NiuZhuanQianKun:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
_sortingOrder = 0
|
|
rewardList = {}
|
|
textList = {}
|
|
imgList = {}
|
|
lightList = {}
|
|
iconList = {}
|
|
redList = {}
|
|
numList = {}
|
|
end
|
|
return NiuZhuanQianKun |