248 lines
9.9 KiB
Lua
248 lines
9.9 KiB
Lua
----- 新副本副关卡弹窗 -----
|
|
local this = {}
|
|
--传入父脚本模块
|
|
local parent
|
|
--传入特效层级
|
|
local sortingOrder=0
|
|
local fun
|
|
local heroListGo = {}
|
|
local fightLevelData = {}
|
|
local liveNodes = {}
|
|
local liveNames = {}
|
|
local rewardGoList = {}
|
|
local rewardItemViewGoList = {}
|
|
local curShowIndex = true
|
|
local HardStageBuff = ConfigManager.GetConfig(ConfigName.HardStageBuff)
|
|
local RewardGroup = ConfigManager.GetConfig(ConfigName.RewardGroup)
|
|
local MonsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
|
|
function this:InitComponent(gameObject)
|
|
this.spLoader = SpriteLoader.New()
|
|
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
|
|
this.tip=Util.GetGameObject(gameObject,"tip"):GetComponent("Text")
|
|
this.conditionInfoText=Util.GetGameObject(gameObject,"conditionInfoText")
|
|
this.power = Util.GetGameObject(gameObject, "Power/Value"):GetComponent("Text")
|
|
this.sureBtn=Util.GetGameObject(gameObject,"sureBtn")
|
|
this.sureBtnText=Util.GetGameObject(gameObject,"sureBtn/Text"):GetComponent("Text")
|
|
--滚动条根节点
|
|
rewardGoList = {}
|
|
rewardItemViewGoList = {}
|
|
this.itemPre = Util.GetGameObject(gameObject, "itemPre")
|
|
this.rewardRoot = Util.GetGameObject(gameObject, "rewardRoot")
|
|
this.NoviceItemList={}--存储itemview 重复利用
|
|
|
|
heroListGo = {}
|
|
for i = 1, 6 do
|
|
heroListGo[i] = Util.GetGameObject(gameObject, "RoleGrid/Bg"..i.."/Hero"..i)
|
|
end
|
|
this.backBtn=Util.GetGameObject(gameObject,"BackBtn")
|
|
this.BackBattleBtn=Util.GetGameObject(gameObject,"BackBattleBtn")
|
|
-- this.rewardBtn=Util.GetGameObject(gameObject,"rewardBtn")
|
|
this.leftBtn=Util.GetGameObject(gameObject,"leftBtn")
|
|
this.rightBtn=Util.GetGameObject(gameObject,"rightBtn")
|
|
this.leftBtnClick=Util.GetGameObject(gameObject,"leftBtn/GameObject")
|
|
this.rightBtnClick=Util.GetGameObject(gameObject,"rightBtn/GameObject")
|
|
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.AssistantLevel,fightLevelData)
|
|
end)
|
|
end)
|
|
-- Util.AddClick(this.rewardBtn, function()
|
|
-- parent:ClosePanel()
|
|
-- end)
|
|
Util.AddClick(this.leftBtnClick, function()
|
|
this.LeftOrRightBtnClickEvent()
|
|
end)
|
|
Util.AddClick(this.rightBtnClick, function()
|
|
this.LeftOrRightBtnClickEvent()
|
|
end)
|
|
end
|
|
|
|
function this:AddListener()
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
end
|
|
function this:OnShow(_parent,...)
|
|
parent=_parent
|
|
sortingOrder = _parent.sortingOrder
|
|
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
|
|
local args = {...}
|
|
fightLevelData = args[1]
|
|
this.titleText.text="关卡情报"
|
|
this.tip.text="特殊规则"
|
|
this.conditionInfoText:GetComponent("Text").text = HardStageBuff[fightLevelData.config.HardStageBuff] and HardStageBuff[fightLevelData.config.HardStageBuff].Describe or ""
|
|
this.sureBtnText.text=Language[10287]
|
|
this.power.text = fightLevelData.config.RecommendFightAbility
|
|
curShowIndex = true
|
|
this.LeftOrRightBtnClickEvent()
|
|
this:ShoeReward()
|
|
this:FormationAdapter()
|
|
end
|
|
|
|
function this:ShoeReward()
|
|
local rewardDataList = {}
|
|
for i = 1, #fightLevelData.config.PassReward do
|
|
if RewardGroup[fightLevelData.config.PassReward[i]] and RewardGroup[fightLevelData.config.PassReward[i]].ShowItem then
|
|
for j = 1, #RewardGroup[fightLevelData.config.PassReward[i]].ShowItem do
|
|
table.insert(rewardDataList,RewardGroup[fightLevelData.config.PassReward[i]].ShowItem[j])
|
|
end
|
|
end
|
|
end
|
|
for i = 1, math.max(#rewardDataList, #rewardGoList) do
|
|
local go = rewardGoList[i]
|
|
if not go then
|
|
go = newObject(this.itemPre)
|
|
go.transform:SetParent(this.rewardRoot.transform)
|
|
go.transform.localScale = Vector3.one
|
|
go.transform.localPosition = Vector3.zero
|
|
rewardGoList[i] = go
|
|
end
|
|
go.gameObject:SetActive(false)
|
|
end
|
|
for i, v in pairs(rewardDataList) do
|
|
local _go = rewardGoList[i]
|
|
_go:SetActive(true)
|
|
local itemParent = Util.GetGameObject(_go, "parent")
|
|
if fightLevelData.state == 0 then--副关卡未通过
|
|
Util.GetGameObject(_go, "getImage"):SetActive(false)
|
|
elseif fightLevelData.state == 1 then--副关卡已通过
|
|
Util.GetGameObject(_go, "getImage"):SetActive(true)
|
|
end
|
|
if not this.NoviceItemList[_go] then
|
|
this.NoviceItemList[_go] = SubUIManager.Open(SubUIConfig.ItemView, itemParent.transform)
|
|
end
|
|
this.NoviceItemList[_go]:OnOpen(false, v, 0.9,false,false,false,sortingOrder)
|
|
end
|
|
end
|
|
-- 编队数据匹配
|
|
function this:FormationAdapter()
|
|
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)
|
|
end
|
|
for i, v in pairs(this.NoviceItemList) do
|
|
if this.NoviceItemList[i] and this.NoviceItemList[i].gameObject then
|
|
this.NoviceItemList[i]:SetEffectLayer(sortingOrder)
|
|
end
|
|
end
|
|
sortingOrder = _sortingOrder
|
|
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 live=Util.GetGameObject(o,"Mask/Live")
|
|
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 pos=Util.GetGameObject(o,"Pos"):GetComponent("Image")
|
|
local yuanImage=Util.GetGameObject(o,"yuanImage")
|
|
Util.GetGameObject(o,"hpProgress"):SetActive(false)
|
|
-- local hp = Util.GetGameObject(o,"hpProgress/hp"):GetComponent("Image")
|
|
-- local hpPass = Util.GetGameObject(o,"hpProgress/hpPass"):GetComponent("Image")
|
|
-- local rage = Util.GetGameObject(o,"rageProgress/rage"):GetComponent("Image")
|
|
|
|
local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage")
|
|
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
|
|
|
|
local zs = Util.GetGameObject(o, "zs")
|
|
local zsName = GetHeroCardStarZs[curMonsterConfig.Star]
|
|
if zsName == "" then
|
|
zs:SetActive(false)
|
|
else
|
|
zs:SetActive(false)
|
|
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)
|
|
|
|
|
|
-- local curHeroHpVal = 1
|
|
-- hp.fillAmount = curHeroHpVal
|
|
-- hpPass.fillAmount = curHeroHpVal
|
|
-- rage.fillAmount = 0.5
|
|
end
|
|
function this.LeftOrRightBtnClickEvent()
|
|
curShowIndex = not curShowIndex
|
|
if curShowIndex then
|
|
this.conditionInfoText:SetActive(false)
|
|
this.rewardRoot:SetActive(true)
|
|
this.tip.text="首通奖励"
|
|
else
|
|
this.conditionInfoText:SetActive(true)
|
|
this.rewardRoot:SetActive(false)
|
|
this.tip.text="特殊规则"
|
|
end
|
|
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 |