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

217 lines
8.3 KiB
Lua
Raw Normal View History

2021-05-11 17:03:09 +08:00
require("Base/BasePanel")
2021-04-22 15:40:21 +08:00
local TaSuiLingXiao = Inherit(BasePanel)
2021-04-23 15:39:46 +08:00
local skillConfig = ConfigManager.GetConfig(ConfigName.SkillConfig)
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
2021-04-22 15:40:21 +08:00
function TaSuiLingXiao:InitComponent()
self.spLoader = SpriteLoader.New()
2021-04-22 15:40:21 +08:00
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")
2021-05-28 14:05:17 +08:00
self.btnRank = Util.GetGameObject(self.gameObject, "btnRank")
self.btnBox = Util.GetGameObject(self.gameObject, "progress/box")
2021-04-29 15:40:10 +08:00
self.mid = Util.GetGameObject(self.gameObject, "mid")
self.finishedText = Util.GetGameObject(self.mid, "FinishedText")
self.progress = Util.GetGameObject(self.mid, "progress")
self.progressNum = Util.GetGameObject(self.mid, "progress/num"):GetComponent("Text")
self.count = Util.GetGameObject(self.mid, "progress/count"):GetComponent("Text")
2021-04-29 15:40:10 +08:00
self.slide = Util.GetGameObject(self.mid, "progress/slide"):GetComponent("Image")
2021-04-23 17:56:57 +08:00
self.helpPosition = self.btnHelp:GetComponent("RectTransform").localPosition
2021-04-22 15:40:21 +08:00
self.liveRoot = Util.GetGameObject(self.gameObject, "bg/liveRoot")
2021-04-23 14:12:24 +08:00
self.skillPre = Util.GetGameObject(self.gameObject, "skillPre")
self.scrollItem = Util.GetGameObject(self.gameObject, "SkillList")
2021-04-22 15:40:21 +08:00
self.sortingOrder = 0
2021-04-23 14:12:24 +08:00
self.itemsGrid = {}
2021-04-23 16:18:56 +08:00
self.itemList = {}
2021-04-22 15:40:21 +08:00
end
--绑定事件(用于子类重写)
function TaSuiLingXiao:BindEvent()
2021-04-23 14:12:24 +08:00
Util.AddClick(self.btnHelp, function()
2021-04-22 15:40:21 +08:00
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
--开始战斗
-- TODO: 没有战斗结果校验
2021-04-23 17:56:57 +08:00
NetManager.TasuilingxiaoRequest(self.actData.activityId,function(msg)
2021-04-25 15:07:36 +08:00
CommonActPageManager.TaSuiLingXiaoMsg = msg
2021-04-22 15:40:21 +08:00
local fightData = BattleManager.GetBattleServerData(msg,0)
2021-04-25 15:07:36 +08:00
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.TASUILINGXIAO,function ()
self:Refresh()
2021-04-22 15:40:21 +08:00
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()
2021-04-25 15:07:36 +08:00
MonsterCampManager.preType = 4
UIManager.OpenPanel(UIName.TrialRewardPopup,self.actData.rewards,nil,4)
2021-04-22 17:22:49 +08:00
end)
Util.AddClick(self.btnBox, function()
MonsterCampManager.preType = 4
UIManager.OpenPanel(UIName.TrialRewardPopup,self.actData.rewards,nil,4)
end)
2021-04-23 14:12:24 +08:00
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
2021-05-28 14:05:17 +08:00
Util.AddClick(self.btnRank, function()
UIManager.OpenPanel(UIName.RankingSingleListPanel, rankKingList[17])
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()
2021-04-23 14:12:24 +08:00
self.actData = CommonActPageManager.GetData(ActivityTypeDef.TaSuiLingXiao)
2021-04-26 16:20:22 +08:00
CommonActPageManager.TaSuiLingXiaoHistoryDmg = self.actData.value
2021-04-27 22:26:36 +08:00
self.configData = ConfigManager.GetConfigData(ConfigName.NewHeroConfig,self.actData.activityId)
TaSuiLingXiao:ShowLive()
2021-04-22 15:40:21 +08:00
TaSuiLingXiao:SetTime()
2021-04-23 16:18:56 +08:00
TaSuiLingXiao:ShowSkillList()
TaSuiLingXiao:ShowSlide()
2021-04-22 15:40:21 +08:00
end
2021-04-23 14:12:24 +08:00
function TaSuiLingXiao:ShowLive()
2021-04-22 15:40:21 +08:00
if self.LiveObj then
poolManager:UnLoadLive(self.LiveObj.name,self.LiveObj)
self.LiveObj = nil
end
2021-04-23 15:39:46 +08:00
self.configData = ConfigManager.GetConfigData(ConfigName.NewHeroConfig,self.actData.activityId)
2023-11-14 14:09:22 +08:00
local imgName = GetResourcePath(ConfigManager.GetConfigData(ConfigName.HeroConfig,self.configData.HeroId).Painting)
2021-04-23 16:18:56 +08:00
self.LiveObj = poolManager:LoadLive(imgName,self.liveRoot.transform, Vector3.one, Vector2.New(self.configData.Size[2],self.configData.Size[3]))
self.liveRoot:GetComponent("RectTransform").localScale = Vector3.one*self.configData.Size[1]
2021-04-22 15:40:21 +08:00
end
2021-04-23 14:12:24 +08:00
function TaSuiLingXiao:ShowSkillList()
2021-04-23 16:18:56 +08:00
if not self.itemList then
self.itemList = {}
2021-04-23 14:12:24 +08:00
end
2021-04-23 16:18:56 +08:00
for k,v in ipairs(self.itemList) do
2021-04-23 14:12:24 +08:00
v.gameObject:SetActive(false)
end
2021-04-23 16:18:56 +08:00
for i = 1,#self.configData.Skill do
2021-04-23 15:39:46 +08:00
local skillData = {}
2021-04-23 16:18:56 +08:00
local skill = self.configData.Skill[i]
2021-04-23 15:39:46 +08:00
if not self.itemList[i] then
self.itemList[i] = newObject(self.skillPre)
self.itemList[i].transform:SetParent(self.scrollItem.transform)
self.itemList[i].transform.localScale = Vector3.one
self.itemList[i].transform.localPosition = Vector3.zero
2021-04-23 14:12:24 +08:00
end
2021-04-23 16:18:56 +08:00
if self.configData.Skill[i][1] == 1 then
skillData = skillConfig[self.configData.Skill[i][2]]
elseif self.configData.Skill[i][1] == 2 then
skillData = passiveSkillConfig[self.configData.Skill[i][2]]
2021-04-23 15:39:46 +08:00
end
2021-04-27 22:26:36 +08:00
local icon = Util.GetGameObject(self.itemList[i],"Image"):GetComponent("Image")
icon.sprite = self.spLoader:LoadSprite(artConfig[skillData.Icon].Name)
2021-04-23 16:18:56 +08:00
self.itemList[i]:SetActive(true)
2021-04-23 17:56:57 +08:00
2021-04-23 19:37:15 +08:00
ForceRebuildLayout(self.scrollItem.transform)
2021-04-23 17:56:57 +08:00
local curSkillData = {}
curSkillData.skillConfig = skillData
local pos = Vector2.New(0,self.itemList[i].gameObject:GetComponent("RectTransform").localPosition.y + self.scrollItem:GetComponent("RectTransform").localPosition.y)
Util.AddOnceClick(self.itemList[i], function()
local maxLv= HeroManager.GetHeroSkillMaxLevel(self.configData.HeroId,skillData.Type)
UIManager.OpenPanel(UIName.SkillInfoPopup,curSkillData,1,10,maxLv,i,pos)
end)
2021-04-23 14:12:24 +08:00
end
end
2021-04-22 15:40:21 +08:00
function TaSuiLingXiao:SetTime()
if self.timer then
self.timer:Stop()
self.timer = nil
2021-04-23 17:56:57 +08:00
end
2021-04-22 15:40:21 +08:00
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:ShowSlide()
local historyMax = self.actData.value
local bossMax = self.configData.BoxList[#self.configData.BoxList][1]
2021-04-29 15:40:10 +08:00
local curBoss = 0
2021-04-29 16:24:55 +08:00
local boxId = 11016
local count = ""
2021-04-29 15:40:10 +08:00
for i = 1, #self.configData.BoxList do
if historyMax < self.configData.BoxList[i][1] then
curBoss = self.configData.BoxList[i][1]
boxId = self.configData.BoxList[i][2]
count = string.format("%s/%s",i,#self.configData.BoxList)
2021-04-29 15:40:10 +08:00
break
end
end
self.btnBox:GetComponent("Image").sprite = self.spLoader:LoadSprite(artConfig[boxId].Name)
2021-04-29 15:40:10 +08:00
self.progressNum.text = string.format("%s/%s",historyMax,curBoss)
self.count.text = count
2021-04-29 15:40:10 +08:00
self.slide.fillAmount = historyMax/curBoss
self.finishedText:SetActive(historyMax == bossMax)
self.progress:SetActive((historyMax > 0) and (historyMax < bossMax))
end
2021-04-22 15:40:21 +08:00
function TaSuiLingXiao:OnClose()
end
--界面销毁时调用(用于子类重写)
function TaSuiLingXiao:OnDestroy()
self.spLoader:Destroy()
2021-04-22 15:40:21 +08:00
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
2021-04-23 14:12:24 +08:00
self.sortingOrder = 0
self.itemsGrid = {}
2021-04-23 16:18:56 +08:00
self.itemList = {}
2021-04-22 15:40:21 +08:00
end
function TaSuiLingXiao:OnHide()
if self.timer then
self.timer:Stop()
self.timer = nil
end
2021-04-23 14:12:24 +08:00
self.sortingOrder = 0
2021-04-22 15:40:21 +08:00
end
return TaSuiLingXiao