213 lines
7.6 KiB
Lua
213 lines
7.6 KiB
Lua
----- 送神弹窗 -----
|
|
local this = {}
|
|
--传入父脚本模块
|
|
local parent
|
|
--传入特效层级
|
|
local sortingOrder=0
|
|
local heros=nil
|
|
local confirmFunc=nil
|
|
local currHeroId=0
|
|
local curPage = 1
|
|
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
function this:InitComponent(gameObject)
|
|
this.spLoader = SpriteLoader.New()
|
|
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
|
|
this.cancelBtn=Util.GetGameObject(gameObject,"CancelBtn")
|
|
this.confirmBtn=Util.GetGameObject(gameObject,"ConfirmBtn")
|
|
this.FourStarUpTip=Util.GetGameObject(gameObject,"tip"):GetComponent("Text")
|
|
this.FourStarUpTip.text = "长按头像可查看英雄详情"
|
|
this.selectObj=Util.GetGameObject(gameObject,"choosed")
|
|
this.prefab=Util.GetGameObject(gameObject,"item")
|
|
--滚动条根节点
|
|
this.root = Util.GetGameObject(gameObject, "Root")
|
|
this.preList={}
|
|
|
|
local rootHight = this.root.transform.rect.height
|
|
local width = this.root.transform.rect.width
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.root.transform,
|
|
this.prefab,nil, Vector2.New(width, rootHight), 1, 5,Vector2.New(20,80))
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
this.ScrollView.moveTween.Strength = 2
|
|
this.ScrollView.elastic = false
|
|
|
|
|
|
this.selectBar = Util.GetGameObject(gameObject,"selectBar")
|
|
this.light = Util.GetGameObject(this.selectBar,"selectBtn")
|
|
this.btnList = {}
|
|
for i = 1, 6 do
|
|
this.btnList[i] = Util.GetGameObject(this.selectBar,"btn"..i)
|
|
end
|
|
this.choosedList = {}
|
|
end
|
|
|
|
function this:BindEvent()
|
|
Util.AddClick(this.cancelBtn,function()
|
|
parent:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.confirmBtn,function()
|
|
if confirmFunc then
|
|
confirmFunc(currHeroId)
|
|
end
|
|
parent:ClosePanel()
|
|
end)
|
|
for i = 1, 6 do
|
|
Util.AddClick(this.btnList[i],function()
|
|
if curPage ~= i then
|
|
this:Refresh(i)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
function this:AddListener()
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
end
|
|
|
|
function this:OnShow(_parent,_args)
|
|
heros = _args[1]
|
|
currHeroId=_args[2]
|
|
confirmFunc=_args[3]
|
|
-- 标题修改
|
|
local title =_args[4]
|
|
this.titleText.text = title or "许愿英雄"
|
|
|
|
parent=_parent
|
|
sortingOrder =_parent.sortingOrder
|
|
local default = 1
|
|
if currHeroId and currHeroId ~= 0 then
|
|
for index, value in ipairs(heros) do
|
|
if value[1] == currHeroId then
|
|
default = value[2]
|
|
break
|
|
end
|
|
end
|
|
end
|
|
this:Refresh(default)
|
|
end
|
|
function this:Refresh(_page)
|
|
curPage = _page
|
|
this.light.transform:SetParent(this.btnList[_page].transform)
|
|
this.light.transform.localPosition = Vector3.zero
|
|
|
|
local heroDatas={}
|
|
for i = 1, #heros do
|
|
-- LogError(heros[i][1].." "..heros[i][2].." "..heros[i][3])
|
|
local CONFIG = heros[i][2] and itemConfig or heroConfig
|
|
if CONFIG[heros[i][1]] then
|
|
if not heroDatas[heros[i][2]] then
|
|
heroDatas[heros[i][2]] = {}
|
|
end
|
|
|
|
--LogError("groupid=="..CONFIG[heros[i][1]].RewardGroup[1])
|
|
local group=ConfigManager.TryGetConfigData(ConfigName.RewardGroup,CONFIG[heros[i][1]].RewardGroup[1])
|
|
local heroId=0
|
|
if group and group.ShowItem then
|
|
-- LogError("group.ShowItem[1]=="..group.ShowItem[1])
|
|
-- LogError("group.ShowItem[1][1]=="..group.ShowItem[1][1])
|
|
heroId=group.ShowItem[1][1]
|
|
end
|
|
--如果没有3 说明是升星活动进来的这个界面
|
|
if heros[i][3] then
|
|
-- 特殊物品 或者 加入了版本的神将
|
|
if heros[i][2] == 6 or (group and HeroManager.InVersion(group.ShowItem[1][1]) ) then
|
|
table.insert(heroDatas[heros[i][2]],{CONFIG[heros[i][1]],heros[i][2],heros[i][3],heros[i][1],heroId})
|
|
end
|
|
else
|
|
if heros[i][2] == 6 or HeroManager.InVersion(heros[i][1]) then
|
|
table.insert(heroDatas[heros[i][2]],{CONFIG[heros[i][1]],heros[i][2],heros[i][3],heros[i][1]})
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
for i = 1, 6 do
|
|
if not heroDatas[i] then
|
|
this.btnList[i]:SetActive(false)
|
|
else
|
|
this.btnList[i]:SetActive(true)
|
|
end
|
|
end
|
|
this.ScrollView:SetData(heroDatas[curPage], function(index, go)
|
|
this.SingleHeroDataShow(go,heroDatas[curPage][index],index)
|
|
end)
|
|
end
|
|
|
|
--英雄单个数据展示
|
|
function this.SingleHeroDataShow(go,_heroData,_index)
|
|
local heroData = _heroData[1]
|
|
local itemType = _heroData[2]
|
|
LogError("herodata id=="..heroData.Id)
|
|
local _go = go
|
|
_go.gameObject:SetActive(true)
|
|
local frame = Util.GetGameObject(_go.transform, "frame"):GetComponent("Image")
|
|
local name = Util.GetGameObject(_go.transform, "Text"):GetComponent("Text")
|
|
local icon = Util.GetGameObject(_go.transform, "icon"):GetComponent("Image")
|
|
local proIcon = Util.GetGameObject(_go.transform, "proIcon"):GetComponent("Image")
|
|
proIcon.gameObject:SetActive(true)
|
|
local starGrid = Util.GetGameObject(_go.transform, "star")
|
|
local numText = Util.GetGameObject(_go.transform, "numTxt"):GetComponent("Text")
|
|
local chipImg=Util.GetGameObject(_go.transform, "chipFrame"):GetComponent("Image")
|
|
chipImg.gameObject:SetActive(false)
|
|
starGrid:SetActive(true)
|
|
local choosed = Util.GetGameObject(_go.transform, "choosed")
|
|
local cardclickBtn = Util.GetGameObject(_go.transform, "icon")
|
|
|
|
-- if itemType ~= 6 then
|
|
-- name.text = SubString2(GetLanguageStrById(heroData.ReadingName),8)
|
|
-- icon.sprite = this.spLoader:LoadSprite(artResourcesConfig[heroData.Icon].Name)
|
|
-- proIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
|
|
-- SetHeroStars(this.spLoader, starGrid, heroData.Star,1,nil,-15)
|
|
-- frame.sprite = this.spLoader:LoadSprite("UI_hz_beibao_pinjise_huangse")
|
|
-- numText.gameObject:SetActive(false)
|
|
-- else
|
|
name.text = SubString2(GetLanguageStrById(heroData.Name),8)
|
|
icon.sprite = this.spLoader:LoadSprite(artResourcesConfig[heroData.ResourceID].Name)
|
|
proIcon.gameObject:SetActive(false)
|
|
starGrid:SetActive(false)
|
|
numText.gameObject:SetActive(true)
|
|
numText.text=_heroData[3]
|
|
frame.sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.Quantity,heroData.Star))
|
|
if heroData.ItemType==2 then
|
|
chipImg.gameObject:SetActive(true)
|
|
chipImg.sprite=this.spLoader:LoadSprite(GetHeroChipQuantityImageByquality(heroData.Quantity))
|
|
-- body
|
|
end
|
|
--end
|
|
this.choosedList[go] = choosed
|
|
this.choosedList[go]:SetActive( heroData.Id==currHeroId)
|
|
|
|
Util.AddOnceClick(cardclickBtn, function()
|
|
currHeroId=heroData.Id
|
|
for k,v in pairs(this.choosedList) do
|
|
v:SetActive(false)
|
|
end
|
|
choosed:SetActive(true)
|
|
end)
|
|
|
|
Util.AddLongPressClick(cardclickBtn, function()
|
|
if itemType ~= 6 then
|
|
UIManager.OpenPanel(UIName.RoleGetInfoPopup, false,_heroData[5],10)
|
|
else
|
|
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,heroData.Id)
|
|
end
|
|
end, 0.5)
|
|
end
|
|
|
|
|
|
function this:OnClose()
|
|
currHeroId=0
|
|
heros=nil
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
this.choosedList = {}
|
|
this.btnList = {}
|
|
end
|
|
|
|
return this |