217 lines
8.3 KiB
Lua
217 lines
8.3 KiB
Lua
require("Base/BasePanel")
|
|
local TaSuiLingXiao = Inherit(BasePanel)
|
|
local skillConfig = ConfigManager.GetConfig(ConfigName.SkillConfig)
|
|
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
|
|
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
|
|
function TaSuiLingXiao:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
self.time = Util.GetGameObject(self.gameObject, "time"):GetComponent("Text")
|
|
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.btnRank = Util.GetGameObject(self.gameObject, "btnRank")
|
|
self.btnBox = Util.GetGameObject(self.gameObject, "progress/box")
|
|
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")
|
|
self.slide = Util.GetGameObject(self.mid, "progress/slide"):GetComponent("Image")
|
|
self.helpPosition = self.btnHelp:GetComponent("RectTransform").localPosition
|
|
self.liveRoot = Util.GetGameObject(self.gameObject, "bg/liveRoot")
|
|
self.skillPre = Util.GetGameObject(self.gameObject, "skillPre")
|
|
self.scrollItem = Util.GetGameObject(self.gameObject, "SkillList")
|
|
self.sortingOrder = 0
|
|
self.itemsGrid = {}
|
|
self.itemList = {}
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function TaSuiLingXiao:BindEvent()
|
|
Util.AddClick(self.btnHelp, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.TaSuiLingXiao,self.helpPosition.x,self.helpPosition.y)
|
|
end)
|
|
|
|
Util.AddClick(self.btnFight,function()
|
|
--开始战斗
|
|
-- TODO: 没有战斗结果校验
|
|
NetManager.TasuilingxiaoRequest(self.actData.activityId,function(msg)
|
|
CommonActPageManager.TaSuiLingXiaoMsg = msg
|
|
local fightData = BattleManager.GetBattleServerData(msg,0)
|
|
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.TASUILINGXIAO,function ()
|
|
self:Refresh()
|
|
end)
|
|
end)
|
|
end)
|
|
Util.AddClick(self.btnTeam, function()
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.SAVE_FORMATION)
|
|
end)
|
|
Util.AddClick(self.btnReward, function()
|
|
MonsterCampManager.preType = 4
|
|
UIManager.OpenPanel(UIName.TrialRewardPopup,self.actData.rewards,nil,4)
|
|
end)
|
|
Util.AddClick(self.btnBox, function()
|
|
MonsterCampManager.preType = 4
|
|
UIManager.OpenPanel(UIName.TrialRewardPopup,self.actData.rewards,nil,4)
|
|
end)
|
|
Util.AddClick(self.btnBack, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(self.btnRank, function()
|
|
UIManager.OpenPanel(UIName.RankingSingleListPanel, rankKingList[17])
|
|
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 = CommonActPageManager.GetData(ActivityTypeDef.TaSuiLingXiao)
|
|
CommonActPageManager.TaSuiLingXiaoHistoryDmg = self.actData.value
|
|
self.configData = ConfigManager.GetConfigData(ConfigName.NewHeroConfig,self.actData.activityId)
|
|
TaSuiLingXiao:ShowLive()
|
|
TaSuiLingXiao:SetTime()
|
|
TaSuiLingXiao:ShowSkillList()
|
|
TaSuiLingXiao:ShowSlide()
|
|
end
|
|
|
|
function TaSuiLingXiao:ShowLive()
|
|
|
|
if self.LiveObj then
|
|
poolManager:UnLoadLive(self.LiveObj.name,self.LiveObj)
|
|
self.LiveObj = nil
|
|
end
|
|
self.configData = ConfigManager.GetConfigData(ConfigName.NewHeroConfig,self.actData.activityId)
|
|
local imgName = GetResourcePath(ConfigManager.GetConfigData(ConfigName.HeroConfig,self.configData.HeroId).Painting)
|
|
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]
|
|
end
|
|
|
|
function TaSuiLingXiao:ShowSkillList()
|
|
if not self.itemList then
|
|
self.itemList = {}
|
|
end
|
|
for k,v in ipairs(self.itemList) do
|
|
v.gameObject:SetActive(false)
|
|
end
|
|
|
|
for i = 1,#self.configData.Skill do
|
|
local skillData = {}
|
|
local skill = self.configData.Skill[i]
|
|
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
|
|
end
|
|
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]]
|
|
end
|
|
local icon = Util.GetGameObject(self.itemList[i],"Image"):GetComponent("Image")
|
|
icon.sprite = self.spLoader:LoadSprite(artConfig[skillData.Icon].Name)
|
|
self.itemList[i]:SetActive(true)
|
|
|
|
ForceRebuildLayout(self.scrollItem.transform)
|
|
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)
|
|
end
|
|
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:ShowSlide()
|
|
local historyMax = self.actData.value
|
|
local bossMax = self.configData.BoxList[#self.configData.BoxList][1]
|
|
local curBoss = 0
|
|
local boxId = 11016
|
|
local count = ""
|
|
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)
|
|
break
|
|
end
|
|
end
|
|
self.btnBox:GetComponent("Image").sprite = self.spLoader:LoadSprite(artConfig[boxId].Name)
|
|
self.progressNum.text = string.format("%s/%s",historyMax,curBoss)
|
|
self.count.text = count
|
|
self.slide.fillAmount = historyMax/curBoss
|
|
self.finishedText:SetActive(historyMax == bossMax)
|
|
self.progress:SetActive((historyMax > 0) and (historyMax < bossMax))
|
|
end
|
|
|
|
function TaSuiLingXiao:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function TaSuiLingXiao:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
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
|
|
self.sortingOrder = 0
|
|
self.itemsGrid = {}
|
|
self.itemList = {}
|
|
end
|
|
|
|
function TaSuiLingXiao:OnHide()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
self.sortingOrder = 0
|
|
end
|
|
|
|
return TaSuiLingXiao |