miduo_client/Assets/ManagedResources/~Lua/Modules/Expert/ExChange.lua

175 lines
6.8 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
local ExChange = quick_class("ExChange")
2020-05-09 13:31:21 +08:00
local this = ExChange
local exChangeInfoGrid = {}--限时兑换内容
local heroConfig
2020-06-28 17:52:29 +08:00
local itemList = {} --itemView优化
local cursortingOrder
2020-05-09 13:31:21 +08:00
function ExChange:ctor(mainPanel, gameObject)
self.mainPanel = mainPanel
self.gameObject = gameObject
self:InitComponent(gameObject)
self:BindEvent()
end
--初始化组件(用于子类重写)
function ExChange:InitComponent(gameObject)
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.timeTextExChangeGo = Util.GetGameObject(gameObject, "timeText")
this.timeTextExChange = Util.GetGameObject(gameObject, "timeText"):GetComponent("Text")
this.exChangeRewardIcon = Util.GetGameObject(gameObject, "downbg1/info/itemViewParent/icon"):GetComponent("Image")
this.exChangeRewardParent = Util.GetGameObject(gameObject, "downbg2/itemRewardParent")
this.exChangeBuyNum = Util.GetGameObject(gameObject, "downbg2/buyInfo/buyNum"):GetComponent("Text")
this.exChangeBuyIcon = Util.GetGameObject(gameObject, "downbg2/buyInfo/icon"):GetComponent("Image")
this.exChangeBuyBtn = Util.GetGameObject(gameObject, "downbg2/buyInfo/addBtn")
for i = 1, 4 do
exChangeInfoGrid[i] = Util.GetGameObject(gameObject, "downbg1/info/infoTextGrid/infoText ("..i..")")
end
this.exChangeGoBtn = Util.GetGameObject(gameObject, "downbg2/goBtn")
this.goBtnRedpot = Util.GetGameObject(gameObject, "downbg2/goBtn/redpot")
2020-05-09 13:31:21 +08:00
this.click = Util.GetGameObject(gameObject, "leftUpGO/click")
this.live2dRoot = Util.GetGameObject(gameObject, "bg/live")
this.profession = Util.GetGameObject(gameObject, "leftUpGO/posImage/posImage"):GetComponent("Image")
this.proImage = Util.GetGameObject(gameObject, "leftUpGO/proImage"):GetComponent("Image")
this.heroName = Util.GetGameObject(gameObject, "leftUpGO/heroName"):GetComponent("Text")
this.quality = Util.GetGameObject(gameObject, "leftUpGO/Natural"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function ExChange:BindEvent()
Util.AddClick(this.click, function()
UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, heroConfig.Id, heroConfig.Star)
end)
-- 前往兑换红点
BindRedPointObject(RedPointType.LimitExchange_GoExchange, this.goBtnRedpot)
2020-05-09 13:31:21 +08:00
end
--添加事件监听(用于子类重写)
function ExChange:AddListener()
end
--移除事件监听(用于子类重写)
function ExChange:RemoveListener()
end
--界面打开时调用(用于子类重写)
function ExChange:OnOpen(...)
2020-09-25 14:11:05 +08:00
itemList = {}
2020-05-09 13:31:21 +08:00
end
local sortingOrder = 0
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ExChange:OnShow(_sortingOrder)
sortingOrder = _sortingOrder
this:ExChangeShow()
end
2020-06-28 17:52:29 +08:00
function ExChange:OnSortingOrderChange(_cursortingOrder)
cursortingOrder = _cursortingOrder
for i, v in pairs(itemList) do
v:SetEffectLayer(cursortingOrder)
end
end
2020-05-09 13:31:21 +08:00
--限时兑换活动
this.liveNode=nil
this.liveName=nil
function ExChange:ExChangeShow()
local LimitExchange = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.LimitExchange)
if LimitExchange then
2021-03-02 16:53:12 +08:00
local str = Language[10573]
2020-09-25 14:11:05 +08:00
-- Log("LimitExchange "..LimitExchange.endTime)
2020-07-29 18:36:36 +08:00
PatFaceManager.RemainTimeDown(this.timeTextExChangeGo,this.timeTextExChange,LimitExchange.endTime - GetTimeStamp(),str)
2020-05-09 13:31:21 +08:00
else
this.timeTextExChangeGo:SetActive(false)
end
local exChangeConFig = ConfigManager.GetConfigDataByKey(ConfigName.ExchangeActivityConfig, "ActivityId", LimitExchange.activityId)
heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig,exChangeConFig.AwardHeroId)
if this.liveNode then
poolManager:UnLoadLive(this.liveName, this.liveNode)
this.liveName=nil
end
this.liveName = GetResourcePath(heroConfig.Live)
this.liveNode = poolManager:LoadLive(this.liveName, this.live2dRoot.transform,
Vector3.one * exChangeConFig.HeroShowScale, Vector3.New(exChangeConFig.HeroShowLocation[1], exChangeConFig.HeroShowLocation[2],0))
2021-04-21 13:12:04 +08:00
this.profession.sprite = this.spLoader:LoadSprite(GetJobSpriteStrByJobNum(heroConfig.Profession))
this.proImage.sprite =this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
2021-01-26 17:08:39 +08:00
this.heroName.text =GetLanguageStrById(heroConfig.ReadingName)
SetTextVerTial(this.heroName,Vector3.New(129.9,3.7,0))
2020-05-09 13:31:21 +08:00
this.quality.text = heroConfig.Natural
2020-06-28 17:52:29 +08:00
--Util.ClearChild(this.exChangeRewardParent.transform)
2020-05-09 13:31:21 +08:00
for i = 1, #exChangeConFig.ShowItem do
local rewardInfo = {exChangeConFig.ShowItem[i],0}
2020-06-28 17:52:29 +08:00
if itemList[i] then
itemList[i]:OnOpen(false,rewardInfo,1.1,false,false,false,sortingOrder)
else
itemList[i] = SubUIManager.Open(SubUIConfig.ItemView, this.exChangeRewardParent.transform)
itemList[i]:OnOpen(false,rewardInfo,1.1,false,false,false,sortingOrder)
end
2020-05-09 13:31:21 +08:00
end
local itemConFig = ConfigManager.GetConfigData(ConfigName.ItemConfig,exChangeConFig.ActivityItem)
2021-04-21 13:12:04 +08:00
this.exChangeRewardIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConFig.ResourceID))
2020-05-09 13:31:21 +08:00
this.exChangeBuyNum.text = PrintWanNum(BagManager.GetItemCountById(exChangeConFig.ActivityItem))
2021-04-21 13:12:04 +08:00
this.exChangeBuyIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConFig.ResourceID))
2021-01-26 17:08:39 +08:00
local descTabs = string.split( GetLanguageStrById(exChangeConFig.Desc),"#")
2020-05-09 13:31:21 +08:00
for i = 1, #exChangeInfoGrid do
if #descTabs >= i then
exChangeInfoGrid[i]:SetActive(true)
exChangeInfoGrid[i]:GetComponent("Text").text = "·"..descTabs[i]
else
exChangeInfoGrid[i]:SetActive(false)
end
end
Util.AddOnceClick(this.exChangeBuyBtn, function()
JumpManager.GoJump(exChangeConFig.ItemJump)
end)
Util.AddOnceClick(this.exChangeGoBtn, function()
local exChangeConFig = ConfigManager.GetConfigData(ConfigName.ExchangeActivityConfig,1)
if not ShopManager.IsActive(exChangeConFig.ShopId) then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10574])
2020-05-09 13:31:21 +08:00
return
end
UIManager.OpenPanel(UIName.MainShopPanel,exChangeConFig.ShopId)
-- 关闭红点儿显示
ActivityGiftManager.SetExchangeRedStatus(false)
CheckRedPointStatus(RedPointType.LimitExchange_GoExchange)
2020-05-09 13:31:21 +08:00
end)
end
--界面关闭时调用(用于子类重写)
function ExChange:OnClose()
if this.liveNode then
poolManager:UnLoadLive(this.liveName, this.liveNode)
this.liveNode = nil
this.liveName = nil
end
end
2020-09-25 14:11:05 +08:00
function ExChange:OnHide()
if this.liveNode then
poolManager:UnLoadLive(this.liveName, this.liveNode)
this.liveNode = nil
this.liveName = nil
end
end
2020-05-09 13:31:21 +08:00
--界面销毁时调用(用于子类重写)
function ExChange:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-06-28 17:52:29 +08:00
itemList = {}
ClearRedPointObject(RedPointType.LimitExchange_GoExchange, this.goBtnRedpot)
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return ExChange