miduo_client/Assets/ManagedResources/~Lua/Modules/TimeLimitSkin/TimeLimitSkinPanel.lua

155 lines
5.6 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2021-01-15 17:03:51 +08:00
local TimeLimitSkin = Inherit(BasePanel)
local this = TimeLimitSkin
2021-01-15 17:50:43 +08:00
local _sortingOrder = 0
2021-03-13 15:09:34 +08:00
local gift
local _ItemViewList = {}
2021-01-15 17:50:43 +08:00
2021-01-15 17:03:51 +08:00
--初始化组件(用于子类重写)
function TimeLimitSkin:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2021-01-15 17:50:43 +08:00
this.backBtn = Util.GetGameObject(self.gameObject,"backBtn")
this.time = Util.GetGameObject(self.gameObject,"show/time"):GetComponent("Text")
2021-03-31 14:33:01 +08:00
this.previewBtn = Util.GetGameObject(self.gameObject,"previewBtn")
this.attri = Util.GetGameObject(self.gameObject,"show/attribute"):GetComponent("Text")
this.buyBtn = Util.GetGameObject(self.gameObject,"show/buyBtn")
this.reward = Util.GetGameObject(self.gameObject,"show/reward")
this.buyBtnText = Util.GetGameObject(self.gameObject,"show/buyBtn/Text"):GetComponent("Text")
2021-01-15 17:50:43 +08:00
this.effect = Util.GetGameObject(self.gameObject,"UI_Effect_TeHuiShenZhuang")
2021-01-15 17:03:51 +08:00
end
--绑定事件(用于子类重写)
function TimeLimitSkin:BindEvent()
2021-01-15 17:50:43 +08:00
Util.AddClick(this.backBtn,function ()
this:ClosePanel()
end)
Util.AddClick(this.previewBtn,function ()
2021-03-17 11:29:43 +08:00
local battleId = 1015
local fdata, fseed = BattleManager.GetFakeBattleData(battleId)
local testFightData = {
fightData = fdata,
fightSeed = fseed,
fightType = 0,
maxRound = 20
}
UIManager.OpenPanel(UIName.BattlePanel, testFightData, BATTLE_TYPE.Test,function ()
Timer.New(function ()
2021-03-18 23:18:43 +08:00
TimeLimitSkin:RefreshData()
end,3):Start()
end)
end)
Util.AddClick(this.buyBtn,function ()
PayManager.Pay(gift.goodsId, function(id)
FirstRechargeManager.RefreshAccumRechargeValue(gift.goodsId)
OperatingManager.SetHadBuyGoodsId({gift.goodsId})
OperatingManager.RemoveItemInfoByType(GoodsTypeDef.DirectPurchaseGift, gift.goodsId)
self:ClosePanel()
end)
end)
2021-01-15 17:03:51 +08:00
end
--添加事件监听(用于子类重写)
function TimeLimitSkin:AddListener()
end
--移除事件监听(用于子类重写)
function TimeLimitSkin:RemoveListener()
end
2021-01-15 17:50:43 +08:00
function TimeLimitSkin:OnSortingOrderChange()
2021-06-09 15:58:04 +08:00
-- Util.AddParticleSortLayer( this.effect, self.sortingOrder - _sortingOrder)
Util.SetParticleSortLayer(this.effect, self.sortingOrder + 1)
2021-01-15 17:50:43 +08:00
_sortingOrder = self.sortingOrder
end
2021-01-15 17:03:51 +08:00
--界面打开时调用(用于子类重写)
function TimeLimitSkin:OnOpen()
end
-- 打开,重新打开时回调
function TimeLimitSkin:OnShow()
2021-06-09 15:58:04 +08:00
Util.SetParticleSortLayer(this.effect, self.sortingOrder + 1)
TimeLimitSkin:RefreshData()
2021-01-15 17:03:51 +08:00
end
function TimeLimitSkin:RefreshData()
gift = OperatingManager.GetTimeLimitSkinInfoList()
TimeLimitSkin:SetReward()
TimeLimitSkin:SetTime()
TimeLimitSkin:SetAttri()
2021-04-09 14:13:39 +08:00
this.buyBtnText.text = MoneyUtil.GetMoneyUnitNameWithMoney(ConfigManager.GetConfigDataByKey(ConfigName.RechargeCommodityConfig,"Id",gift.goodsId).Price)
end
function TimeLimitSkin:SetReward()
for k,v in pairs(_ItemViewList) do
v.gameObject:SetActive(false)
end
local rewards = ConfigManager.GetConfigDataByKey(ConfigName.RechargeCommodityConfig,"Id",gift.goodsId).RewardShow
for i=1, #rewards do
if not _ItemViewList[i] then
local view = SubUIManager.Open(SubUIConfig.ItemView,this.reward.transform)
_ItemViewList[i] = view
end
_ItemViewList[i]:OnOpen(false,rewards[i],1.1,false)
_ItemViewList[i].gameObject:SetActive(true)
end
end
function TimeLimitSkin:SetTime()
local time = gift.endTime
2021-04-09 12:26:35 +08:00
this.time.text = Language[10023]..TimeToFelaxible(time-GetTimeStamp())
if this.localTimer then
this.localTimer:Stop()
this.localTimer = nil
end
local lefttime = time-GetTimeStamp()
this.localTimer = Timer.New(function()
if lefttime < 0 then
OperatingManager.RemoveItemInfoByType(GoodsTypeDef.DirectPurchaseGift, gift.goodsId)
self:ClosePanel()
end
2021-04-09 12:26:35 +08:00
this.time.text = Language[10023]..TimeToFelaxible(lefttime)
lefttime = lefttime - 1
end,1,-1,true)
this.localTimer:Start()
end
2021-01-15 17:03:51 +08:00
function TimeLimitSkin:SetAttri()
--LogGreen("gift.goodsId:"..tostring(gift.goodsId))
local reward = ConfigManager.GetConfigDataByKey(ConfigName.RechargeCommodityConfig,"Id",gift.goodsId).RewardShow[4][1]
2021-04-19 20:28:06 +08:00
-- local rg = ConfigManager.GetConfigDataByKey(ConfigName.ItemConfig,"Id",reward).RewardGroup
-- local skins = ConfigManager.GetConfigDataByKey(ConfigName.RewardGroup,"Id",rg[1]).ShowItem
-- local attris = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Id",skins[1][1]).MonomerProperty--所有皮肤加属性相同就用了第一个
local attris = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Id",reward).MonomerProperty
2021-04-09 12:26:35 +08:00
local str = Language[11440]
for i = 1, #attris do
local attriData = ConfigManager.GetConfigData(ConfigName.PropertyConfig,attris[i][1])
2021-04-07 17:20:23 +08:00
local attriName = GetLanguageStrById(attriData.Info)
local num
if attriData.Style == 1 then
num = tostring(attris[i][2])
elseif attriData.Style == 2 then
num = tostring(attris[i][2]/100).."% "
end
str = str..attriName.."+"..num
end
this.attri.text = str
2021-01-15 17:03:51 +08:00
end
--界面关闭时调用(用于子类重写)
function TimeLimitSkin:OnClose()
2021-03-13 15:09:34 +08:00
UIManager.ClosePanel(UIName.PatFacePanel)
if this.localTimer then
this.localTimer:Stop()
this.localTimer = nil
end
2021-01-15 17:03:51 +08:00
end
--界面销毁时调用(用于子类重写)
function TimeLimitSkin:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
_sortingOrder = 0
_ItemViewList = {}
2021-01-15 17:03:51 +08:00
end
return TimeLimitSkin