miduo_client/Assets/ManagedResources/~Lua/Modules/FightLevel/View/FightLevelInfoPopup_MainLev...

243 lines
10 KiB
Lua

----- 新副本主关卡弹窗 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder = 0
local fun
local heroListGo = {}
local fightLevelData = {}
local liveNodes = {}
local liveNames = {}
local condition = {}
local conditionGo = {}
local HardStage = ConfigManager.GetConfig(ConfigName.HardStage)
local HardStageCondition = ConfigManager.GetConfig(ConfigName.HardStageCondition)
local MonsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
local starListEffect = {}
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
this.titleText = Util.GetGameObject(gameObject, "TitleText"):GetComponent("Text")
this.power = Util.GetGameObject(gameObject, "Power/Value"):GetComponent("Text")
this.sureBtn = Util.GetGameObject(gameObject, "sureBtn")
this.sureBtnText = Util.GetGameObject(gameObject, "sureBtn/Text"):GetComponent("Text")
--滚动条根节点
heroListGo = {}
for i = 1, 6 do
heroListGo[i] = Util.GetGameObject(gameObject, "RoleGrid/Bg" .. i .. "/Hero" .. i)
end
starListEffect = {}
conditionGo = {}
for i = 1, 3 do
conditionGo[i] = Util.GetGameObject(gameObject, "Root/item (" .. i .. ")")
starListEffect[i] = Util.GetGameObject(gameObject, "isFirst/Fx_star_looping (" .. i .. ")")
end
this.Root = Util.GetGameObject(gameObject, "Root")
this.backBtn = Util.GetGameObject(gameObject, "BackBtn")
this.BackBattleBtn = Util.GetGameObject(gameObject, "BackBattleBtn")
this.rewardBtn = Util.GetGameObject(gameObject, "rewardBtn")
this.isFirstEffect = Util.GetGameObject(gameObject, "isFirst")
end
function this:BindEvent()
Util.AddClick(this.sureBtn, function()
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.FIGHTLEVEL, fightLevelData)
end)
Util.AddClick(this.backBtn, function()
parent:ClosePanel()
if fun then
fun()
fun = nil
end
end)
Util.AddClick(this.BackBattleBtn, function()
FightLevelManager.HardStageReportRequset(fightLevelData, function()
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup, FIGHTLEVEL_POPUP_TYPE.MainLevel, fightLevelData)
end)
end)
Util.AddClick(this.rewardBtn, function()
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup, FIGHTLEVEL_POPUP_TYPE.MainLevelReward, fightLevelData,
function()
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup, FIGHTLEVEL_POPUP_TYPE.MainLevel,
fightLevelData)
end)
end)
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.FightLevel.MainLevelInfoRefresh, this.MainLevelInfoRefresh)
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.FightLevel.MainLevelInfoRefresh, this.MainLevelInfoRefresh)
end
function this:OnShow(_parent, ...)
parent = _parent
sortingOrder = _parent.sortingOrder
-- LogYellow("sortingOrder "..sortingOrder)
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
local args = { ... }
fightLevelData = args[1]
--条件组数据
condition = fightLevelData.config.ConditionValue or {}
this:FormationAdapter()
this:ShoeCondition()
end
function this.MainLevelInfoRefresh()
if fightLevelData then
local curChapterData = FightLevelManager.GetChapterData(fightLevelData.config.Chapter)
if curChapterData then
fightLevelData = curChapterData.node[fightLevelData.config.Id]
--条件组数据
condition = fightLevelData.config.ConditionValue or {}
this:FormationAdapter()
this:ShoeCondition()
end
else
parent:ClosePanel()
end
end
function this:ShoeCondition()
this.isFirstEffect:SetActive(fightLevelData.isFirst)
if starListEffect and #starListEffect > 0 then
for i = 1, #starListEffect do
-- Util.AddParticleSortLayer(starListEffect[i], sortingOrder)
Util.SetParticleSortLayer(starListEffect[i], sortingOrder + 1)
end
end
for i = 1, math.max(#condition, #conditionGo) do
local go = conditionGo[i]
if not go then
go = newObject(this.conditionGo[1])
go.transform:SetParent(this.Root.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
conditionGo[i] = go
end
go.gameObject:SetActive(false)
end
for i, v in pairs(condition) do
conditionGo[i]:SetActive(true)
local noStarImage = Util.GetGameObject(conditionGo[i], "noStarImage")
local getStarImage = Util.GetGameObject(conditionGo[i], "getStarImage")
noStarImage:SetActive(not FightLevelManager.GetCurLevelStarState(fightLevelData.state, i))
getStarImage:SetActive(FightLevelManager.GetCurLevelStarState(fightLevelData.state, i))
Util.GetGameObject(conditionGo[i], "Text"):GetComponent("Text").text = i
Util.GetGameObject(conditionGo[i], "infolText"):GetComponent("Text").text = GetLanguageStrById(
HardStageCondition[v].Describe)
end
end
-- 编队数据匹配
function this:FormationAdapter()
this.titleText.text = Language[10805]
this.sureBtnText.text = Language[10340]
this.power.text = fightLevelData.config.RecommendFightAbility
for i = 1, #heroListGo do
heroListGo[i]:SetActive(false)
end
local MonsterGroup = ConfigManager.GetConfigData(ConfigName.MonsterGroup, fightLevelData.config.MonsterGroup)
if MonsterGroup and MonsterGroup.Contents and MonsterGroup.Contents[1] and #MonsterGroup.Contents[1] > 0 then
for i = 1, #heroListGo do
if MonsterGroup.Contents[1][i] and MonsterGroup.Contents[1][i] > 0 then
local pos = i
-- LogYellow("MonsterGroup.Contents[1][i] "..MonsterGroup.Contents[1][i])
this.SetCardSingleData(heroListGo[pos], MonsterGroup.Contents[1][i], pos)
heroListGo[pos]:SetActive(true)
end
end
end
end
function this:OnSortingOrderChange(_sortingOrder)
for i = 1, #heroListGo do
-- Util.AddParticleSortLayer(heroListGo[i], _sortingOrder - sortingOrder)
Util.SetParticleSortLayer(heroListGo[i], _sortingOrder + 1)
end
if starListEffect and #starListEffect > 0 then
for i = 1, #starListEffect do
-- Util.AddParticleSortLayer(starListEffect[i], _sortingOrder - sortingOrder)
Util.SetParticleSortLayer(starListEffect[i], _sortingOrder + 1)
end
sortingOrder = _sortingOrder
end
end
--设置单个上阵英雄信息
function this.SetCardSingleData(o, monsterId, _pos)
local curMonsterConfig = MonsterConfig[monsterId]
o.transform.parent:GetComponent("Image").sprite = this.spLoader:LoadSprite("t_chengyuankuang_kuang")
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig,
curMonsterConfig.MonsterId)
local bg = Util.GetGameObject(o, "Bg1"):GetComponent("Image")
local fg = Util.GetGameObject(o, "Bg2"):GetComponent("Image")
local lv = Util.GetGameObject(o, "lv/Text"):GetComponent("Text")
local pro = Util.GetGameObject(o, "Pro/Image"):GetComponent("Image")
local starGrid = Util.GetGameObject(o, "StarGrid")
local nameParent = Util.GetGameObject(o, "Name") -- 用于解决本地化问题
local name = Util.GetGameObject(nameParent, "Text"):GetComponent("Text")
local yuanImage = Util.GetGameObject(o, "yuanImage")
Util.GetGameObject(o, "hpProgress"):SetActive(false)
local rage = Util.GetGameObject(o, "rageProgress/rage"):GetComponent("Image")
local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage")
live.transform.rotation = Vector3.New(0, 0, 0)
local liveName = GetResourcePath(heroConfig.Live)
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroConfig.Id)
local scale = roleConfig.play_liveScale
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
live.texture = CardRendererManager.GetSpineTexture(_pos + 6, liveName, Vector3.one * scale, livePos, true)
live.transform.localScale = Vector3.one
live.transform.localPosition = Vector3.zero
if heroConfig.Toward == 2 then
SetHEeroLiveToward(live, 1)
end
local zs = Util.GetGameObject(o, "zs")
local zsName = GetHeroCardStarZs[curMonsterConfig.Star]
if zsName == "" then
zs:SetActive(false)
else
zs:SetActive(true)
zs:GetComponent("Image").sprite = this.spLoader:LoadSprite(zsName)
end
yuanImage:SetActive(false)
lv.text = curMonsterConfig.Level
bg.sprite = this.spLoader:LoadSprite(GetHeroCardStarBg[curMonsterConfig.Star])
fg.sprite = this.spLoader:LoadSprite(GetHeroCardStarFg[curMonsterConfig.Star])
pro.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
SetCardStars(starGrid, curMonsterConfig.Star)
if curMonsterConfig.Star > 9 then
Util.GetGameObject(o, "UI_Effect_jinkuang_KaPai").gameObject:SetActive(true)
else
Util.GetGameObject(o, "UI_Effect_jinkuang_KaPai").gameObject:SetActive(false)
end
SetHeroFormationFlyEffect(o, this.spLoader, Util.GetGameObject(o, "UI_Effect_jinkuang_KaPai"), curMonsterConfig.Star,
sortingOrder)
name.text = GetLanguageStrById(heroConfig.ReadingName)
--SetTextVerTial(name.gameObject, Vector3.New(35, -7.45, 0), nil, nil, 8)
end
function this:OnClose()
for i, v in pairs(liveNodes) do
if v then
poolManager:UnLoadLive(liveNames[i], v)
liveNames[i] = nil
end
end
end
function this:OnDestroy()
this.spLoader:Destroy()
heroListGo = {}
end
return this