miduo_client/Assets/ManagedResources/~Lua/Modules/TaSuiLingXiao/TaSuiLingXiaoPanel.lua

144 lines
4.6 KiB
Lua
Raw Normal View History

2021-04-22 15:40:21 +08:00
require("Base/BasePanel")
local TaSuiLingXiao = Inherit(BasePanel)
function TaSuiLingXiao:InitComponent()
self.time = Util.GetGameObject(self.gameObject, "time"):GetComponent("Text")
2021-04-22 17:22:49 +08:00
self.btnFight = Util.GetGameObject(self.gameObject, "btnFight")
self.btnTeam = Util.GetGameObject(self.gameObject, "btnTeam")
self.btnReward = Util.GetGameObject(self.gameObject, "btnReward")
self.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
self.btnHelp = Util.GetGameObject(self.gameObject, "btnHelp")
self.helpPosition=self.btnHelp:GetComponent("RectTransform").localPosition
2021-04-22 15:40:21 +08:00
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)
2021-04-22 17:22:49 +08:00
Util.AddClick(self.btnFight,function()
2021-04-22 15:40:21 +08:00
--开始战斗
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)
2021-04-22 17:22:49 +08:00
Util.AddClick(self.btnTeam, function()
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.SAVE_FORMATION)
end)
Util.AddClick(self.btnReward, function()
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.SAVE_FORMATION)
end)
2021-04-22 15:40:21 +08:00
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