155 lines
5.6 KiB
Lua
155 lines
5.6 KiB
Lua
require("Base/BasePanel")
|
|
local TimeLimitSkin = Inherit(BasePanel)
|
|
local this = TimeLimitSkin
|
|
|
|
local _sortingOrder = 0
|
|
local gift
|
|
local _ItemViewList = {}
|
|
|
|
--初始化组件(用于子类重写)
|
|
function TimeLimitSkin:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.backBtn = Util.GetGameObject(self.gameObject,"backBtn")
|
|
this.time = Util.GetGameObject(self.gameObject,"show/time"):GetComponent("Text")
|
|
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")
|
|
this.effect = Util.GetGameObject(self.gameObject,"UI_Effect_TeHuiShenZhuang")
|
|
end
|
|
--绑定事件(用于子类重写)
|
|
function TimeLimitSkin:BindEvent()
|
|
Util.AddClick(this.backBtn,function ()
|
|
this:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.previewBtn,function ()
|
|
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 ()
|
|
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)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function TimeLimitSkin:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function TimeLimitSkin:RemoveListener()
|
|
end
|
|
|
|
function TimeLimitSkin:OnSortingOrderChange()
|
|
-- Util.AddParticleSortLayer( this.effect, self.sortingOrder - _sortingOrder)
|
|
Util.SetParticleSortLayer(this.effect, self.sortingOrder + 1)
|
|
_sortingOrder = self.sortingOrder
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function TimeLimitSkin:OnOpen()
|
|
|
|
end
|
|
|
|
-- 打开,重新打开时回调
|
|
function TimeLimitSkin:OnShow()
|
|
Util.SetParticleSortLayer(this.effect, self.sortingOrder + 1)
|
|
TimeLimitSkin:RefreshData()
|
|
end
|
|
|
|
function TimeLimitSkin:RefreshData()
|
|
gift = OperatingManager.GetTimeLimitSkinInfoList()
|
|
TimeLimitSkin:SetReward()
|
|
TimeLimitSkin:SetTime()
|
|
TimeLimitSkin:SetAttri()
|
|
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
|
|
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
|
|
this.time.text = Language[10023]..TimeToFelaxible(lefttime)
|
|
lefttime = lefttime - 1
|
|
end,1,-1,true)
|
|
this.localTimer:Start()
|
|
end
|
|
|
|
function TimeLimitSkin:SetAttri()
|
|
--LogGreen("gift.goodsId:"..tostring(gift.goodsId))
|
|
local reward = ConfigManager.GetConfigDataByKey(ConfigName.RechargeCommodityConfig,"Id",gift.goodsId).RewardShow[4][1]
|
|
-- 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
|
|
local str = Language[11440]
|
|
for i = 1, #attris do
|
|
local attriData = ConfigManager.GetConfigData(ConfigName.PropertyConfig,attris[i][1])
|
|
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
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function TimeLimitSkin:OnClose()
|
|
UIManager.ClosePanel(UIName.PatFacePanel)
|
|
if this.localTimer then
|
|
this.localTimer:Stop()
|
|
this.localTimer = nil
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function TimeLimitSkin:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
_sortingOrder = 0
|
|
_ItemViewList = {}
|
|
end
|
|
return TimeLimitSkin |