135 lines
4.2 KiB
Lua
135 lines
4.2 KiB
Lua
require("Base/BasePanel")
|
|
local TaSuiLingXiao = Inherit(BasePanel)
|
|
|
|
function TaSuiLingXiao:InitComponent()
|
|
self.time = Util.GetGameObject(self.gameObject, "time"):GetComponent("Text")
|
|
self.fightBtn = Util.GetGameObject(self.gameObject, "layout/fightBtn")
|
|
self.helpBtn = Util.GetGameObject(self.gameObject, "helpBtn")
|
|
self.helpPosition=self.helpBtn:GetComponent("RectTransform").localPosition
|
|
self.liveRoot = Util.GetGameObject(self.gameObject, "bg/liveRoot")
|
|
self.sortingOrder = 0
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function TaSuiLingXiao:BindEvent()
|
|
Util.AddClick(self.helpBtn, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.TaSuiLingXiao,self.helpPosition.x,self.helpPosition.y)
|
|
end)
|
|
|
|
Util.AddClick(self.fightBtn,function()
|
|
--开始战斗
|
|
NetManager.NewGeneralAttackRequest(self.actData.activityId,function(msg)
|
|
local fightData = BattleManager.GetBattleServerData(msg,0)
|
|
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.XINJIANG,function ()
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1,function ()
|
|
self:Refresh()
|
|
end)
|
|
end)
|
|
end)
|
|
end)
|
|
end
|
|
--添加事件监听(用于子类重写)
|
|
function TaSuiLingXiao:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function TaSuiLingXiao:RemoveListener()
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function TaSuiLingXiao:OnOpen()
|
|
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function TaSuiLingXiao:OnShow(_sortingOrder)
|
|
local actId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.TaSuiLingXiao)
|
|
if not actId or actId <= 0 then return end
|
|
self.sortingOrder = _sortingOrder
|
|
TaSuiLingXiao:Refresh()
|
|
end
|
|
|
|
function TaSuiLingXiao:Refresh()
|
|
self.actData = DynamicActivityManager.XinJiangBuildData()
|
|
TaSuiLingXiao:OnShowData()
|
|
TaSuiLingXiao:SetTime()
|
|
end
|
|
|
|
function TaSuiLingXiao:OnShowData()
|
|
|
|
if self.LiveObj then
|
|
poolManager:UnLoadLive(self.LiveObj.name,self.LiveObj)
|
|
self.LiveObj = nil
|
|
end
|
|
local configData = ConfigManager.GetConfigData(ConfigName.NewHeroConfig,self.actData.activityId)
|
|
local HeroId = configData.HeroId
|
|
local imgName = GetResourcePath(ConfigManager.GetConfigData(ConfigName.HeroConfig,HeroId).Live)
|
|
self.LiveObj = poolManager:LoadLive(imgName,self.liveRoot.transform, Vector3.one, Vector2.New(configData.Size[2],configData.Size[3]))
|
|
self.liveRoot:GetComponent("RectTransform").localScale = Vector3.one*configData.Size[1]
|
|
end
|
|
|
|
function TaSuiLingXiao:SetTime()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
local timeDown = self.actData.endTime - GetTimeStamp()
|
|
self.time.text = Language[10470]..TimeToFelaxible(timeDown)
|
|
self.timer = Timer.New(function()
|
|
timeDown = timeDown - 1
|
|
if timeDown < 1 then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
self:ClosePanel()
|
|
return
|
|
end
|
|
self.time.text = Language[10470]..TimeToFelaxible(timeDown)
|
|
end, 1, -1, true)
|
|
self.timer:Start()
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function TaSuiLingXiao:OnOpen()
|
|
|
|
end
|
|
|
|
--商店
|
|
function TaSuiLingXiao:StoreShow()
|
|
if not self.shopView then
|
|
self.shopView = SubUIManager.Open(SubUIConfig.ShopView, self.content.transform)
|
|
end
|
|
self.shopView:ShowShop(SHOP_TYPE.XINJIANG_SHOP,sortingOrder)
|
|
parent.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.TaSuiLingXiao })
|
|
end
|
|
|
|
function TaSuiLingXiao:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function TaSuiLingXiao:OnDestroy()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
if self.LiveObj then
|
|
poolManager:UnLoadLive(self.LiveObj.name,self.LiveObj)
|
|
self.LiveObj = nil
|
|
end
|
|
sortingOrder = 0
|
|
itemsGrid = {}
|
|
end
|
|
|
|
function TaSuiLingXiao:OnHide()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
if self.shopView then
|
|
self.shopView = SubUIManager.Close(self.shopView)
|
|
self.shopView = nil
|
|
end
|
|
sortingOrder = 0
|
|
end
|
|
|
|
return TaSuiLingXiao |